summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex')
-rw-r--r--Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex47
1 files changed, 47 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex b/Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex
new file mode 100644
index 00000000000..c1efc549d07
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/glossaries/samples/sample-nomathhyper.tex
@@ -0,0 +1,47 @@
+ % 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}
+
+\makeglossaries
+
+ % switch off hyperlinks:
+\glsdisablehyper
+
+ % redefine \glsentryfmt so that it adds a hyperlink
+ % if not in math mode
+\renewcommand*{\glsentryfmt}{%
+ \ifmmode
+ \glsgenentryfmt
+ \else
+ % Temporarily enable hyperlinks:
+ \glsenablehyper
+ \glshyperlink[\glsgenentryfmt]{\glslabel}%
+ % Disable hyperlinks again
+ \glsdisablehyper
+ \fi
+}
+
+\renewcommand{\glossarypreamble}{\glsenablehyper}
+\renewcommand{\glossarypostamble}{\glsdisablehyper}
+
+ % 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}.
+
+\printglossaries
+\end{document}