[texhax] memoir, hyperref, nameref

Heiko Oberdiek oberdiek at uni-freiburg.de
Thu Apr 15 14:12:24 CEST 2010


On Thu, Apr 15, 2010 at 01:46:50PM +0200, Lars Madsen wrote:

> Victor Ivrii wrote:
> >1) At some moment (not sure when, I just noticed, but I presume that
> >it have happened on not earlier than last summer)
> >
> >\nameref command stopped working properly with memoir
> >
> >\documentclass[12pt]{memoir}
> >\usepackage{hyperref}
> >\begin{document}
> >\section{One}
> >\label{sect-1}
> >\nameref{sect-1}
> >\end{document}
> >
> >
> >produces hyperlink without text (no error returns). With {article}
> >everything works fine.
> >
> 
> interesting
> 
> I just updated, it worked before the update and not after the update

Test file, the last page should show "OK" in all nameref links:

\listfiles
\documentclass{memoir}
\usepackage{hyperref}[2010/04/15]
\AtBeginDocument{\RequirePackage{nameref}[2010/04/15]}% only date checking
\begin{document}
\makeatletter
\def\List{}
\def\Label#1{%
  \label{#1}%
  \g at addto@macro\List{%
    \par
    #1: [\nameref{#1}]%
  }%
  \mbox{}%
}
\def\Test#1{%
  \csname#1\endcsname*{OK/#1}%
  \Label{#1*}
  \csname#1\endcsname{OK/#1}%
  \Label{#1}%
  \csname#1\endcsname[OK/#1-toc]%
                     {WRONG-in-nameref/#1-toc-2}%
  \Label{#1-toc}%
  \expandafter\ifx\csname#1\endcsname\part
  \else
    \headnamereffalse
    \csname#1\endcsname[OK/#1-th-toc]%
                       [WRONG-in-nameref/#1-th-toc-2]%
                       {WRONG-in-nameref/#1-th-toc-3}%
    \Label{#1-th-toc}%
    \headnamereftrue
    \csname#1\endcsname[WRONG-in-nameref/#1-th-head-1]%
                       [OK/#1-th-head]%
                       {WRONG-in-nameref/#1-th-head-3}%
    \Label{#1-th-head}%
  \fi
}
\@for\x:=part,chapter,section,subsection,subsubsection\do{%
  \expandafter\Test\expandafter{\x}%
}
\List
\end{document}

 *File List*
  memoir.cls    2010/02/20 v1.618033988c configurable book, report, article
doc
ument class
   ifpdf.sty    2010/01/28 v2.1 Provides the ifpdf switch (HO)
 ifxetex.sty    2009/01/23 v0.5 Provides ifxetex conditional
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
   mem10.clo    2008/01/30 v0.3 memoir class 10pt size option
mempatch.sty    2009/07/24 v6.0f Patches for memoir class v1.6180339
hyperref.sty    2010/04/15 v6.80v Hypertext links for LaTeX
 ltxcmds.sty    2010/04/08 v1.5 LaTeX kernel commands for general use (HO)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
kvsetkeys.sty    2010/03/01 v1.9 Key value parser (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/message (HO)
etexcmds.sty    2010/01/28 v1.3 Prefix for e-TeX command names (HO)
pdfescape.sty    2010/03/01 v1.9 Provides hex, PDF name and string
conversions 
(HO)
pdftexcmds.sty    2010/04/01 v0.9 Utility functions of pdfTeX for LuaTeX
(HO)
  ifvtex.sty    2010/03/01 v1.5 Switches for detecting VTeX and its modes
(HO)
 hycolor.sty    2009/12/12 v1.6 Color options of hyperref/bookmark (HO)
xcolor-patch.sty    2009/12/12 xcolor patch
letltxmacro.sty    2008/06/24 v1.3 Let assignment for LaTeX macros (HO)
  pd1enc.def    2010/04/15 v6.80v Hyperref: PDFDocEncoding definition (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable integer calculations (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
kvoptions.sty    2010/02/22 v3.7 Keyval support for LaTeX options (HO)
     url.sty    2006/04/12  ver 3.3  Verb mode for urls, etc.
  bitset.sty    2007/09/28 v1.0 Data type bit set (HO)
bigintcalc.sty    2007/11/11 v1.1 Expandable big integer calculations (HO)
atbegshi.sty    2010/03/25 v1.12 At begin shipout hook (HO)
memhfixc.sty    2009/02/06 v1.12 nameref/hyperref package fixes for memoir
clas
s
 hpdftex.def    2010/04/15 v6.80v Hyperref driver for pdfTeX
atveryend.sty    2010/03/24 v1.5 Hooks at very end of document (HO)
rerunfilecheck.sty    2010/03/16 v1.6 Rerun checks for auxiliary files (HO)
rerunfilecheck.cfg    2010/03/16 Default configuration
uniquecounter.sty    2009/12/18 v1.1 Provides unlimited unique counter (HO)
 nameref.sty    2010/04/15 v2.37 Cross-referencing by name of section
refcount.sty    2008/08/11 v3.1 Data extraction from references (HO)
gettitlestring.sty    2009/12/18 v1.3 Cleanup title references (HO)
    test.out
    test.out
 ***********

> Did you change something interesting Heiko, that I need to change i
> memhfixc?

The following code from memhfixc explains Victor's remark,
that adding \usepackage{nameref} works:

|  \AtBeginDocument{%
|    \@ifpackageloaded{nameref}{\let\nameref\titleref}{}%
|  }

With \usepackage{nameref} this code redefines \nameref.
Otherwise, hyperref loads nameref later using \AtBeginDocument.

In any case, this code is unhappy, because hyperref has
to define a star variant of \nameref, see Victor's other problem.

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list