[texhax] memoir, hyperref, nameref

Heiko Oberdiek heiko.oberdiek at googlemail.com
Sun Apr 18 05:12:48 CEST 2010


On Sat, Apr 17, 2010 at 02:28:20PM -0400, Victor Ivrii wrote:

> I took hyperref 2010/04/16 v6.80w (including nameref 2.38) from TUG
> and tried again. Still this particular example does not work.
> (BTW, thanks for taking care of theorems)
> 
> >From foo.aux
> \newlabel{MyLabel}{{}{1}{\relax }{}{}}
> and
> bar.tex stumbles upon \ref{foo-MyLabel}
> It does not return ? but an error
> 
> {\@thirdoffive }\fi \endgroup  \end {document}
> ! File ended while scanning use of \Hy at setref@link.
> <inserted text>
>                 \par
> <*> bar.tex
> 
> ? q
> OK, entering \batchmode...
> ! Emergency stop.
> <*> bar.tex
> 
> *** (job aborted, no legal \end found)
> 
> If I manually edit
> \newlabel{MyLabel}{{}{1}{\relax }{}{}}
> replacing it by
> \newlabel{MyLabel}{{My Great Article}{1}{\relax }{}{}}
> 
> then foo.tex returns My Great Article
> 
> 
> So, I think that if the label is not inside of any environment, it is
> *still* inside of the largest environment document itself and the
> title of document should go there.

But the title can be defined after \begin{document}, the only
condition is that \title must be used before \maketitle.

> I think that this makes a sense with xr-hyper

The problem in this example is rather that xr-hyper/hyperref
don't see an anchor name and assumes that the label was written
without nameref/hyperref.
  At least I have updated hyperref v6.80x/nameref v2.39,
that the initial value is "Doc-Start" (this will be set as anchor
by hyperref in \begin{document}).

But I still don't think that \label *before* \begin{document}
is not the best recommended way. For example, before the first
page it is put on the first page (the way \special works).
Thus the page number is "1" instead of a more reasonable "0".

> \documentclass[12pt]{article}
> \usepackage{hyperref}
> \usepackage{nameref}
> \label{MyLabel}
> \begin{document}
> blah
> \end{document}

> %%%bar.tex%%%
> \documentclass[12pt]{article}
> \usepackage{xr-hyper}
> \usepackage{hyperref}
> \usepackage{nameref}
> \externaldocument[foo-]{foo}[foo.pdf]
> \begin{document}
> blah
> \nameref{foo-MyLabel}
> \end{document}

For package zref, module xr I had written a more sophisticated parser.
Now (zref v2.12) I have updated the module and added the feature to convert
the imported references to standard LaTeX references. Therefore I think,
xr-hyper/xr can be replaced by:

  \usepackage{zref-xr}
  \zxrsetup{%
    % verbose,% imported labels are shown in the .log file
    % tozreflabel=false,% if zref is not needed otherwise
    toltxlabel,
  }
  \zexternaldocument*[foo-]{foo}[foo.pdf]

If `nameref' is used (hyperref), it must be loaded *before*
the first \zexternaldocument.

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list