summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/glossaries/samples/glossary-lipsum-examples.tex
blob: c8fa373feb8509d42e8f9e9154e87e03d747c87c (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 % arara: pdflatex
 % arara: makeglossaries
 % arara: pdflatex
 % arara: bibtex
 % arara: pdflatex
 % arara: pdflatex
\documentclass{report}

\usepackage{graphicx}

\usepackage[colorlinks]{hyperref}
\usepackage[savewrites,nopostdot,toc,acronym,symbols]{glossaries}
\usepackage{glossary-mcols}
\usepackage{glossary-longragged}

\newglossary*{symbolname}{Entries with Symbols in the Name}
\newglossary*{long}{Long Descriptions}
\newglossary*{multipar}{Multi-Paragraph Descriptions}
\newglossary*{acronymdesc}{Acronyms with Descriptions}
\newglossary*{images}{Descriptions with Images}
\newglossary*{acronymslang}{Acronyms with Translations}

\newglossary*{parent}{Hierarchical Entries}
\newglossary*{homographs}{Homographs}
\newglossary*{cites}{Entries with Citations}
\newglossary*{urls}{Entries with URLs}

\DeclareAcronymList{acronymdesc,acronymslang}

\makeglossaries

\loadglsentries{example-glossaries-brief}
\loadglsentries[long]{example-glossaries-long}
\loadglsentries[multipar]{example-glossaries-multipar}
\loadglsentries[symbols]{example-glossaries-symbols}
\loadglsentries[symbolname]{example-glossaries-symbolnames}
\loadglsentries[images]{example-glossaries-images}
\loadglsentries[parent]{example-glossaries-parent}
\loadglsentries[homographs]{example-glossaries-childnoname}
\loadglsentries[cites]{example-glossaries-cite}
\loadglsentries[urls]{example-glossaries-url}

\setacronymstyle{long-short}

\loadglsentries[acronym]{example-glossaries-acronym}

\setacronymstyle{long-short-desc}

\loadglsentries[acronymdesc]{example-glossaries-acronym-desc}

 % define an acronym style for the acronyms with a translation:

\newacronymstyle{acronymslang}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}
{%
  \GlsUseAcrStyleDefs{short-long}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glsentrylong{##1}##2\space
   (\protect\firstacronymfont{\glsentryshort{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \Glsentrylong{##1}##2\space
   (\protect\firstacronymfont{\glsentryshort{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsentrylongpl{##1}##2\space
   (\protect\firstacronymfont{\glsentryshortpl{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \Glsentrylongpl{##1}##2\space
   (\protect\firstacronymfont{\glsentryshortpl{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
}

\setacronymstyle{acronymslang}

\loadglsentries[acronymslang]{example-glossaries-acronyms-lang}

 % Define a style for the "images" glossary. The image names are
 % stored in the user1 key.
 % (The image insertion can probably be done more neatly using an
 % appropriate package, but this is just a sample file.)

\newsavebox\glsimagebox
\newlength\glswidth

\newglossarystyle{images}%
{%
  \setglossarystyle{tree}%
  \renewenvironment{theglossary}{}{}%
  \renewcommand{\glossentry}[2]{%
    \ifglshasfield{useri}{##1}%
    {\savebox
      {\glsimagebox}%
      {\includegraphics[height=4\baselineskip]{\glsentryuseri{##1}}}%
      \settowidth{\glswidth}{\usebox\glsimagebox}%
      \glswidth=\dimexpr\linewidth-\glswidth-1em\relax
      \parshape=5
        0pt \glswidth
        0pt \glswidth
        0pt \glswidth
        0pt \glswidth
        0pt \linewidth\relax
    }%
    {%
      \savebox{\glsimagebox}{}%
    }%
    \noindent
    \makebox[0pt][l]{%
     \smash{\makebox[\linewidth][r]{\raisebox{-3\baselineskip}{\usebox\glsimagebox}}}}%
    \glsentryitem{##1}\textbf{\glstarget{##1}{\glossentryname{##1}}}%
    \space\glossentrydesc{##1}\par
    \indexspace
  }%
  \renewcommand*{\glsgroupskip}{}%
}

 % glossary style for acronyms with a translation

\newglossarystyle{acronymslang}
{%
  \setglossarystyle{long}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription
    \ifglshasfield{useri}{##1}{ (English: \glsentryuseri{##1})}{}%
    \space ##2\tabularnewline
  }%
}

 % glossary style for the cites glossary

\newglossarystyle{cites}
{% based on list style
  \setglossarystyle{list}%
    \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
       \glossentrydesc{##1}\glspostdescription
    \ifglshasfield{useri}{##1}{\space
     % in the event of multiple cites (as in the vestibulum2
     % sample entry), \glsentryuseri{##1} needs to be expanded
     % before being passed to \cite.
     \glsletentryfield{\thiscite}{##1}{useri}%
     (See \expandafter\cite\expandafter{\thiscite})}{}%
    \space ##2}%
}

 % glossary style for the urls glossary

\newglossarystyle{urls}
{% based on list style
  \setglossarystyle{list}%
    \renewcommand{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
       \glossentrydesc{##1}\glspostdescription\space##2%
    \ifglshasfield{useri}{##1}{\glspar
     \glsletentryfield{\thisurl}{##1}{useri}%
     \expandafter\url\expandafter{\thisurl}}{}}%
}

\begin{document}
\tableofcontents

\chapter{Sample}

This is a sample document that uses the dummy glossary entries
supplied with the glossaries bundle for testing.

Here are all the entries (including acronyms):

\forallglossaries{\thistype}{\section{Glossary `\thistype'}
\forglsentries[\thistype]{\thislabel}{\gls{\thislabel}. }}

\section{Acronyms Revisited}

Here are just the acronyms again:
\forallacronyms{\thistype}{\forglsentries[\thistype]{\thislabel}{\gls{\thislabel}. }}

\printglossary[style=mcolindex,title={Brief Descriptions}]

\printglossary[type=long,style=list]

\printglossary[type=multipar,style=altlist]

\printglossary[type=symbols,style=altlongragged4col,nogroupskip]

\printglossary[type=symbolname,style=list,nogroupskip]

\printglossary[type=acronym,style=long]

\printglossary[type=acronymdesc,style=altlist]

\printglossary[type=images,style=images]

\printglossary[type=acronymslang,style=acronymslang]

\printglossary[type=homographs,style=mcoltreenoname,subentrycounter]

\printglossary[type=parent,style=tree]

\printglossary[type=cites,style=cites,nopostdot=false,nogroupskip]

\printglossary[type=urls,style=urls,nopostdot=false,nogroupskip]

\bibliographystyle{plain}
\bibliography{xampl}

\end{document}