summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex')
-rw-r--r--Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex74
1 files changed, 74 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex b/Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex
new file mode 100644
index 00000000000..bd63d817500
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex
@@ -0,0 +1,74 @@
+\documentclass{report}
+
+\usepackage[colorlinks]{hyperref}
+\usepackage[acronym, % create list of acronyms
+ nomain, % don't need main glossary for this example
+ style=tree, % need a style that displays the symbol
+ hyperfirst=false,% don't hyperlink first use
+ sanitize=none % switch off sanitization as description
+ % will be used in the main text
+ ]{glossaries}
+
+\makeglossaries
+
+ % This is a sample file to illustrate how to define a custom
+ % acronym. This example defines the acronym so that on first use
+ % it displays the short form in the text and places the long form
+ % and its description in a footnote. In the main body of the
+ % document the short form will be displayed in small caps, but in
+ % the list of acronyms the short form is displayed in normal
+ % capitals. To ensure this, the short form should be written in
+ % lower case when the acronym is defined, and \MakeUppercase is
+ % used when it's displayed in the list of acronyms.
+
+ % In the list of acronyms, the long form is used as the name, the
+ % short form is used as the symbol and the user supplies the
+ % description when defining the acronym.
+
+\renewcommand*{\CustomAcronymFields}{%
+ name={\the\glslongtok},%
+ symbol={\MakeUppercase{\the\glsshorttok}},%
+ text={\textsc{\the\glsshorttok}},%
+ plural={\textsc{\the\glsshorttok}\noexpand\acrpluralsuffix}%
+}
+
+\renewcommand*{\SetCustomDisplayStyle}[1]{%
+ % ##1 corresponds to the 'first' key
+ % ##2 corresponds to the 'description' key
+ % ##3 corresponds to the 'symbol' key
+ % ##4 is the inserted text given by the final optional argument to
+ % commands like \gls
+ % The short form can be obtained via \glsentryuseri{\glslabel}
+ % The plural short form can be obtained via
+ % \glsentryuserii{\glslabel}
+ % The long form can be obtained via \glsentryuseriii{\glslabel}
+ % The plural long form can be obtained via
+ % \glsentryuseriv{\glslabel}
+ \defglsdisplayfirst[#1]{##1##4\protect\footnote{%
+ \glsentryuseriii{\glslabel}: ##2}}%
+ % ##1 corresponds to the 'text' key
+ % the rest as above
+ \defglsdisplay[#1]{##1##4}%
+}
+
+ % Now set the custom acronym style (to override the default style)
+\SetCustomStyle
+
+ % Now define the acronyms (must be done after setting the custom
+ % style)
+
+\newacronym[description={set of tags for use in developing hypertext
+documents}]{html}{html}{Hyper Text Markup Language}
+
+\newacronym[description={language used to describe the layout of a
+document written in a markup language}]{css}{css}{Cascading Style
+Sheet}
+
+\begin{document}
+
+\gls{css}. \gls{html}.
+
+\gls{css}. \gls{html}.
+
+\printglossaries
+\end{document}