| 1 |
% This file is public domain |
| 2 |
% If you want to use arara, you need the following directives: |
| 3 |
% arara: pdflatex: { synctex: on } |
| 4 |
% arara: makeglossaries |
| 5 |
% arara: pdflatex: { synctex: on } |
| 6 |
% |
| 7 |
%http://mirrors.ctan.org/macros/latex/contrib/glossaries/glossaries-user.html#sample-custom-acronym |
| 8 |
\documentclass{report} |
| 9 |
|
| 10 |
\usepackage[colorlinks]{hyperref} |
| 11 |
\usepackage[acronym,% create list of acronyms |
| 12 |
% The package option "nomain" is used here to suppress the |
| 13 |
% main glossary, since this example doesn't use it. If you |
| 14 |
% want to use the main glossary, remove the "nomain" option. |
| 15 |
nomain |
| 16 |
]{glossaries} |
| 17 |
|
| 18 |
\makeglossaries |
| 19 |
|
| 20 |
% This is a sample file to illustrate how to define a custom |
| 21 |
% acronym style. This example defines the acronyms so that on first use |
| 22 |
% they display the short form in the text and with the long form |
| 23 |
% and description in a footnote. In the main body of the |
| 24 |
% document the short form will be displayed in small caps, but in |
| 25 |
% the list of acronyms the short form is displayed in normal |
| 26 |
% capitals. To ensure this, the short form should be written in |
| 27 |
% lower case when the acronym is defined, and \mfirstucMakeUppercase is |
| 28 |
% used when it's displayed in the list of acronyms. |
| 29 |
% |
| 30 |
% Note that if glossaries.sty v4.50+ detects mfirstuc.sty 2.08+ |
| 31 |
% the textcase package will no longer be loaded so use |
| 32 |
% \mfirstucMakeUppercase for uppercase. |
| 33 |
|
| 34 |
\newacronymstyle{custom-fn}% new style name |
| 35 |
{% Check for long form in case of a mixed glossary |
| 36 |
\ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}% |
| 37 |
}% |
| 38 |
{% Style definitions: |
| 39 |
% User needs to supply the description: |
| 40 |
\renewcommand*{\GenericAcronymFields}{}% |
| 41 |
% Need to ensure hyperlinks are switched off on first use: |
| 42 |
\glshyperfirstfalse |
| 43 |
% Redefine the commands used by \glsgenacfmt on first use: |
| 44 |
\renewcommand*{\genacrfullformat}[2]{% |
| 45 |
\firstacronymfont{\glsentryshort{##1}}##2% |
| 46 |
\footnote{\glsentrylong{##1}: \glsentrydesc{##1}}% |
| 47 |
}% |
| 48 |
\renewcommand*{\Genacrfullformat}[2]{% |
| 49 |
\firstacronymfont{\Glsentryshort{##1}}##2% |
| 50 |
\footnote{\glsentrylong{##1}: \glsentrydesc{##1}}% |
| 51 |
}% |
| 52 |
\renewcommand*{\genplacrfullformat}[2]{% |
| 53 |
\firstacronymfont{\glsentryshortpl{##1}}##2% |
| 54 |
\footnote{\glsentrylongpl{##1}: \glsentrydesc{##1}}% |
| 55 |
}% |
| 56 |
\renewcommand*{\Genplacrfullformat}[2]{% |
| 57 |
\firstacronymfont{\Glsentryshortpl{##1}}##2% |
| 58 |
\footnote{\glsentrylongpl{##1}: \glsentrydesc{##1}}% |
| 59 |
}% |
| 60 |
% Redefine the no-link full forms: |
| 61 |
\renewcommand*{\glsentryfull}[1]{% |
| 62 |
\glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})% |
| 63 |
}% |
| 64 |
\renewcommand*{\Glsentryfull}[1]{% |
| 65 |
\Glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})% |
| 66 |
}% |
| 67 |
\renewcommand*{\glsentryfullpl}[1]{% |
| 68 |
\glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})% |
| 69 |
}% |
| 70 |
\renewcommand*{\Glsentryfullpl}[1]{% |
| 71 |
\Glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})% |
| 72 |
}% |
| 73 |
% Redefine the link full forms: |
| 74 |
\renewcommand*{\acrfullfmt}[3]{% |
| 75 |
\glslink[##1]{##2}{% |
| 76 |
\glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})% |
| 77 |
}% |
| 78 |
}% |
| 79 |
\renewcommand*{\Acrfullfmt}[3]{% |
| 80 |
\glslink[##1]{##2}{% |
| 81 |
\Glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})% |
| 82 |
}% |
| 83 |
}% |
| 84 |
\renewcommand*{\ACRfullfmt}[3]{% |
| 85 |
\glslink[##1]{##2}{% |
| 86 |
\mfirstucMakeUppercase{% |
| 87 |
\glsentrylong{##2}##3\space |
| 88 |
(\acronymfont{\glsentryshort{##2}})% |
| 89 |
}% |
| 90 |
}% |
| 91 |
}% |
| 92 |
\renewcommand*{\acrfullplfmt}[3]{% |
| 93 |
\glslink[##1]{##2}{% |
| 94 |
\glsentrylongpl{##2}##3\space |
| 95 |
(\acronymfont{\glsentryshortpl{##2}})% |
| 96 |
}% |
| 97 |
}% |
| 98 |
\renewcommand*{\Acrfullplfmt}[3]{% |
| 99 |
\glslink[##1]{##2}{% |
| 100 |
\Glsentrylongpl{##2}##3\space |
| 101 |
(\acronymfont{\glsentryshortpl{##2}})% |
| 102 |
}% |
| 103 |
}% |
| 104 |
\renewcommand*{\ACRfullplfmt}[3]{% |
| 105 |
\glslink[##1]{##2}{% |
| 106 |
\mfirstucMakeUppercase{% |
| 107 |
\glsentrylongpl{##2}##3\space |
| 108 |
(\acronymfont{\glsentryshortpl{##2}})% |
| 109 |
}% |
| 110 |
}% |
| 111 |
}% |
| 112 |
% Use smallcaps for the acronym in the document text: |
| 113 |
\renewcommand*{\acronymfont}[1]{\textsc{##1}}% |
| 114 |
\renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}% |
| 115 |
% Sort acronyms according to the long form: |
| 116 |
\renewcommand*{\acronymsort}[2]{##2}% |
| 117 |
% Set the name in the list of acronyms to the long form followed by |
| 118 |
% the short form (in upper case) in parentheses: |
| 119 |
\renewcommand*{\acronymentry}[1]{% |
| 120 |
\Glsentrylong{##1}\space(\mfirstucMakeUppercase{\glsentryshort{##1}})}% |
| 121 |
} |
| 122 |
|
| 123 |
% Now set the new acronym style (to override the default style) |
| 124 |
\setacronymstyle{custom-fn} |
| 125 |
|
| 126 |
% Set an appropriate glossary style: |
| 127 |
\setglossarystyle{altlist} |
| 128 |
|
| 129 |
% Now define the acronyms (must be done after setting the custom |
| 130 |
% style) |
| 131 |
|
| 132 |
\newacronym[description={set of tags for use in developing hypertext |
| 133 |
documents}]{html}{html}{hyper text markup language} |
| 134 |
|
| 135 |
\newacronym[description={language used to describe the layout of a |
| 136 |
document written in a markup language}]{css}{css}{cascading style |
| 137 |
sheet} |
| 138 |
|
| 139 |
\begin{document} |
| 140 |
|
| 141 |
\gls{css}. \gls{html}. |
| 142 |
|
| 143 |
\gls{css}. \gls{html}. |
| 144 |
|
| 145 |
No-link full forms: \glsentryfull{css}, \Glsentryfull{css}. |
| 146 |
Linking full forms: \acrfull{css}, \Acrfull{css}, \ACRfull{css}. |
| 147 |
Linking with insert: \acrfull{css}['s], \Acrfull{css}['s], |
| 148 |
\ACRfull{css}['s]. |
| 149 |
|
| 150 |
Now test plurals. |
| 151 |
|
| 152 |
No-link full forms: \glsentryfullpl{html}, \Glsentryfullpl{html}. |
| 153 |
Linking full forms: \acrfullpl{html}, \Acrfullpl{html}, \ACRfullpl{html}. |
| 154 |
Linking with insert: \acrfullpl{html}['s], \Acrfullpl{html}['s], |
| 155 |
\ACRfullpl{html}['s]. |
| 156 |
|
| 157 |
\printglossaries |
| 158 |
\end{document} |