summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/samples/sample-custom-acronym.tex
blob: a0de228a23fa3abbc35c542804547549b5e385c5 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 % This file is public domain
\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 \glsentryshort{\glslabel}
  % The plural short form can be obtained via
  % \glsentryshortplural{\glslabel}
  % The long form can be obtained via \glsentrylong{\glslabel}
  % The plural long form can be obtained via
  % \glsentrylongplural{\glslabel}
  \defglsdisplayfirst[#1]{##1##4\protect\footnote{%
    \glsentrylong{\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}