| 1 |
% This file is public domain |
| 2 |
% If you want to use arara, you need the following directives: |
| 3 |
% arara: pdflatex: { synctex: on } |
| 4 |
% arara: makeglossaries |
| 5 |
% arara: pdflatex: { synctex: on } |
| 6 |
% |
| 7 |
%http://mirrors.ctan.org/macros/latex/contrib/glossaries/glossaries-user.html#sample-nomathhyper |
| 8 |
\documentclass{report} |
| 9 |
|
| 10 |
\usepackage[colorlinks]{hyperref} |
| 11 |
\usepackage{glossaries} |
| 12 |
|
| 13 |
\GlsDeclareNoHyperList{main} |
| 14 |
|
| 15 |
\makeglossaries |
| 16 |
|
| 17 |
% redefine \glsentryfmt so that it adds a hyperlink |
| 18 |
% if not in math mode and the hyperlinks haven't been forced on |
| 19 |
\renewcommand*{\glsentryfmt}{% |
| 20 |
\ifmmode |
| 21 |
\glsgenentryfmt |
| 22 |
\else |
| 23 |
\glsifhyperon |
| 24 |
{\glsgenentryfmt}% hyperlink already on |
| 25 |
{\glshyperlink[\glsgenentryfmt]{\glslabel}}% |
| 26 |
\fi |
| 27 |
} |
| 28 |
|
| 29 |
% define a sample entry: |
| 30 |
\newglossaryentry{x}{name={x},description={sample entry}} |
| 31 |
|
| 32 |
\begin{document} |
| 33 |
\chapter{Sample} |
| 34 |
In text mode: \gls{x}. Inline maths: $\gls{x}$. Displayed |
| 35 |
maths: |
| 36 |
\[ |
| 37 |
\gls{x} |
| 38 |
\] |
| 39 |
|
| 40 |
Back to text mode again: \gls{x}. Don't check the first use flag: |
| 41 |
\glstext{x}. Force on the hyperlink: \glstext+{x}. |
| 42 |
|
| 43 |
\printglossaries |
| 44 |
\end{document} |