这个问题与问题相关如何获取 LaTeX 文档中所有标签的列表. 根据作者lablst.sty,您可以将其用作lablst
全局选项,以documentstyle
在\documentstyle[11pt,lablst]{article}
文档末尾生成标签定义(列表)。
可以更新它以便可以使用吗documentclass
?
答案1
您可以尝试通过以下newlablst.sty
方式调用它\usepackage{newlablst}
:
\RequirePackage{atveryend,ltxcmds}
\AtVeryEndDocument{\@lablst}
\def\@lablst{
\parindent 0pt \parskip 0pt
\normalsize
\newwrite \labfile \relax
\immediate\openout \labfile =\jobname.lab\relax
{\def\toc{toc}
\def\@writefile##1##2{\def\temp{##1}%
\ifx\temp\toc
\immediate\write\labfile{\unexpanded{##2}}%
\fi}
\def\newlabel##1##2{\immediate\write\labfile{\string\newlabel{##1}{##2}}}
\def\bibcite##1##2{\immediate\write\labfile{\string\bibcite{##1}{##2}}}
\makeatletter
\input \jobname.aux }
\immediate\closeout\labfile
\def\newlabel##1##2{\par \hbox to \textwidth
{\hfill\makebox[10em][l]{\ttfamily ##1}\makebox[3.5em][l]{\first
##2}\hspace{1em}Page:\makebox[3em][r]{\second ##2}\hspace{4em}}}
\ltx@ifpackageloaded{hyperref}
{\def\first##1##2##3##4{##1}\def\second##1##2##3##4{##2}}
{\def\first##1##2{##1}\def\second##1##2{##2}}
\def\bibcite##1##2{\par\makebox[2in][l]{\ttfamily ##1}[##2]\par}
\input \jobname.lab
\clearpage
}
编辑
这也许是一个更强大的版本;它只是更现代lablst.tex
:
\RequirePackage{atveryend,ltxcmds}
\def\@lablst{%
\ltx@ifpackageloaded{hyperref}
{\long\def\x@firstoftwo##1##2##3##4{##1}%
\long\def\x@secondoftwo##1##2##3##4{##2}}
{\long\def\x@firstoftwo##1##2{##1}%
\long\def\x@secondoftwo##1##2{##2}}
\let \@mlabel \@gobbletwo
% No protection needed:
%
\let \protect \relax
% Better formatting?:
%
\let \raggedright \relax
% Only write out toc entries:
%
\def \@writefile ##1##2{%
\def\lablst@tempa{##1}%
\def\lablst@tempb{toc}%
\ifx \lablst@tempa\lablst@tempb
\par{##2}\par\nobreak
\vspace{3pt}%
\fi
}
% Allow characters like ^ _ to be printed `verbatim'.
%
\def\@lablstverb##1{%
\def\lablst@tempa{##1}%
{\ttfamily\expandafter\strip@prefix\meaning\lablst@tempa}}%
% For first run:
%
\def \newlabel ##1##2{%
\par
\hbox to \textwidth{%
\hfill\makebox[10em][r]{\@lablstverb{##1}}%
\hspace{1em}\makebox[4.5em][l]{\x@firstoftwo ##2}%
Page:
\makebox[2.5em][r]{\x@secondoftwo ##2}%
\hspace{4em}}\par
}
\let \bibcite \@gobbletwo
{\Large \sl Logical labels within sections}
\input{\jobname.aux}
% For second run:
%
\def \bibcite ##1##2{\par
\hbox to \textwidth{%
\hfill\makebox[2in][r]{\@lablstverb{##1}}\hspace{1em}[##2]\hspace{4em}}}
\let \newlabel \@gobbletwo
\let \@writefile \@gobbletwo
\par
\vspace{2\baselineskip}
{\Large \sl Bibliography logical labels}
\input{\jobname.aux}\clearpage
}
这似乎也适用于超链接。