[pdftex] Cross reference between document including \_ underscore

Heiko Oberdiek heiko.oberdiek at googlemail.com
Thu Jan 13 05:54:37 CET 2011


On Wed, Jan 12, 2011 at 04:44:42PM +0100, Jonathan Jacqmot wrote:

> I am trying to generate hyperlinks between two pdf documents compiled from
> two distinct tex files
> 
> Unfortunately, a part of the targets contains underscore character like :
> \hypertarget{TOTO\_TATA}{}

Then "\_" including the backslash becomes part of the name.

> Two links should appear in file1.tex that should point towards two different
> locations in file2.tex. Unfortunately only the first link is working as it
> does not contain any \_ 

Inside \href, "\_" becomes "_".

> file2.tex

> \documentclass[openright,10pt,final]{book}
> 
> \usepackage[pdftex]{hyperref}  

% Redefinition of \hypertarget to change \_ to _ in the
% first argument
\newcommand\orghypertarget{}
\let\orghypertarget\hypertarget
\renewcommand{\hypertarget}[1]{%
  \begingroup
    \csname @safe at activestrue\endcsname % babel shorthand support
    \edef\_{\string_}%
    \edef\x{\endgroup
      \noexpand\orghypertarget{#1}%
    }%
  \x
}

> \hypertarget{NODE\_FORCE}{}

Yours sincerely
  Heiko Oberdiek
-- 


More information about the pdftex mailing list