我正在编写一个包含多个环境的文档\label{}
,并且正在寻找机会在开始时生成所有环境的列表,如下所示:
Label 1 ..... 1
Label 2 ..... 2
Label 3 ..... 4
等等。我看了一下,tocloft
但什么也没发现。
答案1
标签信息全部在 aux 文件中,因此您可以像这样提取它:
\documentclass{article}
\usepackage{hyperref}
\long\def\findlabel#1#2\findlabel{%
\ifx\newlabel#1\lablist\expandafter{\the\lablist\showlabel#2}\fi}
%hyerref has 4 felds in each label culd use them but don't here
\def\showlabel#1#2{%
\par \noindent Label: \texttt{\detokenize{#1}}\dotfill \ref{#1} on page \pageref{#1}}
\newtoks\lablist
\newread\zz
\immediate\openin\zz=\jobname.aux
\loop
\ifeof\zz\else
\read\zz to \tmp
\expandafter\findlabel\tmp\relax\findlabel
\repeat
\begin{document}
\section*{Labels}
\the\lablist
\section{ho ho ho}\label{z}
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
\subsection{him hum hum}\label{zz}
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
\begin{equation}
1=2\label{q}
\end{equation}
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
\begin{figure}
X\\X\\X\\X\\X\\X\\X\\X\\X\\
X\\X\\X\\X\\X\\X\\X\\X\\X\\
X\\X\\X\\X\\X\\X\\X\\X\\X\\
X\\X\\X\\X\\X\\X\\X\\X\\X
\caption{figure figure figure}\label{ff}
\end{figure}
\end{document}