commit 57deea7d94e7e79f1dcc402403a2bd194121d0cc
parent e5a9519395f2ecb65793c06492d32d473adbdb69
Author: robert <robertrussell.72001@gmail.com>
Date: Sun, 16 Jan 2022 17:04:45 -0800
Make \Lfmt a tokens register
Mostly an code aesthetic change. Now all the parameters that control
list appearance are registers.
Diffstat:
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/list.tex b/list.tex
@@ -1,12 +1,13 @@
-% The label of each list item is derived from \Lfmt, which should be a macro
-% whose expansion optionally depends on \Llvl (the nesting level of list, where
-% 0 means not in a list, 1 means in a top-level list, etc.) and \Lcnt (the item
-% number, where 0 means before the first item, 1 means in the first item,
-% etc.). Alternatively, \Lfmt can be overridden with an explicit label on an
+% The label of each list item is derived from \Lfmt, which is a tokens list
+% optionally depending on \Llvl (the nesting level of list, where 0 means not
+% in a list, 1 means in a top-level list, etc.) and \Lcnt (the item number,
+% where 0 means before the first item, 1 means in the first item, etc.).
+% Alternatively, \Lfmt can be overridden with an explicit label on an
% item-by-item basis by using \xitem in place of \item. Each label is
% overlapped in to the ident of the first paragraph in the item. The geometry
% of a list is mostly controlled by the following parameters.
+\newtoks\Lfmt % label format, generally depends on \Llvl and \Lcnt
\newdimen\Lindent % indent of first paragraph in item
\newdimen\Lmaxprotrusion % max protrusion of item label into left margin
\newdimen\Llmargin % bring left margin in by this amount
@@ -18,15 +19,15 @@
\newcount\Lmidpenalty % penalty between items
\newcount\Lbotpenalty % penalty below list
-\newcount\Lcnt % item number within current list
\newcount\Llvl \Llvl=0 % list nesting level
+\newcount\Lcnt % item number within current list
\def\@Lbeg{%
\par
\begingroup
\Lcnt=0
\incr\Llvl
- \let\Lfmt=\empty
+ \Lfmt={}%
\advance\leftskip\Llmargin
\advance\rightskip\Lrmargin
\penalty\Ltoppenalty
@@ -41,7 +42,7 @@
\tmpparindent0pt
}
-\def\item{\@Litem\Lfmt}
+\def\item{\@Litem{\the\Lfmt}}
\def\xitem#1{\@Litem{#1\enspace}\ignorespaces}
\def\@Litem#1{%
\par
@@ -56,15 +57,15 @@
% Common list types
% TODO: some of these belong in style
\newdimen\@Lpwd
-\def\begxlist#{\@Lbeg\def\Lfmt}
+\def\begxlist#{\@Lbeg\Lfmt=}
\def\begplist#1#2#3{%
\@Lbeg
\def\csA{#3}%
\ifx\csA\empty
- \def\Lfmt{\rm(#1\/)#2}% TODO: use robust italic correction
+ \Lfmt={\rm(#1\/)#2}% TODO: use robust italic correction
\else
\maxwd\@Lpwd={#3}%
- \def\Lfmt{\rm(\hbox to\@Lpwd{\hss#1\/\hss})#2}%
+ \Lfmt={\rm(\hbox to\@Lpwd{\hss#1\/\hss})#2}%
\fi
}
\def\begnlist{\begxlist{\rm\number\Lcnt.\enspace}} % 1. 2. 3. ...