It seems like a simple question, but I cannot find the solution. In the body of the book the same name, say John Smith is mentioned a number of times. I would like to label this name with \label{Smith} across entire book, so I can write in the prefatory note to the book something like "In this autobiography, the name of Dr. Smith is mentioned on pages xyz \pageref{Smith}" (something similar to what \makeindex generates). Obviously, when I try to use same label more than once, I get an error. Is there a specific package to create a list of pages that I am looking for? I would appreciate if someone can stir me in the right direction.
\documentclass[a4paper,12pt]{extreport}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setmainfont{CMU Serif}
\begin{document}
The word to the reader:
"In this autobiography, the name of Dr. Smith is mentioned on pages xyz `\pageref{Smith}`"
\newpage
Bla... John Smith\label{Smith}
\newpage
Bla... John\label{Smith}
\newpage
Ba...Dr. J. Smith\label{Smith}
\end{document}
usepackage[pagebackref]{hyperref}might help. And maybe set the label once (the name of Dr. Smith\label{Smith} is...) and replace your\labels by\refs. – bers Apr 28 '19 at 06:05\indexas if to get an index of names and then give yourself a macro to access a single item from the index. That way multiple entries on the same page, or ranges of consecutive page numbers can all be handled gracefully. – David Carlisle Apr 28 '19 at 06:52