| 1 |
% arara: pdflatex |
| 2 |
% arara: makeglossaries |
| 3 |
% arara: pdflatex |
| 4 |
% arara: bibtex |
| 5 |
% arara: pdflatex |
| 6 |
% arara: pdflatex |
| 7 |
\documentclass{report} |
| 8 |
|
| 9 |
\usepackage{graphicx} |
| 10 |
|
| 11 |
\usepackage[colorlinks]{hyperref} |
| 12 |
\usepackage[savewrites,nopostdot,toc,acronym,symbols]{glossaries} |
| 13 |
\usepackage{glossary-mcols} |
| 14 |
\usepackage{glossary-longragged} |
| 15 |
|
| 16 |
\newglossary*{symbolname}{Entries with Symbols in the Name} |
| 17 |
\newglossary*{long}{Long Descriptions} |
| 18 |
\newglossary*{multipar}{Multi-Paragraph Descriptions} |
| 19 |
\newglossary*{acronymdesc}{Acronyms with Descriptions} |
| 20 |
\newglossary*{images}{Descriptions with Images} |
| 21 |
\newglossary*{acronymslang}{Acronyms with Translations} |
| 22 |
|
| 23 |
\newglossary*{parent}{Hierarchical Entries} |
| 24 |
\newglossary*{homographs}{Homographs} |
| 25 |
\newglossary*{cites}{Entries with Citations} |
| 26 |
\newglossary*{urls}{Entries with URLs} |
| 27 |
\newglossary*{constants}{Entries with Varying Width Symbols} |
| 28 |
|
| 29 |
\DeclareAcronymList{acronymdesc,acronymslang} |
| 30 |
|
| 31 |
\makeglossaries |
| 32 |
|
| 33 |
\loadglsentries{example-glossaries-brief} |
| 34 |
\loadglsentries[long]{example-glossaries-long} |
| 35 |
\loadglsentries[multipar]{example-glossaries-multipar} |
| 36 |
\loadglsentries[symbols]{example-glossaries-symbols} |
| 37 |
\loadglsentries[symbolname]{example-glossaries-symbolnames} |
| 38 |
\loadglsentries[images]{example-glossaries-images} |
| 39 |
\loadglsentries[parent]{example-glossaries-parent} |
| 40 |
\loadglsentries[homographs]{example-glossaries-childnoname} |
| 41 |
\loadglsentries[cites]{example-glossaries-cite} |
| 42 |
\loadglsentries[urls]{example-glossaries-url} |
| 43 |
\loadglsentries[constants]{example-glossaries-constants} |
| 44 |
|
| 45 |
\setacronymstyle{long-short} |
| 46 |
|
| 47 |
\loadglsentries[acronym]{example-glossaries-acronym} |
| 48 |
|
| 49 |
\setacronymstyle{long-short-desc} |
| 50 |
|
| 51 |
\loadglsentries[acronymdesc]{example-glossaries-acronym-desc} |
| 52 |
|
| 53 |
% define an acronym style for the acronyms with a translation: |
| 54 |
|
| 55 |
\newacronymstyle{acronymslang}% |
| 56 |
{% |
| 57 |
\GlsUseAcrEntryDispStyle{long-short}% |
| 58 |
} |
| 59 |
{% |
| 60 |
\GlsUseAcrStyleDefs{short-long}% |
| 61 |
\renewcommand*{\genacrfullformat}[2]{% |
| 62 |
\glsentrylong{##1}##2\space |
| 63 |
(\protect\firstacronymfont{\glsentryshort{##1}}% |
| 64 |
\ifglshasfield{useri}{##1}% |
| 65 |
{, English: \glsentryuseri{##1}}{})% |
| 66 |
}% |
| 67 |
\renewcommand*{\Genacrfullformat}[2]{% |
| 68 |
\Glsentrylong{##1}##2\space |
| 69 |
(\protect\firstacronymfont{\glsentryshort{##1}}% |
| 70 |
\ifglshasfield{useri}{##1}% |
| 71 |
{, English: \glsentryuseri{##1}}{})% |
| 72 |
}% |
| 73 |
\renewcommand*{\genplacrfullformat}[2]{% |
| 74 |
\glsentrylongpl{##1}##2\space |
| 75 |
(\protect\firstacronymfont{\glsentryshortpl{##1}}% |
| 76 |
\ifglshasfield{useri}{##1}% |
| 77 |
{, English: \glsentryuseri{##1}}{})% |
| 78 |
}% |
| 79 |
\renewcommand*{\Genplacrfullformat}[2]{% |
| 80 |
\Glsentrylongpl{##1}##2\space |
| 81 |
(\protect\firstacronymfont{\glsentryshortpl{##1}}% |
| 82 |
\ifglshasfield{useri}{##1}% |
| 83 |
{, English: \glsentryuseri{##1}}{})% |
| 84 |
}% |
| 85 |
} |
| 86 |
|
| 87 |
\setacronymstyle{acronymslang} |
| 88 |
|
| 89 |
\loadglsentries[acronymslang]{example-glossaries-acronyms-lang} |
| 90 |
|
| 91 |
% Define a style for the "images" glossary. The image names are |
| 92 |
% stored in the user1 key. |
| 93 |
% (The image insertion can probably be done more neatly using an |
| 94 |
% appropriate package, but this is just a sample file.) |
| 95 |
|
| 96 |
\newsavebox\glsimagebox |
| 97 |
\newlength\glswidth |
| 98 |
|
| 99 |
\newglossarystyle{images}% |
| 100 |
{% |
| 101 |
\setglossarystyle{tree}% |
| 102 |
\renewenvironment{theglossary}{}{}% |
| 103 |
\renewcommand{\glossentry}[2]{% |
| 104 |
\ifglshasfield{useri}{##1}% |
| 105 |
{\savebox |
| 106 |
{\glsimagebox}% |
| 107 |
{\includegraphics[height=4\baselineskip]{\glsentryuseri{##1}}}% |
| 108 |
\settowidth{\glswidth}{\usebox\glsimagebox}% |
| 109 |
\glswidth=\dimexpr\linewidth-\glswidth-1em\relax |
| 110 |
\parshape=5 |
| 111 |
0pt \glswidth |
| 112 |
0pt \glswidth |
| 113 |
0pt \glswidth |
| 114 |
0pt \glswidth |
| 115 |
0pt \linewidth\relax |
| 116 |
}% |
| 117 |
{% |
| 118 |
\savebox{\glsimagebox}{}% |
| 119 |
}% |
| 120 |
\noindent |
| 121 |
\makebox[0pt][l]{% |
| 122 |
\smash{\makebox[\linewidth][r]{\raisebox{-3\baselineskip}{\usebox\glsimagebox}}}}% |
| 123 |
\glsentryitem{##1}\textbf{\glstarget{##1}{\glossentryname{##1}}}% |
| 124 |
\space\glossentrydesc{##1}\par |
| 125 |
\indexspace |
| 126 |
}% |
| 127 |
\renewcommand*{\glsgroupskip}{}% |
| 128 |
} |
| 129 |
|
| 130 |
% glossary style for acronyms with a translation |
| 131 |
|
| 132 |
\newglossarystyle{acronymslang} |
| 133 |
{% |
| 134 |
\setglossarystyle{long}% |
| 135 |
\renewcommand*{\glsgroupskip}{}% |
| 136 |
\renewcommand{\glossentry}[2]{% |
| 137 |
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & |
| 138 |
\glossentrydesc{##1}\glspostdescription |
| 139 |
\ifglshasfield{useri}{##1}{ (English: \glsentryuseri{##1})}{}% |
| 140 |
\space ##2\tabularnewline |
| 141 |
}% |
| 142 |
} |
| 143 |
|
| 144 |
% glossary style for the cites glossary |
| 145 |
|
| 146 |
\newglossarystyle{cites} |
| 147 |
{% based on list style |
| 148 |
\setglossarystyle{list}% |
| 149 |
\renewcommand*{\glossentry}[2]{% |
| 150 |
\item[\glsentryitem{##1}% |
| 151 |
\glstarget{##1}{\glossentryname{##1}}] |
| 152 |
\glossentrydesc{##1}\glspostdescription |
| 153 |
\ifglshasfield{useri}{##1}{\space |
| 154 |
% in the event of multiple cites (as in the vestibulum2 |
| 155 |
% sample entry), \glsentryuseri{##1} needs to be expanded |
| 156 |
% before being passed to \cite. |
| 157 |
\glsletentryfield{\thiscite}{##1}{useri}% |
| 158 |
(See \expandafter\cite\expandafter{\thiscite})}{}% |
| 159 |
\space ##2}% |
| 160 |
} |
| 161 |
|
| 162 |
% glossary style for the urls glossary |
| 163 |
|
| 164 |
\newglossarystyle{urls} |
| 165 |
{% based on list style |
| 166 |
\setglossarystyle{list}% |
| 167 |
\renewcommand{\glossentry}[2]{% |
| 168 |
\item[\glsentryitem{##1}% |
| 169 |
\glstarget{##1}{\glossentryname{##1}}] |
| 170 |
\glossentrydesc{##1}\glspostdescription\space##2% |
| 171 |
\ifglshasfield{useri}{##1}{\glspar |
| 172 |
\glsletentryfield{\thisurl}{##1}{useri}% |
| 173 |
\expandafter\url\expandafter{\thisurl}}{}}% |
| 174 |
} |
| 175 |
|
| 176 |
\begin{document} |
| 177 |
\tableofcontents |
| 178 |
|
| 179 |
\chapter{Sample} |
| 180 |
|
| 181 |
This is a sample document that uses the dummy glossary entries |
| 182 |
supplied with the glossaries bundle for testing. |
| 183 |
|
| 184 |
Here are all the entries (including acronyms): |
| 185 |
|
| 186 |
\forallglossaries{\thistype}{\section{Glossary `\thistype'} |
| 187 |
\forglsentries[\thistype]{\thislabel}{\gls{\thislabel}. }} |
| 188 |
|
| 189 |
\section{Acronyms Revisited} |
| 190 |
|
| 191 |
Here are just the acronyms again: |
| 192 |
\forallacronyms{\thistype}{\forglsentries[\thistype]{\thislabel}{\gls{\thislabel}. }} |
| 193 |
|
| 194 |
\printglossary[style=mcolindex,title={Brief Descriptions}] |
| 195 |
|
| 196 |
\printglossary[type=long,style=list] |
| 197 |
|
| 198 |
\printglossary[type=multipar,style=altlist] |
| 199 |
|
| 200 |
\printglossary[type=symbols,style=altlongragged4col,nogroupskip] |
| 201 |
|
| 202 |
\printglossary[type=symbolname,style=list,nogroupskip] |
| 203 |
|
| 204 |
\printglossary[type=constants,style=tree*,nogroupskip] |
| 205 |
|
| 206 |
\printglossary[type=acronym,style=long] |
| 207 |
|
| 208 |
\printglossary[type=acronymdesc,style=altlist] |
| 209 |
|
| 210 |
\printglossary[type=images,style=images] |
| 211 |
|
| 212 |
\printglossary[type=acronymslang,style=acronymslang] |
| 213 |
|
| 214 |
\printglossary[type=homographs,style=mcoltreenoname,subentrycounter] |
| 215 |
|
| 216 |
\printglossary[type=parent,style=tree] |
| 217 |
|
| 218 |
\printglossary[type=cites,style=cites,nopostdot=false,nogroupskip] |
| 219 |
|
| 220 |
\printglossary[type=urls,style=urls,nopostdot=false,nogroupskip] |
| 221 |
|
| 222 |
\bibliographystyle{plain} |
| 223 |
\bibliography{xampl} |
| 224 |
|
| 225 |
\end{document} |