0

I would like to know if there is a way to make the page references in the nomenclature point to the exact place where the \nomenclature command has been given (e.g. by assigning a label as discussed here).

More precisely, what I would like is an analogue of these patches to backref for nomenclature. I know that there is the nomeqref command from nomenclature, but sometimes I introduce notations without having any equation (but possibly within a definition -- this could be an idea for having a precise place to refer to).

Minimal (not really working) example:

\documentclass[11pt, a4paper]{article}
\usepackage[refpage]{nomencl}
\usepackage[pageanchor, backref=page, colorlinks=true]{hyperref}
\def\pagedeclaration#1{, \hyperlink{nomencl.#1}{page\nobreakspace#1}} % from https://tex.stackexchange.com/questions/197166
\makenomenclature

\begin{document} . \hypertarget{nomencl.1} $x$ \nomenclature[1(X)]{$X^0$}{my x} \vspace{10cm}

, \hypertarget{nomencl.2} $L$ \nomenclature[1(L)]{$L^0$}{my l} \newpage

s \hypertarget{nomencl.3} t $v$ \nomenclature[1(V)]{$V^0$}{my v} \vspace{10cm}

... \hypertarget{nomencl.4} $b$ \nomenclature[1(B)]{$B^0$}{my b} \newpage

\printnomenclature[2cm] \end{document}

For instance, I want the "page 2" of the B^0 item in the nomenclature to point out to the B^0 instead of just the top of page 2.

Thanks in advance for any suggestion.

Watson
  • 890

1 Answers1

0

Ok, I found a way which seems to work, based on How to add page numbering in nomenclature to link to an arbitrary page with a "label"?

\documentclass{article}
\usepackage[refpage]{nomencl}

\makeatletter \def\nomlabelref#1{ , \hyperlink{#1}{page\nobreakspace \pageref{#1}}\nomentryend\endgroup} \def@@@nomenclature[#1]#2#3#4{% {}\hypertarget{#4} %the {} is important! {}\phantomsection\label{#4}%https://tex.stackexchange.com/questions/193380 \def@tempa{#2}\def@tempb{#3}\def@tempc{#4}% \protected@write@nomenclaturefile{}% {\string\nomenclatureentry{#1\nom@verb@tempa @[{\nom@verb@tempa}]% \begingroup\nom@verb@tempb\protect\nomeqref{\theequation}% |nomlabelref}{@tempc}}% \endgroup @esphack} \makeatother

\usepackage[backref=page,pageanchor, colorlinks=true]{hyperref} \makenomenclature

\begin{document}

$x$ \nomenclature[1\(X\)]{$X^0$}{my x}{nomenc:X}
\vspace{10cm}

See \hyperlink{nomenc:B}{here} the definition of $B^0$, on page \pageref{nomenc:B}.\\
$L$     \nomenclature[1\(L\)]{$L^0$}{my l}{nomenc:L}
\newpage


$v$  \nomenclature[1\(V\)]{$V^0$}{my v}{nomenc:V}
\vspace{10cm}

$b$ \nomenclature[1\(B\)]{$B^0$}{my b}{nomenc:B}
\newpage

\printnomenclature \end{document}

Watson
  • 890
  • It could happen that, in combination with other packages, using some symbols as the label/hypertarget doesn not work, e.g. nomencl:B (using \def\nomlabelref#1{ , #1 \hyperlink{#1}{page\nobreakspace \pageref{#1}}\nomentryend\endgroup} will print "nomencl: B" with a space, whence the issue). Instead, just use e.g. nomenclB. – Watson Mar 10 '21 at 11:56
  • NB: using nomenclature needs to run makeindex with makeindex %.nlo -s nomencl.ist -o %.nls -t %.nlg in the commands of MakeIndex, see http://www.xm1math.net/doculatex/nomenclature.html for TexMaker. – Watson Mar 10 '21 at 14:20