1

We are making a book, where each chapter is included and compiled together in a single master .tex file. We also compile each chapter separately to make a single .pdf for each chapter, and we can easily make a reference to another chapter using the xr-hyper package (the e.g. section number becomes then a hyperlink, and when pressed the master .pdf opens on the right page).

Now, we would like to do the same with the glossaries, such that when an entry is marked e.g. \gls{<entry label>} then when clicked the master .pdf opens at the entry in the glossary of the main .pdf document.

Further, also a version which points to an url of the master .pdf, would be great (like achieved with xr-hyper by \externaldocument{master}[<url>].

I can't find out how to do this. Is it possible and how?

1
  • If Nicola Talbot's answer is a solution to your problem consider to accept it, please
    – user31729
    Commented Feb 5, 2017 at 14:08

1 Answer 1

1

It would help to have a minimal working example (MWE) but assuming a master file called master.tex that looks like:

\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries

\loadglsentries{example-glossaries-brief}

\begin{document}

\gls{lorem}.

\printglossaries

\end{document}

This is compiled in the usual manner:

pdflatex master
makeglossaries master
pdflatex master

Now a child document:

\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\loadglsentries{example-glossaries-brief}

\renewcommand*{\glsdohyperlink}[2]{%
 \hyperref{master.pdf}{}{#1}{#2}%
}

\glsenablehyper

\begin{document}
\gls{lorem}.

\end{document}

Assuming this file is called child.tex then the build process for this file is:

pdflatex child
pdflatex child

This will break if you need an internal glossary as well. If you need a mixture of internal and external links, then the simplest method is to use the extension package glossaries-extra at least v1.11 (2017-01-19):

\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}[2017/01/19]

\newignoredglossary*{external}

\makeglossaries

\loadglsentries[external]{example-glossaries-brief}

\newglossaryentry{sample}{name=sample,category=internal,
 description={an example}
}

\glssetcategoryattribute{general}{targeturl}{master.pdf}
\glssetcategoryattribute{general}{targetname}{\glolinkprefix\glslabel}


\begin{document}
\gls{lorem}, \gls{sample}.

\printglossaries

\end{document}

The build process is now:

pdflatex child
makeglossaries child
pdflatex child

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .