Debian Codegraph @

texmf-dist/source/latex/listlbls/listlbls.dtx

raw
1 % \iffalse meta-comment
2 %<*internal>
3 \iffalse
4 %</internal>
5 %<*readme>
6 ----------------------------------------------------------------
7 listlbls --- Creates a list of all labels used throughout a document
8 Author: Norbert Melzer
9 E-mail: [email protected]
10 License: Released under the LaTeX Project Public License v1.3c or later
11 See: http://www.latex-project.org/lppl.txt
12 ----------------------------------------------------------------
13
14 This is a package meant to help a LaTeX-writer to keep track all the defined
15 labels by typesetting a complete list of labels whereever the author requests
16 it. Keep in mind, that you might need to have additional LaTeX runs to get the
17 references right.
18
19 This package is based on an answer David Carlisle gave on tex.stackexchange.com
20 in the thread ``List of all labels with hyperlinks''[1].
21
22 [1]: http://tex.stackexchange.com/questions/147695/list-of-all-labels-with-hyperlinks/147705#147705
23 %</readme>
24 %<*readmemd>
25 listlbls
26 ========
27
28 Creates a list of all labels used throughout a document
29
30 | Key | Value |
31 |--------:|:---------------------------------------------------------------|
32 | Author | Norbert Melzer |
33 | E-mail | [email protected] |
34 | License | Released under the LaTeX Project Public License v1.3c or later |
35 | See | http://www.latex-project.org/lppl.txt |
36
37 This is a package meant to help a LaTeX-writer to keep track all the defined
38 labels by typesetting a complete list of labels whereever the author requests
39 it. Keep in mind, that you might need to have additional LaTeX runs to get the
40 references right.
41
42 This package is based on an answer David Carlisle gave on tex.stackexchange.com
43 in the thread [List of all labels with hyperlinks][1].
44
45 [1]: http://tex.stackexchange.com/questions/147695/list-of-all-labels-with-hyperlinks/147705#147705
46 %</readmemd>
47 %<*internal>
48 \fi
49 \def\nameofplainTeX{plain}
50 \ifx\fmtname\nameofplainTeX\else
51 \expandafter\begingroup
52 \fi
53 %</internal>
54 %<*install>
55 \input docstrip.tex
56 \keepsilent
57 \askforoverwritefalse
58 \preamble
59 ----------------------------------------------------------------
60 listlbls --- Creates a list of all labels used throughout a document
61 Author: Norbert Melzer
62 E-mail: [email protected]
63 License: Released under the LaTeX Project Public License v1.3c or later
64 See: http://www.latex-project.org/lppl.txt
65 ----------------------------------------------------------------
66
67 \endpreamble
68 \postamble
69
70 Copyright (C) 2014 by Norbert Melzer <[email protected]>
71
72 This work may be distributed and/or modified under the
73 conditions of the LaTeX Project Public License (LPPL), either
74 version 1.3c of this license or (at your option) any later
75 version. The latest version of this license is in the file:
76
77 http://www.latex-project.org/lppl.txt
78
79 This work is "maintained" (as per LPPL maintenance status) by
80 Norbert Melzer.
81
82 This work consists of the file listlbls.dtx and a Makefile.
83 Running "make" generates the derived files README, listlbls.pdf and listlbls.sty.
84 Running "make inst" installs the files in the user's TeX tree.
85 Running "make install" installs the files in the local TeX tree.
86
87 \endpostamble
88
89 \usedir{tex/latex/listlbls}
90 \generate{
91 \file{\jobname.sty}{\from{\jobname.dtx}{package}}
92 }
93 %</install>
94 %<install>\endbatchfile
95 %<*internal>
96 \usedir{source/latex/listlbls}
97 \generate{
98 \file{\jobname.ins}{\from{\jobname.dtx}{install}}
99 }
100 \nopreamble\nopostamble
101 \usedir{doc/latex/listlbls}
102 \generate{
103 \file{README.txt}{\from{\jobname.dtx}{readme}}
104 }
105 \generate{
106 \file{README.md}{\from{\jobname.dtx}{readmemd}}
107 }
108 \ifx\fmtname\nameofplainTeX
109 \expandafter\endbatchfile
110 \else
111 \expandafter\endgroup
112 \fi
113 %</internal>
114 % \fi
115 %
116 % \iffalse
117 %<*driver>
118 \ProvidesFile{listlbls.dtx}
119 %</driver>
120 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
121 %<package>\ProvidesPackage{listlbls}
122 %<*package>
123 [2023/05/24 v1.04 Creates a list of all labels used throughout a document]
124 %</package>
125 %<*driver>
126 \documentclass{ltxdoc}
127 \usepackage{microtype}
128 \usepackage{lmodern}
129 \usepackage{fontawesome5}
130 \usepackage[a4paper,margin=25mm,left=45mm,nohead]{geometry}
131 \usepackage{multicol}
132 \usepackage[reportchangedates]{doc}
133 \usepackage{dtxdescribe}
134 \usepackage[numbered]{hypdoc}
135 \usepackage{xspace}
136 \usepackage{nameref}
137 \usepackage[english]{babel}
138 \usepackage[draft,totoc]{listlbls}
139 \EnableCrossrefs
140 \CodelineIndex
141 \RecordChanges
142 \newcommand\TSE{\href{http://tex.stackexchange.com/}{\TeX-Stackexchange}\xspace}
143
144 \newcommand\link[2]{\href{#1}{#2}\footnote{\nolinkurl{#1}}}
145 \newcommand\ghissue[3]{\link{https://github.com/#1/#2/issues/#3}{\faIcon{github}~#1/#2\##3}}
146 \newcommand\thisissue[1]{\ghissue{nobbz}{listlbls}{#1}}
147 \begin{document}
148 \DocInput{\jobname.dtx}
149 \end{document}
150 %</driver>
151 % \fi
152 %
153 % \GetFileInfo{\jobname.dtx}
154 % \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,\`,\ยด,\'}
155 %
156 %\title{\textsf{listlbls} --- Creates a list of all labels used throughout a document\thanks{This file
157 % describes version \fileversion, last revised \filedate.}
158 %}
159 %\author{Norbert Melzer\thanks{E-mail: \href{mailto:[email protected]}{[email protected]}}}
160 %\date{Released \filedate}
161 %
162 %\maketitle
163 %
164 %\changes{v1.00}{2014/07/25}{First public release}
165 %\changes{v1.01}{2014/07/25}{Changed maintainer email}
166 %\changes{v1.01}{2014/07/25}{Changed some internal stuff to make it releaseable on CTAN}
167 %\changes{v1.02}{2014/07/27}{Local option wins agains global option}
168 %\changes{v1.02}{2014/07/27}{Added languag-support for English, German and French.}
169 %\changes{v1.03}{2014/08/04}{Proceeding with namespacing internal macros}
170 %\changes{v1.04}{2023/05/24}{Fix build problems due to bitrotten dependencies}
171 %\changes{v1.04}{2023/05/24}{Switch back to lmodern for documentation}
172 % \begin{abstract}
173 % 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.
174 %
175 % 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}.
176 % \end{abstract}
177 %
178 % \begin{multicols}{2}
179 % \tableofcontents
180 % \end{multicols}
181 % \section{Installation}\label{sec:install}
182 %
183 % The following explanations are only valid for Linux-like systems with gnu-|make| available.
184 %
185 % \subsection{\TeX live}\label{ssec:inst-tl}
186 %
187 % This package is bundled in \TeX live, so you can simply (|sudo|) |tlmgr install listlbls| (which should work for windows as well)
188 %
189 % \subsection{From Github}\label{ssec:inst-gh}
190 %
191 % \begin{enumerate}
192 % \item Check out the sourcecode from \link{https://github.com/}{GitHub}:\\
193 % |git clone https://github.com/NobbZ/nixos-config.git| or\\
194 % |git clone [email protected]:NobbZ/listlbls.git| or\\
195 % |gh repo clone NobbZ/listlbls|
196 % \item Switch to the source-folder:\\|cd listlbls|
197 % \item Checkout the branch/tag you desire: |master| for latest release, |develop| for latest builds (might be broken) or the version number desired.\\
198 % |git checkout <branch/tag>|
199 % \item Compile the document using |make|:\\
200 % |make all|
201 % \item You can do either a user-installation or a system-wide installation:
202 % \begin{description}
203 % \item[user:] |make inst|
204 % \item[system:] |make install| (will ask for root!)
205 % \end{description}
206 % \end{enumerate}
207 %
208 % \subsection{From CTAN}\label{ssec:inst-ctan}
209 %
210 % \begin{enumerate}
211 % \item Browse to \url{http://ctan.org/pkg/listlbls}.
212 % \item Download the package as zip archive (``Download'' at the bottom of the page).\\
213 % |wget http://mirrors.ctan.org/macros/latex/contrib/listlbls.zip|
214 % \item Unzip wherever you want. \\
215 % |unzip listlbls.zip|
216 % \item |cd| into the directory you unzipped to. \\
217 % |cd listlbls|
218 % \item You can do either a user-installation or a system-wide installation:
219 % \begin{description}
220 % \item[user:] |make inst|
221 % \item[system:] |make install| (will ask for root!)
222 % \end{description}
223 % \end{enumerate}
224 %
225 % \section{Usage}\label{sec:usage}
226 %
227 % \subsection{Initialization}\label{ssec:use-init}
228 %
229 % Just activate the package as usual: |\usepackage|\oarg{options}|{listlbls}|
230 %
231 % \DescribeOption{draft} If |draft| is given as option, |\listoflabels| will typeset the list of labels.
232 %
233 % \DescribeOption{final} If |final| is given as option, |\listoflabels| will do nothing. Please remember, that |final| is set globally by most documentclasses.
234 %
235 % \DescribeOption{totoc} If this is given the List of Labels will appear in a table of contents (unnumbered).
236 %
237 % \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.
238 %
239 % \DescribeOption{numtoc} Typesets a numbered headline, this option also implies |totoc|!
240 %
241 % \DescribeOption{nonameref} Even if the package |nameref| if detected, it will not be used.
242 %
243 % This document was typeset with |\usepackage[draft,totoc]{listlbls}| also the package |nameref| was loaded.
244 %
245 % A locally set option will win against a globally set contrary option!
246 %
247 % \subsection{Macros}\label{ssec:use-macros}
248 %
249 % 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{special:listoflabels}.
250 %
251 % \DescribeMacro{\label} \marg{name}
252 % Use |\label| as you are used to it!
253 %
254 % \DescribeMacro{\listoflabels} \oarg{label}
255 % This macro will typeset the list of labels when this module is in draft mode.
256 % It will itself register the label from the optional arg, defaulting to ``|special:listoflabels|''.
257 %
258 %\StopEventually{^^A
259 % \PrintChanges
260 %
261 % \PrintIndex
262 %
263 % \listoflabels
264 %}
265 %
266 % \section{Contribution and bugreports}\label{sec:contribute}
267 %
268 % If you have feature-requests or bug-reports, please feel free to report them on the \link{https://github.com/NobbZ/listlbls}{project page at GitHub}.
269 %
270 % If you want to contribute then follow these steps:
271 % \begin{enumerate}
272 % \item Visit the \link{https://github.com/NobbZ/listlbls}{project page at GitHub},
273 % \item forkt it,
274 % \item clone it to your local machine,
275 % \item create a branch ``|feature/|\meta{feature name}'',
276 % \item do your changes,
277 % \item push them back to GitHub,
278 % \item create a pull request to |develop|,
279 % \item and wait for approval.
280 % \end{enumerate}
281 % After approval your code will be merged to the |development|-branch and I will generally not accept pull-requests that edit |develop| directly.
282 %
283 % \section{Known issues and limitations}\label{sec:issues}
284 % \changes{v1.04}{2023/05/24}{Add issues and limitations section}
285 %
286 % \subsection{\texttt{\textbackslash{}include}}\label{ssec:issues-include}
287 %
288 % Documents containing |\include| will not work.
289 % Currently there is no logic to recurse through the different |.aux|-files.
290 %
291 % Please see \thisissue{4} for more information.
292 %
293 % \section{Implementation}\label{sec:implementation}
294 %
295 % \begin{macrocode}
296 %<*package>
297 \newif\ifllbls@draft\llbls@draftfalse
298 \newif\ifllbls@totoc\llbls@totocfalse
299 \newif\ifllbls@numtoc\llbls@numtocfalse
300 \newif\ifllbls@nameref\llbls@namereftrue
301 % \end{macrocode}
302 % \subsection{Options}\label{ssec:impl-options}
303 % \begin{option}{draft}
304 % \changes{v1.01}{2014/07/25}{Added option}
305 % \changes{v1.02}{2014/07/27}{Introduced @ifdraft}
306 % Check for |draft|-option:
307 % \begin{macrocode}
308 \DeclareOption{draft}{\llbls@drafttrue}
309 % \end{macrocode}
310 % \end{option}
311 % \begin{option}{final}
312 % \changes{v1.01}{2014/07/25}{Added option}
313 % \changes{v1.02}{2014/07/27}{Introduced @ifdraft}
314 % Check for |final|-option:
315 % \begin{macrocode}
316 \DeclareOption{final}{\llbls@draftfalse}
317 % \end{macrocode}
318 % \end{option}
319 % \begin{option}{totoc}
320 % \changes{v1.02}{2014/07/27}{Added option}
321 % Check for |totoc|-option:
322 % \begin{macrocode}
323 \DeclareOption{totoc}{\llbls@totoctrue}
324 % \end{macrocode}
325 % \end{option}
326 % \begin{option}{notoc}
327 % \changes{v1.02}{2014/07/27}{Added option}
328 % Check for |notoc|-option:
329 % \begin{macrocode}
330 \DeclareOption{notoc}{\llbls@totocfalse}
331 % \end{macrocode}
332 % \end{option}
333 % \begin{option}{numtoc}
334 % \changes{v1.02}{2014/07/27}{Added option}
335 % Check for |numtoc|-option:
336 % \begin{macrocode}
337 \DeclareOption{numtoc}{\llbls@numtoctrue}
338 % \end{macrocode}
339 % \end{option}
340 % \begin{option}{nonameref}
341 % \changes{v1.03}{2014/08/04}{Added option}
342 % Check for |nonameref|-option:
343 % \begin{macrocode}
344 \DeclareOption{nonameref}{\llbls@namereffalse}
345 % \end{macrocode}
346 % \end{option}
347 % Process the options:
348 % \begin{macrocode}
349 \ProcessOptions*\relax
350 % \end{macrocode}
351 % \subsection{Loading auxilliary packages}\label{ssec:impl-aux}
352 % Load the package |translations| to provide internationalised caption for the\\|\listoflabels|.
353 % \begin{macrocode}
354 \RequirePackage{translations}
355 % \end{macrocode}
356 % \subsection{Set up internationalisation}\label{ssec:impl-i18n}
357 % Define fallback translations:
358 % \begin{macrocode}
359 \DeclareTranslationFallback%
360 {llbls-listoflabels}%
361 {List of Labels}
362 \DeclareTranslationFallback%
363 {llbls-onpage}%
364 {on page}
365 % \end{macrocode}
366 % \subsubsection{English}\label{sssec:impl-i18n-en}
367 % \begin{macrocode}
368 \DeclareTranslation{English}%
369 {llbls-listoflabels}%
370 {List of Labels}
371 \DeclareTranslation{English}%
372 {llbls-onpage}%
373 {on page}
374 % \end{macrocode}
375 % \subsubsection{German}\label{sssec:impl-i18n-de}
376 % \begin{macrocode}
377 \DeclareTranslation{German}%
378 {llbls-listoflabels}%
379 {Sprungmarkenverzeichnis}
380 \DeclareTranslation{German}%
381 {llbls-onpage}%
382 {auf Seite}
383 % \end{macrocode}
384 % \subsubsection{French}\label{sssec:impl-i18n-fr}
385 % \begin{macrocode}
386 \DeclareTranslation{French}%
387 {llbls-listoflabels}%
388 {Liste des \'etiquettes}
389 \DeclareTranslation{French}%
390 {llbls-onpage}%
391 {\`a la page}
392 % \end{macrocode}
393 % \subsubsection{Portuguese}\label{sssec:impl-i18n-pt}
394 % \changes{v1.04}{2023/05/24}{Add Portuguese translation}
395 % \begin{macrocode}
396 \DeclareTranslation{Portuguese}%
397 {llbls-listoflabels}%
398 {Lista de R\'{o}tulos}
399 \DeclareTranslation{Portuguese}%
400 {llbls-onpage}%
401 {na p\'{a}gina}
402 % \end{macrocode}
403 % \subsection{Internal stuff}\label{ssec:impl-internal}
404 % \begin{macro}{\llbls@headline}\begin{macro}{\llbls@toccommand}\begin{macro}{\llbls@tocgroup}
405 % Determine if we have |\chapter|s or not and create a command that maps to |\chapter| or |\section| as needed.
406 % \begin{macrocode}
407 \ifdefined\chapter
408 \ifllbls@numtoc
409 \def\llbls@headline{%
410 % \end{macrocode}
411 % We are using |\llbls@labelname| here and in the other possible definitions of |\llbls@headline| to be able to set the label name in the |\listoflabels| macro.
412 % \begin{macrocode}
413 \chapter{List of Labels}\label{\llbls@labelname}}
414 \else
415 \def\llbls@toccommand{\chapter*}
416 \def\llbls@tocgroup{chapter}
417 \fi
418 \else
419 \ifllbls@numtoc
420 \def\llbls@headline{%
421 \section{List of Labels}\label{\llbls@labelname}}
422 \else
423 \def\llbls@toccommand{\section*}
424 \def\llbls@tocgroup{section}
425 \fi
426 \fi
427 \ifdefined\llbls@headline\else
428 \def\llbls@headline{%
429 \llbls@toccommand{\GetTranslation{llbls-listoflabels}}%
430 \label{\llbls@labelname}%
431 \ifllbls@totoc%
432 \addcontentsline{toc}%
433 {\llbls@tocgroup}%
434 {\GetTranslation{llbls-listoflabels}}%
435 \relax%
436 \fi%
437 }
438 \fi
439 % \end{macrocode}
440 % \end{macro}\end{macro}\end{macro}
441 % \begin{macro}{\llbls@refs}
442 % Whether or not we use |\nameref| in the output.
443 % \begin{macrocode}
444 \ifdefined\nameref
445 \ifllbls@nameref
446 \newcommand\llbls@refs[1]{\nameref{#1}, \ref{#1}}
447 \else
448 \newcommand\llbls@refs[1]{\ref{#1}}
449 \fi
450 \else
451 \newcommand\llbls@refs[1]{\ref{#1}}%
452 \fi
453 % \end{macrocode}
454 % \end{macro}
455 % \begin{macro}{\llbls@findlabel}
456 % No explanation yet.
457 % \begin{macrocode}
458 \long\def\llbls@findlabel#1#2\llbls@findlabel{%
459 \ifx\newlabel#1%
460 \llbls@lablist\expandafter{\the\llbls@lablist\llbls@showlabel#2}
461 \fi}
462 % \end{macrocode}
463 % \end{macro}
464 %
465 % \begin{macro}{\llbls@showlabel}
466 % \changes{v1.02}{2014/08/04}{Add support for nameref-package}
467 % Displays a single entry in the |\listoflabels|
468 % \begin{macrocode}
469 \def\llbls@showlabel#1#2{%
470 \par\noindent Label: %
471 \texttt{\detokenize{#1}}\dotfill%
472 \llbls@refs{#1}~\GetTranslation{llbls-onpage}~\pageref{#1}%
473 }
474 % \end{macrocode}
475 % \end{macro}
476 %
477 % \begin{macrocode}
478 \newtoks\llbls@lablist
479 \newread\llbls@zz
480 \immediate\openin\llbls@zz=\jobname.aux
481 \loop
482 \ifeof\llbls@zz\else
483 \read\llbls@zz to \llbls@tmp
484 \expandafter\llbls@findlabel\llbls@tmp\relax\llbls@findlabel
485 \repeat
486 % \end{macrocode}
487 % \subsection{External stuff}\label{ssec:impl-extern}
488 % \begin{macrocode}
489 \ifllbls@draft
490 % \end{macrocode}
491 % \begin{macro}{\listoflabels}
492 % \changes{v1.04}{2023/05/24}{add optional argument to change the name of the label used.}
493 % \begin{macro}{\llbls@labelname}
494 % Print a list of all available lables that are defined throughout the document.
495 % \begin{macrocode}
496 \newcommand{\listoflabels}[1][special:listoflabels]{%
497 \def\llbls@labelname{#1}%
498 \llbls@headline%
499 \the\llbls@lablist}
500 % \end{macrocode}
501 % \end{macro}\end{macro}
502 % \begin{macrocode}
503 \else
504 \let\listoflabels=\relax
505 \fi
506 \endinput
507 %</package>
508 % \end{macrocode}
509 %\Finale