summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/samples/sample-dot-abbr.tex
blob: cf8f9c44ae29a0b217571b2e8db23d0381b14fa1 (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
% This file is public domain.
% If you want to use arara you need the following directives:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
%
%http://mirrors.ctan.org/macros/latex/contrib/glossaries/glossaries-user.html#sample-dot-abbr
\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\glsaddstoragekey{abbrtype}{word}{\abbrtype}

\setacronymstyle{long-short}

\newcommand*{\newabbr}[1][]{%
 \newacronym[abbrtype=initials,#1]}

\newabbr{eg}{e.g.}{exempli gratia}
\newabbr{ie}{i.e.}{id est}
\newabbr{bsc}{B.Sc.}{Bachelor of Science}
\newabbr{ba}{B.A.}{Bachelor of Arts}
\newabbr{agm}{A.G.M.}{annual general meeting}

\newacronym{laser}{laser}{light amplification by stimulated
emission of radiation}

% See the sample-initialisms.tex example file provided with
% glossaries-extra.sty for a better way of doing this.

\makeatletter
\renewcommand{\glspostlinkhook}{%
 \ifglsfieldeq{\glslabel}{abbrtype}{initials}%
 {\new@ifnextchar.\doendsentence\doendword}
 {}%
}
\makeatother

\newcommand{\doendsentence}[1]{\spacefactor=10000{}}
\newcommand{\doendword}{\spacefactor=1000{}}

\begin{document}
This is a sample document that illustrates abbreviations with
full stops (periods) and abbreviations that are words (i.e.\
acronyms). The examples switch to a typewriter font to make it
easier to see the inter-word and inter-sentence spaces.

The extension package glossaries-extra.sty provides a better way of
doing this.

First use: \gls{laser} \gls{eg} \gls{ie} \gls{bsc} \gls{ba} \gls{agm} end of
sentence.

End of sentence use:

\ttfamily

\gls{laser}. \gls{eg}. \gls{ie}. \gls{bsc}. \gls{ba}. \gls{agm}.
Done.

laser. e.g. i.e. B.Sc. B.A\@. A.G.M\@. Done.

\rmfamily

Mid-sentence use:

\ttfamily

\gls{laser} \gls{eg} \gls{ie} \gls{bsc} \gls{ba} \gls{agm} Done.

laser e.g.\ i.e.\ B.Sc.\ B.A. A.G.M. Done.

\rmfamily

Check other sentence terminators:

\ttfamily

\gls{laser}? \gls{eg}? \gls{ie}? \gls{bsc}! \gls{ba}! \gls{agm}? Done.

laser? e.g.? i.e.? B.Sc.! B.A.! A.G.M.? Done.

\rmfamily

\glsresetall Reset. End of sentence use:

\ttfamily

\gls{laser}. \gls{eg}. \gls{ie}. \gls{bsc}. \gls{ba}. \gls{agm}.
Done.

\rmfamily
\printglossaries
\end{document}