r3tex

custom LuaTeX format
git clone git://git.rr3.xyz/r3tex
Log | Files | Refs | README | LICENSE

commit 791ade53da1a3bd37bc055ebe956fc0c8f3adfd5
parent 14fc068001e2f1ca829fff47a24f8a2e3f84a188
Author: robert <robertrussell.72001@gmail.com>
Date:   Sun, 16 Jan 2022 10:31:14 -0800

Add versatile, low-level list macros

Some reorganization is required. The r3tex core should not make any
style decisions. It should merely provide the low-level tools for, in
this case, making lists of various styles. Then style files should
define appropriate list macros based on the low-level macros provided by
r3tex. Of course, multiple styles may wish to use the same types of
lists, in which case styles can be composed.

Diffstat:
Alist.tex | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mr3tex.tex | 2+-
2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/list.tex b/list.tex @@ -0,0 +1,73 @@ +% Derive bullet from \Lfmt based on \Lcnt, which is incremented per item. + +\newcount\Lcnt % item number within current list +\newcount\Llvl \Llvl=0 % list nesting level + +\newdimen\Lindent % indent of first paragraph in item +\newdimen\Lmaxprotrusion % max protrusion of item label +\newdimen\Llmargin % bring left margin in by this amount +\newdimen\Lrmargin % bring right margin in by this amount +\newskip\Ltopskip % vskip above list +\newskip\Lmidskip % vskip between items +\newskip\Lbotskip % vskip below list +\newcount\Ltoppenalty +\newcount\Lmidpenalty +\newcount\Lbotpenalty + +\def\@Lbeg{% + \par + \begingroup + \Lcnt=0 + \incr\Llvl + \let\Lfmt=\empty + \advance\leftskip\Llmargin + \advance\rightskip\Lrmargin + \penalty\Ltoppenalty + \vskip\Ltopskip +} + +\def\@Lend{% + \par + \endgroup + \penalty\Lbotpenalty + \vskip\Lbotskip + \tmpparindent0pt +} + +\def\item{\@Litem\Lfmt} +\def\xitem#1{\@Litem{#1\enspace}\ignorespaces} +\def\@Litem#1{% + \par + \ifnum\Lcnt>0 \penalty\Lmidpenalty \vskip\Lmidskip \fi + \incr\Lcnt + \setbox0=\hbox{#1}% + \dimen1=\dimexpr\wd0-\Lmaxprotrusion\relax + \dimen0=\ifdim\Lindent<\dimen1 \dimen1 \else \Lindent \fi + \noindent\hbox to\dimen0{\hss\box0}% +} + +% Common list types +% TODO: some of these belong in style +\newdimen\@Lpwd +\def\begxlist#{\@Lbeg\def\Lfmt} +\def\begplist#1#2#3{% + \@Lbeg + \def\csA{#3}% + \ifx\csA\empty + \def\Lfmt{\rm(#1\/)#2}% TODO: use robust italic correction + \else + \maxwd\@Lpwd={#3}% + \def\Lfmt{\rm(\hbox to\@Lpwd{\hss#1\/\hss})#2}% + \fi +} +\def\begnlist{\begxlist{\rm\number\Lcnt.\enspace}} % 1. 2. 3. ... +\def\begrlist{\begplist{\rm\romannumeral\Lcnt}{\enspace}} % (i) (ii) (iii) ... +\def\begalist{\begplist{\rm\char\numexpr\Lcnt+96\relax}{\enspace}} % (a) (b) (c) ... +\def\begblist{\begxlist{$\m@th\bullet$\enspace}} % bullets + +\def\begol{\begnlist} +\def\endol{\@Lend} +\def\begul{\begblist} +\def\endul{\@Lend} + +\endinput diff --git a/r3tex.tex b/r3tex.tex @@ -10,7 +10,7 @@ % \input margin % \input font % \input section -% \input list +\input list % \input verbatim % \input hyphen % \input graphics