summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/glossaries-extra/glossary-topic.sty
blob: 74bd967eb0f8088b94dd75e917698fdff4facde8 (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
%%
%% This is file `glossary-topic.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% glossaries-extra.dtx  (with options: `glossary-topic.sty,package')
%% 
%%  glossaries-extra.dtx
%%  Copyright 2020 Nicola Talbot
%% 
%%  This work may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.3
%%  of this license or (at your option) any later version.
%%  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%%  and version 1.3 or later is part of all distributions of LaTeX
%%  version 2005/12/01 or later.
%% 
%%  This work has the LPPL maintenance status `maintained'.
%% 
%%  The Current Maintainer of this work is Nicola Talbot.
%% 
%%  This work consists of the files glossaries-extra.dtx and glossaries-extra.ins and the derived files glossaries-extra.sty, glossaries-extra-bib2gls.sty, glossaries-extra-stylemods.sty, glossary-bookindex.sty, glossary-longextra.sty, glossary-topic.sty, example-glossaries-xr.tex, example-glossaries-acronym-desc.bib, example-glossaries-acronym.bib, example-glossaries-acronyms-lang.bib, example-glossaries-brief.bib, example-glossaries-childnoname.bib, example-glossaries-cite.bib, example-glossaries-images.bib, example-glossaries-long.bib, example-glossaries-multipar.bib, example-glossaries-parent.bib, example-glossaries-symbolnames.bib, example-glossaries-symbols.bib, example-glossaries-url.bib, example-glossaries-xr.bib.
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossary-topic}[2020/02/13 v1.42 (NLCT)]
\RequirePackage{multicol}
\newglossarystyle{topic}{%
  \renewenvironment{theglossary}%
  {%
    \glstopicInit
    \def\glstopic@prechildren{}%
    \def\glstopic@prevlevel{-1}%
  }%
  {\par}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{%
    \def\glstopic@prevlevel{-1}%
    \glstopicGroupHeading{##1}%
  }%
  \renewcommand{\glossentry}[2]{%
    \hangindent0pt\relax
    \parindent\glstopicParIndent\relax
    \glstopicItem{##1}{##2}%
     \ifglshasdesc{##1}%
     {%
       \def\glstopic@prechildren{}%
     }%
     {%
       \def\glstopic@prechildren{\nopagebreak}%
     }%
  }%
  \renewcommand{\subglossentry}[3]{%
    \ifnum\glstopic@prevlevel=0\relax\glstopic@prechildren\fi
    \def\glstopic@prevlevel{##1}%
    \glstopicAssignSubIndent{##1}%
    \glstopicSubItem{##1}{##2}{##3}%
  }%
  \renewcommand*{\glsgroupskip}{}%
}
\newcommand*{\glstopicGroupHeading}[1]{}
\newcommand*{\glstopicItem}[2]{%
  \glspar\glstopicPreSkip\glspar\noindent
  \glstopicMarker{#1}%
  \glstopicTitleFont
  {%
    \glsentryitem{#1}\glstarget{#1}{\glstopicTitle{#1}}%
  }%
  \ifglshasdesc{#1}%
  {\glspar\nobreak\glstopicMidSkip\glspar\nobreak
   \@afterheading\glstopicDesc{#1}\glspar\glstopicPostSkip}%
  {\glspar\nobreak\glstopicPostSkip}%
  \glstopicLoc{#1}{#2}%
}
\newcommand*{\glstopicMarker}[1]{}
\newcommand*{\glstopicTitle}[1]{\Glossentryname{#1}%
  \ifglshassymbol{#1}{\space(\glossentrysymbol{#1})}{}%
}
\newcommand*{\glstopicTitleFont}[1]{\textbf{\large #1}}
\newcommand*{\glstopicDesc}[1]{\Glossentrydesc{#1}\glspostdescription}
\newcommand*{\glstopicLoc}[2]{}
\newlength\glstopicParIndent
\setlength\glstopicParIndent{20pt}
\newlength\glstopicSubIndent
\setlength\glstopicSubIndent{20pt}
\newcommand{\glstopicInit}{}
\newcommand*{\glstopicAssignSubIndent}[1]{%
  \par
  \parindent\dimexpr#1\glstopicSubIndent-\glstopicSubIndent\relax
  \glstopicAssignWidest{#1}%
  \hangindent\dimexpr\parindent+\glstopicwidest\relax
}
\newlength\glstopicwidest
\newcommand*{\glstopicAssignWidest}[1]{%
  \ifcsundef{@glswidestlength\romannumeral#1}%
  {%
    \ifcsdef{@glswidestname\romannumeral#1}%
    {%
      \settowidth{\glstopicwidest}{%
       \glstopicSubNameFont{\csuse{@glswidestname\romannumeral#1}}%
       \glstopicSubItemSep
      }%
    }%
    {\setlength{\glstopicwidest}{0pt}}%
    \csedef{@glswidestlength\romannumeral#1}{\the\glstopicwidest}%
  }%
  {\setlength{\glstopicwidest}{\csuse{@glswidestlength\romannumeral#1}}}%
}
\newcommand*{\glstopicPreSkip}{\medskip}
\newcommand*{\glstopicMidSkip}{\smallskip}
\newcommand*{\glstopicPostSkip}{\smallskip}
\newcommand*{\glstopicSubItem}[3]{%
  \glstopicSubItemBox{#1}{\glstopicSubNameFont{\glsentryitem{#2}%
    \glstarget{#2}{\glossentryname{#2}}}%
    \glstopicSubItemSep
  }%
  \ifglshassymbol{#2}{(\glossentrysymbol{#2})\space}{}%
  \ifglshasdesc{#2}%
   {\glossentrydesc{#2}\glspostdescription\glstopicSubPreLocSep}{}%
  \glstopicSubLoc{#2}{#3}%
}
\newcommand*{\glstopicSubItemSep}{\quad}
\newcommand*{\glstopicSubItemBox}[2]{%
  \ifdim\glstopicwidest>0pt\relax\makebox[\glstopicwidest][l]{#2}\else#2\fi
}
\newcommand*{\glstopicSubNameFont}[1]{\textbf{#1}}
\newcommand*{\glstopicSubPreLocSep}{\space}
\newcommand*{\glstopicSubLoc}[2]{#2}
\newcommand*{\glstopicCols}{2}
\newcommand*{\glstopicColsEnv}{multicols}
\newglossarystyle{topicmcols}{%
  \renewenvironment{theglossary}%
  {%
    \glstopicInit
    \def\glstopic@prechildren{}%
    \def\glstopic@postchildren{}%
    \def\glstopic@prevlevel{-1}%
  }%
  {%
    \ifnum\glstopic@prevlevel>0\relax\glstopic@postchildren\fi
    \par
  }%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{%
    \ifnum\glstopic@prevlevel>0\relax\glstopic@postchildren\fi
    \def\glstopic@prevlevel{-1}%
    \glstopicGroupHeading{##1}%
  }%
  \renewcommand{\glossentry}[2]{%
    \ifnum\glstopic@prevlevel>0\relax\glstopic@postchildren\fi
    \def\glstopic@prevlevel{0}%
    \hangindent0pt\relax
    \parindent\glstopicParIndent\relax
    \glstopicItem{##1}{##2}%
    \ifnum\glstopicCols>1\relax
      \ifglshasdesc{##1}%
      {%
        \edef\glstopic@prechildren{%
          \noexpand\begin{\glstopicColsEnv}{\glstopicCols}}%
      }%
      {%
        \edef\glstopic@prechildren{%
          \noexpand\nopagebreak
          \noexpand\begin{\glstopicColsEnv}{\glstopicCols}}%
      }%
      \edef\glstopic@postchildren{\noexpand\end{\glstopicColsEnv}}%
    \fi
  }%
  \renewcommand{\subglossentry}[3]{%
    \ifnum\glstopic@prevlevel=0\relax\glstopic@prechildren\fi
    \def\glstopic@prevlevel{##1}%
    \glstopicAssignSubIndent{##1}%
    \glstopicSubItem{##1}{##2}{##3}%
  }%
  \renewcommand*{\glsgroupskip}{}%
}
\endinput
%%
%% End of file `glossary-topic.sty'.