summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/listlbls/listlbls.dtx
blob: c1036548e7d8bc95569eb02c471a9f954f296e07 (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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
----------------------------------------------------------------
listlbls --- Creates a list of all labels used throughout a document
Author:  Norbert Melzer
E-mail:  timmelzer@gmail.com
License: Released under the LaTeX Project Public License v1.3c or later
See:     http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

Some text about the package: probably the same as the abstract.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
----------------------------------------------------------------
listlbls --- Creates a list of all labels used throughout a document
Author:  Norbert Melzer
E-mail:  timmelzer@gmail.com
License: Released under the LaTeX Project Public License v1.3c or later
See:     http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

\endpreamble
\postamble

Copyright (C) 2014 by Norbert Melzer <timmelzer@gmail.com>

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
version 1.3c of this license or (at your option) any later
version.  The latest version of this license is in the file:

http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) by
Norbert Melzer.

This work consists of the file listlbls.dtx and a Makefile.
Running "make" generates the derived files README, listlbls.pdf and listlbls.sty.
Running "make inst" installs the files in the user's TeX tree.
Running "make install" installs the files in the local TeX tree.

\endpostamble

\usedir{tex/latex/listlbls}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/listlbls}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/listlbls}
\generate{
  \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{listlbls.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{listlbls}
%<*package>
    [2014/07/27 v1.02 Creates a list of all labels used throughout a document]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[a4paper,margin=25mm,left=50mm,nohead]{geometry}
\usepackage{colordoc}
\usepackage{multicol}
\usepackage{dox}
\doxitem{Option}{option}{option}
\usepackage[numbered]{hypdoc}
\usepackage{xspace}
\usepackage[draft,totoc]{listlbls}
\usepackage[english]{babel}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\newcommand\TSE{\href{http://tex.stackexchange.com/}{\TeX-Stackexchange}\xspace}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{\jobname.dtx}
% \DoNotIndex{\newcommand,\newenvironment,\def,\detokenize,\dotfill,\else,\endinput,\expandafter,\fi,\ifeof,\ifx,\immediate,\jobname,\par,\pageref,\openin,\noindent,\newtoks,\newread,\newlabel,\loop,\long,\read,\ref,\relax,\repeat,\texttt,\the,\tmp,\zz,\ProcessOptions,\let,\ifdefined,\DeclareOption,\addcontentsline,\chapter,\DeclareTranslation,\DeclareTranslationFallback,\GetTranslation,\newif,\RequirePackage,\section,\`,\´,\'}
%
%\title{\textsf{listlbls} --- Creates a list of all labels used throughout a document\thanks{This file 
%   describes version \fileversion, last revised \filedate.}
%}
%\author{Norbert Melzer\thanks{E-mail: \href{mailto:timmelzer@gmail.com}{timmelzer@gmail.com}}}
%\date{Released \filedate}
%
%\maketitle
%
%\changes{v1.00}{2014/07/25}{First public release}
%\changes{v1.01}{2014/07/25}{Changed maintainer email}
%\changes{v1.01}{2014/07/25}{Changed some internal stuff to make it releaseable on CTAN}
%\changes{v1.02}{2014/07/26}{Local option wins agains global option}
%\changes{v1.02}{2014/07/27}{Added languag-support for English, German and French.}
% \begin{abstract}
% This is a package meant to help a \LaTeX-writer to keep track all the defined labels by typesetting a complete list of labels whereever the author requests it. Keep in mind, that you might need to have additional \LaTeX\ runs to get the references right.
%
% This package is based on an answer \textsc{David Carlisle}\ gave on \TSE in the thread \href{http://tex.stackexchange.com/questions/147695/list-of-all-labels-with-hyperlinks/147705#147705}{List of all labels with hyperlinks}.
% \end{abstract}
%
% \begin{multicols}{2}
%   \tableofcontents
% \end{multicols}
% \section{Installation}\label{sec:install}
% 
% The following explanations are only valid for Linux-like systems with gnu-|make| available.
%
% \subsection{From Github}
%
% \begin{enumerate}
%   \item Check out the sourcecode from \href{https://github.com/}{GitHub}:\\
%     |git clone git@github.com:NobbZ/listlbls.git|
%   \item Switch to the source-folder:\\|cd listlbls|
%   \item Checkout the branch/tag you desire: |master| for latest release, |develop| for latest builds (might be broken) or the version number desired.\\
%     |git checkout <branch/tag>|
%   \item Compile the document using |make|:\\
%     |make all|
%   \item You can do either a user-installation or a system-wide installation:
%     \begin{description}
%       \item[user:] |make inst|
%       \item[system:] |make install| (will ask for root!)
%     \end{description}
% \end{enumerate}
%
% \subsection{From CTAN}
%
% \begin{enumerate}
%   \item Browse to \url{http://ctan.org/pkg/listlbls}.
%   \item Download the package as zip archive (``Download'' at the bottom of the page).\\
%     |wget http://mirrors.ctan.org/macros/latex/contrib/listlbls.zip|
%   \item Unzip wherever you want. \\
%     |unzip listlbls.zip|
%   \item |cd| into the directory you unzipped to. \\
%     |cd listlbls|
%   \item You can do either a user-installation or a system-wide installation:
%     \begin{description}
%       \item[user:] |make inst|
%       \item[system:] |make install| (will ask for root!)
%     \end{description}
% \end{enumerate}
%
% \section{Usage}\label{sec:usage}
%
% \subsection{Initialization}\label{ssec:use-init}
%
% Just activate the package as usual: |\usepackage|\oarg{options}|{listlbls}|
%
% \DescribeOption{draft} If |draft| is given as option, |\listoflabels| will typeset the list of labels.
%
% \DescribeOption{final} If |final| is given as option, |\listoflabels| will do nothing. Please remember, that |final| is set globally by most documentclasses.
%
% \DescribeOption{totoc} If this is given the List of Labels will appear in a table of contents (unnumbered).
%
% \DescribeOption{notoc} If this is given the List of Labels will \emph{not} appear in a table of contents, but it will still have a headline.
%
% \DescribeOption{numtoc} Typesets a numbered headline, this option also implies |totoc|!
%
% This document was typeset with |\usepackage[draft,totoc]{listlbls}|.
%
% A locally set option will win against a globally set contrary option!
%
% \subsection{Macros}
%
% Then anywhere in your document, you can use the |\listoflabels|-macro to typeset a list of labels. An example can be seen on page \pageref{sec:lolabels}.
%
% \DescribeMacro{\label} Use |\label| as you are used to it!
%
% \DescribeMacro{\listoflabels} This macro will typeset the list of labels when this module is in draft mode. It will itself register the label ``|special:listoflabels|''.
%
%\StopEventually{^^A
%  \PrintChanges
%
%  \PrintIndex
%
%  \listoflabels
%}
%
% \section{Implementation}\label{sec:implementation}
%
%    \begin{macrocode}
%<*package>
\newif\if@draft\@draftfalse
\newif\if@totoc\@totocfalse
\newif\if@numtoc\@numtocfalse
%    \end{macrocode}
% \subsection{Options}\label{ssec:impl-options}
% \begin{option}{draft}
% \changes{v1.01}{2014/07/25}{Added option}
% \changes{v1.02}{2014/07/26}{Introduced @ifdraft}
% Check for |draft|-option:
%    \begin{macrocode}
\DeclareOption{draft}{\@drafttrue}
%    \end{macrocode}
% \end{option}
% \begin{option}{final}
% \changes{v1.01}{2014/07/25}{Added option}
% \changes{v1.02}{2014/07/26}{Introduced @ifdraft}
% Check for |final|-option:
%    \begin{macrocode}
\DeclareOption{final}{\@draftfalse}
%    \end{macrocode}
% \end{option}
% \begin{option}{totoc}
% \changes{v1.02}{2014/07/26}{Added option}
% Check for |totoc|-option:
%    \begin{macrocode}
\DeclareOption{totoc}{\@totoctrue}
%    \end{macrocode}
% \end{option}
% \begin{option}{notoc}
% \changes{v1.02}{2014/07/26}{Added option}
% Check for |notoc|-option:
%    \begin{macrocode}
\DeclareOption{notoc}{\@totocfalse}
%    \end{macrocode}
% \end{option}
% \begin{option}{numtoc}
% \changes{v1.02}{2014/07/27}{Added option}
% Check for |numtoc|-option:
%    \begin{macrocode}
\DeclareOption{numtoc}{\@numtoctrue}
%    \end{macrocode}
% \end{option}
% Process the options:
%    \begin{macrocode}
\ProcessOptions*\relax
%    \end{macrocode}
% \subsection{Loading auxilliary packages}\label{ssec:impl-aux}
% Load the package |translations| to provide internationalised caption for the |\listoflabels|.
%    \begin{macrocode}
\RequirePackage{translations}
%    \end{macrocode}
% \subsection{Set up internationalisation}\label{ssec:impl-i18n}
% Define fallback translations:
%    \begin{macrocode}
\DeclareTranslationFallback{llbls-listoflabels}{List of Labels}
\DeclareTranslationFallback{llbls-onpage}{on page}
%    \end{macrocode}
% Define other translations:
%    \begin{macrocode}
\DeclareTranslation{English}{llbls-listoflabels}{List of Labels}
\DeclareTranslation{English}{llbls-onpage}{on page}
\DeclareTranslation{German}{llbls-listoflabels}{Sprungmarkenverzeichnis}
\DeclareTranslation{German}{llbls-onpage}{auf Seite}
\DeclareTranslation{French}{llbls-listoflabels}{Liste des \'etiquettes}
\DeclareTranslation{French}{llbls-onpage}{\`a la page}
%    \end{macrocode}
% \subsection{Internal stuff}\label{ssec:impl-internal}
% Determine if we have |\chapter|s or not and create a command that maps to |\chapter| or |\section| as needed.
%    \begin{macrocode}
\ifdefined\chapter*
  \if@numtoc
    \def\llbls@headline{\chapter{List of Labels}\label{special:listoflabels}}
  \else
    \def\llbls@toccommand{\chapter*}
    \def\llbls@tocgroup{chapter}
  \fi
\else
  \if@numtoc
    \def\llbls@headline{\section{List of Labels}\label{special:listoflabels}}
  \else
    \def\llbls@toccommand{\section*}
    \def\llbls@tocgroup{section}
  \fi
\fi
\ifdefined\llbls@headline\else
  \def\llbls@headline{\llbls@toccommand{\GetTranslation{llbls-listoflabels}}\label{special:listoflabels}%
    \if@totoc\addcontentsline{toc}{\llbls@tocgroup}{\GetTranslation{llbls-listoflabels}}\relax\fi}
\fi
%    \end{macrocode}
% \begin{macro}{\@findlabel}
% No explanation yet.
%    \begin{macrocode}
\long\def\@findlabel#1#2\@findlabel{%
  \ifx\newlabel#1\lablist\expandafter{\the\lablist\@showlabel#2}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@showlabel}
% Displays a single entry in the |\listoflabels|
%    \begin{macrocode}
\def\@showlabel#1#2{%
  \par\noindent Label: \texttt{\detokenize{#1}}\dotfill\ref{#1}~\GetTranslation{llbls-onpage}~\pageref{#1}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\newtoks\lablist
\newread\zz
\immediate\openin\zz=\jobname.aux
\loop
\ifeof\zz\else
\read\zz to \tmp
\expandafter\@findlabel\tmp\relax\@findlabel
\repeat    
%    \end{macrocode}
% \subsection{External stuff}\label{ssec:impl-extern}
%    \begin{macrocode}
\if@draft
%    \end{macrocode}
% \begin{macro}{\listoflabels}
% Print a list of all available lables that are defined throughout the document.
%    \begin{macrocode}
  \newcommand\listoflabels{%
    \llbls@headline%
    \the\lablist}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\else
  \let\listoflabels=\relax
\fi
\endinput
%</package>
%    \end{macrocode}
%\Finale