summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex
blob: 16cc511eee7fddae8163198169927ef9cb0c99a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{report}

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

\GlsDeclareNoHyperList{main}

\makeglossaries

 % redefine \glsentryfmt so that it adds a hyperlink
 % if not in math mode and the hyperlinks haven't been forced on
\renewcommand*{\glsentryfmt}{%
  \ifmmode
    \glsgenentryfmt
  \else
    \glsifhyperon
    {\glsgenentryfmt}% hyperlink already on
    {\glshyperlink[\glsgenentryfmt]{\glslabel}}%
  \fi
}

 % define a sample entry:
\newglossaryentry{x}{name={x},description={sample entry}}

\begin{document}
\chapter{Sample}
In text mode: \gls{x}. Inline maths: $\gls{x}$. Displayed
maths:
\[
  \gls{x}
\]

Back to text mode again: \gls{x}. Don't check the first use flag:
\glstext{x}. Force on the hyperlink: \glstext+{x}.

\printglossaries
\end{document}