From 93eabd122c74d35dfd34e5d1b5e645dcdbe73998 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 10 Aug 2014 22:20:40 +0000 Subject: listlbls git-svn-id: svn://tug.org/texlive/trunk@34893 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/listlbls/listlbls.dtx | 216 ++++++++++++++++----- 1 file changed, 169 insertions(+), 47 deletions(-) (limited to 'Master/texmf-dist/source/latex/listlbls') diff --git a/Master/texmf-dist/source/latex/listlbls/listlbls.dtx b/Master/texmf-dist/source/latex/listlbls/listlbls.dtx index c1036548e7d..52da33c3817 100644 --- a/Master/texmf-dist/source/latex/listlbls/listlbls.dtx +++ b/Master/texmf-dist/source/latex/listlbls/listlbls.dtx @@ -11,8 +11,39 @@ 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. +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 David Carlisle gave on tex.stackexchange.com +in the thread ``List of all labels with hyperlinks''[1]. + +[1]: http://tex.stackexchange.com/questions/147695/list-of-all-labels-with-hyperlinks/147705#147705 % +%<*readmemd> +listlbls +======== + +Creates a list of all labels used throughout a document + +| Key | Value | +|--------:|:---------------------------------------------------------------| +| 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 | + +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 David Carlisle gave on tex.stackexchange.com +in the thread [List of all labels with hyperlinks][1]. + +[1]: http://tex.stackexchange.com/questions/147695/list-of-all-labels-with-hyperlinks/147705#147705 +% %<*internal> \fi \def\nameofplainTeX{plain} @@ -71,6 +102,9 @@ Running "make install" installs the files in the local TeX tree. \generate{ \file{README.txt}{\from{\jobname.dtx}{readme}} } +\generate{ + \file{README.md}{\from{\jobname.dtx}{readmemd}} +} \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else @@ -86,10 +120,12 @@ Running "make install" installs the files in the local TeX tree. %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{listlbls} %<*package> - [2014/07/27 v1.02 Creates a list of all labels used throughout a document] + [2014/08/04 v1.03 Creates a list of all labels used throughout a document] % %<*driver> \documentclass{ltxdoc} +\usepackage{microtype} +\usepackage{libertine} \usepackage[a4paper,margin=25mm,left=50mm,nohead]{geometry} \usepackage{colordoc} \usepackage{multicol} @@ -97,8 +133,9 @@ Running "make install" installs the files in the local TeX tree. \doxitem{Option}{option}{option} \usepackage[numbered]{hypdoc} \usepackage{xspace} -\usepackage[draft,totoc]{listlbls} +\usepackage{nameref} \usepackage[english]{babel} +\usepackage[draft,totoc]{listlbls} \EnableCrossrefs \CodelineIndex \RecordChanges @@ -125,6 +162,7 @@ Running "make install" installs the files in the local TeX tree. %\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.} +%\changes{v1.03}{2014/08/04}{Proceeding with namespacing internal macros} % \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. % @@ -138,7 +176,11 @@ Running "make install" installs the files in the local TeX tree. % % The following explanations are only valid for Linux-like systems with gnu-|make| available. % -% \subsection{From Github} +% \subsection{\TeX live}\label{ssec:inst-tl} +% +% This package is bundled in \TeX live, so you can simply (|sudo|) |tlmgr install listlbls| (which should work for windows as well) +% +% \subsection{From Github}\label{ssec:inst-gh} % % \begin{enumerate} % \item Check out the sourcecode from \href{https://github.com/}{GitHub}:\\ @@ -155,7 +197,7 @@ Running "make install" installs the files in the local TeX tree. % \end{description} % \end{enumerate} % -% \subsection{From CTAN} +% \subsection{From CTAN}\label{ssec:inst-ctan} % % \begin{enumerate} % \item Browse to \url{http://ctan.org/pkg/listlbls}. @@ -188,13 +230,15 @@ Running "make install" installs the files in the local TeX tree. % % \DescribeOption{numtoc} Typesets a numbered headline, this option also implies |totoc|! % -% This document was typeset with |\usepackage[draft,totoc]{listlbls}|. +% \DescribeOption{nonameref} Even if the package |nameref| if detected, it will not be used. +% +% This document was typeset with |\usepackage[draft,totoc]{listlbls}| also the package |nameref| was loaded. % % A locally set option will win against a globally set contrary option! % -% \subsection{Macros} +% \subsection{Macros}\label{ssec:use-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}. +% 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}. % % \DescribeMacro{\label} Use |\label| as you are used to it! % @@ -208,13 +252,30 @@ Running "make install" installs the files in the local TeX tree. % \listoflabels %} % +% \section{Contribution and bugreports}\label{sec:contribute} +% +% If you have feature-requests or bug-reports, please feel free to report them on the \href{https://github.com/NobbZ/listlbls}{project page at GitHub}. +% +% If you want to contribute then follow these steps: +% \begin{enumerate} +% \item Visit the \href{https://github.com/NobbZ/listlbls}{project page at GitHub}, +% \item forkt it, +% \item clone it to your local machine, +% \item create a branch ``|feature/|\meta{feature name}'', +% \item do your changes, +% \item push them back to GitHub, +% \item create a pull request to |develop|, +% \item and wait for approval. +% \end{enumerate} +% After approval your code will be merged to the |development|-branch and I will generally not accept pull-requests that edit |develop| directly. % \section{Implementation}\label{sec:implementation} % % \begin{macrocode} %<*package> -\newif\if@draft\@draftfalse -\newif\if@totoc\@totocfalse -\newif\if@numtoc\@numtocfalse +\newif\ifllbls@draft\llbls@draftfalse +\newif\ifllbls@totoc\llbls@totocfalse +\newif\ifllbls@numtoc\llbls@numtocfalse +\newif\ifllbls@nameref\llbls@namereftrue % \end{macrocode} % \subsection{Options}\label{ssec:impl-options} % \begin{option}{draft} @@ -222,7 +283,7 @@ Running "make install" installs the files in the local TeX tree. % \changes{v1.02}{2014/07/26}{Introduced @ifdraft} % Check for |draft|-option: % \begin{macrocode} -\DeclareOption{draft}{\@drafttrue} +\DeclareOption{draft}{\llbls@drafttrue} % \end{macrocode} % \end{option} % \begin{option}{final} @@ -230,28 +291,35 @@ Running "make install" installs the files in the local TeX tree. % \changes{v1.02}{2014/07/26}{Introduced @ifdraft} % Check for |final|-option: % \begin{macrocode} -\DeclareOption{final}{\@draftfalse} +\DeclareOption{final}{\llbls@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} +\DeclareOption{totoc}{\llbls@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} +\DeclareOption{notoc}{\llbls@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} +\DeclareOption{numtoc}{\llbls@numtoctrue} +% \end{macrocode} +% \end{option} +% \begin{option}{nonameref} +% \changes{v1.03}{2014/08/04}{Added option} +% Check for |nonameref|-option: +% \begin{macrocode} +\DeclareOption{nonameref}{\llbls@namereffalse} % \end{macrocode} % \end{option} % Process the options: @@ -259,84 +327,138 @@ Running "make install" installs the files in the local TeX tree. \ProcessOptions*\relax % \end{macrocode} % \subsection{Loading auxilliary packages}\label{ssec:impl-aux} -% Load the package |translations| to provide internationalised caption for the |\listoflabels|. +% 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} +\DeclareTranslationFallback% + {llbls-listoflabels}% + {List of Labels} +\DeclareTranslationFallback% + {llbls-onpage}% + {on page} +% \end{macrocode} +% \subsubsection{English}\label{sssec:impl-i18n-en} +% \begin{macrocode} +\DeclareTranslation{English}% + {llbls-listoflabels}% + {List of Labels} +\DeclareTranslation{English}% + {llbls-onpage}% + {on page} +% \end{macrocode} +% \subsubsection{German}\label{sssec:impl-i18n-de} +% \begin{macrocode} +\DeclareTranslation{German}% + {llbls-listoflabels}% + {Sprungmarkenverzeichnis} +\DeclareTranslation{German}% + {llbls-onpage}% + {auf Seite} % \end{macrocode} -% Define other translations: +% \subsubsection{French}\label{sssec:impl-i18n-fr} % \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} +\DeclareTranslation{French}% + {llbls-listoflabels}% + {Liste des \'etiquettes} +\DeclareTranslation{French}% + {llbls-onpage}% + {\`a la page} % \end{macrocode} % \subsection{Internal stuff}\label{ssec:impl-internal} +% \begin{macro}{\llbls@headline}\begin{macro}{\llbls@toccommand}\begin{macro}{\llbls@tocgroup} % 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}} + \ifllbls@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}} + \ifllbls@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} + \def\llbls@headline{% + \llbls@toccommand{\GetTranslation{llbls-listoflabels}}% + \label{special:listoflabels}% + \ifllbls@totoc% + \addcontentsline{toc}% + {\llbls@tocgroup}% + {\GetTranslation{llbls-listoflabels}}% + \relax% + \fi% + } \fi % \end{macrocode} -% \begin{macro}{\@findlabel} +% \end{macro}\end{macro}\end{macro} +% \begin{macro}{\llbls@refs} +% Whether or not we use |\nameref| in the output. +% \begin{macrocode} +\ifdefined\nameref + \ifllbls@nameref + \newcommand\llbls@refs[1]{\nameref{#1}, \ref{#1}} + \else + \newcommand\llbls@refs[1]{\ref{#1}} + \fi +\else + \newcommand\llbls@refs[1]{\ref{#1}}% +\fi +% \end{macrocode} +% \end{macro} +% \begin{macro}{\llbls@findlabel} % No explanation yet. % \begin{macrocode} -\long\def\@findlabel#1#2\@findlabel{% - \ifx\newlabel#1\lablist\expandafter{\the\lablist\@showlabel#2}\fi} +\long\def\llbls@findlabel#1#2\llbls@findlabel{% + \ifx\newlabel#1% + \llbls@lablist\expandafter{\the\llbls@lablist\llbls@showlabel#2} + \fi} % \end{macrocode} % \end{macro} % -% \begin{macro}{\@showlabel} +% \begin{macro}{\llbls@showlabel} +% \changes{v1.03}{2014/07/27}{Add support for nameref-package} % 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}} +\def\llbls@showlabel#1#2{% + \par\noindent Label: % + \texttt{\detokenize{#1}}\dotfill% + \llbls@refs{#1}~\GetTranslation{llbls-onpage}~\pageref{#1}% +} % \end{macrocode} % \end{macro} % % \begin{macrocode} -\newtoks\lablist -\newread\zz -\immediate\openin\zz=\jobname.aux +\newtoks\llbls@lablist +\newread\llbls@zz +\immediate\openin\llbls@zz=\jobname.aux \loop -\ifeof\zz\else -\read\zz to \tmp -\expandafter\@findlabel\tmp\relax\@findlabel -\repeat +\ifeof\llbls@zz\else +\read\llbls@zz to \llbls@tmp +\expandafter\llbls@findlabel\llbls@tmp\relax\llbls@findlabel +\repeat % \end{macrocode} % \subsection{External stuff}\label{ssec:impl-extern} % \begin{macrocode} -\if@draft +\ifllbls@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} + \the\llbls@lablist} % \end{macrocode} % \end{macro} % \begin{macrocode} -- cgit v1.2.3