因此,每当您开始撰写文档并为其指定某个类(文章、回忆录等)时,都会使用许多默认长度和高度。我正在寻找一种无需明确查阅文档甚至源代码即可查看这些内容的方法。
我知道您可以\the\<some_name>
在正文中使用来显示文档中的值\<some_name>
。但问题是,如果您不确定变量的名称,该怎么办?
理想情况下,我正在寻找类似于\layout{}
布局包中的命令,但更通用的东西。
答案1
是的,您可以滚动浏览 .log。但那有什么乐趣呢?:)
而且,通过数字您无法知道分配的寄存器的名称,因此仅知道它包含的内容是没有多大用的。
这是一个 LaTeX 解决方案(在纯 TeX 中不起作用)。它利用了 LaTeX 的\e@alloc
宏,该宏通过内核用于分配寄存器。我在定义中添加了一些内容,\e@alloc
使其保存分配的寄存器名称。将其添加到您的文档中:
\makeatletter
\def \countlist{\@gobble}% @gobble to remove the first comma
\def \dimenlist{\@gobble}%
\def \skiplist{\@gobble}%
\def\muskiplist{\@gobble}%
\def \boxlist{\@gobble}%
\def \tokslist{\@gobble}%
\def \readlist{\@gobble}%
\def \writelist{\@gobble}%
\def\e@alloc#1#2#3#4#5#6{%
\global\advance#3\@ne
\e@ch@ck{#3}{#4}{#5}#1%
\allocationnumber#3\relax
\global#2#6\allocationnumber
\wlog{\string#6=\string#1\the\allocationnumber}%
% Until here it's unchanged
% Now we define a \reserved@a macro that will hold the name of the \<type>list
\edef\reserved@a{%
\expandafter\noexpand
\csname\expandafter\@gobble\string#1list\endcsname}%
% Now we add #6 (the allocated register) to the list
\expandafter\xdef\reserved@a{\reserved@a,#6}%
}%
\makeatother
这将在宏中“记录”已分配的寄存器\<type>list
。它仅在您插入后才会生效,因此如果您想查看文档类分配的寄存器,您需要先添加它。
因为它只影响分配的内容后重新定义,你可以t see the LaTeX kernel
使用寄存器,像这样:
\newcount\@tempcnta
\newcount\@tempcntb
\newif\if@tempswa
\newdimen\@tempdima
\newdimen\@tempdimb
\newdimen\@tempdimc
\newbox\@tempboxa
\newskip\@tempskipa
\newskip\@tempskipb
\newtoks\@temptokena
\newskip\@flushglue
现在,您可以自行决定如何处理该列表。例如,您可以打印一个表格,其中左侧是寄存器名称,右侧是其值:
\makeatletter
\def \countlist{\@gobble}% @gobble to remove the first comma
\def \dimenlist{\@gobble}%
\def \skiplist{\@gobble}%
\def\muskiplist{\@gobble}%
\def \boxlist{\@gobble}%
\def \tokslist{\@gobble}%
\def \readlist{\@gobble}%
\def \writelist{\@gobble}%
\def\e@alloc#1#2#3#4#5#6{%
\global\advance#3\@ne
\e@ch@ck{#3}{#4}{#5}#1%
\allocationnumber#3\relax
\global#2#6\allocationnumber
\wlog{\string#6=\string#1\the\allocationnumber}%
\edef\reserved@a{%
\expandafter\noexpand
\csname\expandafter\@gobble\string#1list\endcsname}%
\expandafter\xdef\reserved@a{\reserved@a,#6}%
}%
\makeatother
\documentclass{memoir}% Many allocations :)
\usepackage[T1]{fontenc}
\usepackage{etoolbox}% For the csvlist thingy
\usepackage{longtable}% To allow page breaks
\begin{document}
% Create an empty list
\newcommand\reglist{}
% Define a command \do which adds a table row to the list
\def\do#1{\appto\reglist{%
% the allocated register its value
\expandafter\string#1 & \the#1 \\}}%
% Process the \skiplist VVVVVVVVV
\expandafter\docsvlist\expandafter{\skiplist}
% Print the list
\begin{longtable}{@{\ttfamily}l@{ = }l}
\reglist
\end{longtable}
\end{document}
\@firstoffour
页数:
普通 TeX 解决方案:
基本和 LaTeX2e 一样,只是调用的宏\@alloc
有点不一样:
\catcode`@=11
\def\@gobble#1{}% plain doesn't have \@gobble
\def \countlist{\@gobble}% @gobble to remove the first comma
\def \dimenlist{\@gobble}%
\def \skiplist{\@gobble}%
\def\muskiplist{\@gobble}%
\def \boxlist{\@gobble}%
\def \tokslist{\@gobble}%
\def \readlist{\@gobble}%
\def \writelist{\@gobble}%
\def\alloc@#1#2#3#4#5{\global\advance\count1#1by\@ne
\ch@ck#1#4#2% make sure there's still room
\allocationnumber=\count1#1%
\global#3#5=\allocationnumber
\wlog{\string#5=\string#2\the\allocationnumber}%
\edef\reserved@a{%
\expandafter\noexpand
\csname\expandafter\@gobble\string#2list\endcsname}%
\expandafter\xdef\reserved@a{\reserved@a,#5}%
}
\catcode`@=12