]> mj.ucw.cz Git - ucwmac.git/commitdiff
The first attempt at new list styles
authorMartin Mares <mj@ucw.cz>
Wed, 27 Jun 2018 09:38:33 +0000 (11:38 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 27 Jun 2018 09:39:06 +0000 (11:39 +0200)
test.tex
ucwmac2.tex

index db93c0c87e3a35b1d3a0521ac36309a1f82dee42..cf42d0ae690dbadf6f2cb1d1a5b733ebc5d56116 100644 (file)
--- a/test.tex
+++ b/test.tex
 
 \noindent An~itemized list:
 
+\list{n)}
+\:primo
+\:secundo
+\:tertio
+\endlist
+
 \itemize\ibull
 \:It is an {\I important and popular fact} that things are not always what
 they seem.  For instance, on the planet Earth, man had always assumed
index 90dd753bb86c4967614e6d4f7b881c7f601ac779..131ae11d195bfbdc82177de4b6c3551b981cce27 100644 (file)
 
 % Usage:
 %
+% \list{style}
+% \:first item
+% \:second item
+% \endlist
+%
+% Available styles (others can be defined by \sdef{item:<style>}{<marker>})
+%
+%      o               % bullet
+%      O               % empty circle
+%      *               % asterisk
+%      -               % en-dash
+%      .               % dot
+%      n               % 1, 2, 3
+%      i               % i, ii, iii
+%      I               % I, II, III
+%      a               % a, b, c
+%      A               % A, B, C
+%      g               % α, β, γ
+%
+% Meta-styles (can be used to modify an arbitrary style, currently hard-wired)
+%
+%      #.              % with a dot behind
+%      #)              % with a parenthesis behind
+%      (#)             % enclosed in parentheses
+%
+% Historic usage:
+%
 % \itemize\ibull       % or other marker
 % \:first item
 % \:second item
 
 \def\inititemize{\begingroup\preitemize\itemstrue\parindent=0pt}
 
+\def\list#1{\inititemize\itemcount=0\liststyle{#1}\let\:=\listitem}
+\def\listitem{\par\leavevmode\advance\itemcount by 1
+       \llap{\listmarker\hskip\itemmarkerskip}\ignorespaces}
+
+\def\liststyle#1{%
+       \edef\markertmp{#1}
+       \ifcsname item:\markertmp\endcsname
+               \slet{listmarker}{item:\markertmp}%
+       \else
+               \slet{listmarker}{metaitem:\markertometa#1^^X}%
+               \slet{markerinner}{item:\markertoinner#1^^X}%
+       \fi
+}
+
+\def\markertometa#1{%
+       \ifx#1^^X
+       \else
+               \ifx#1((%
+               \else\ifx#1))%
+               \else\ifx#1..%
+               \else=%
+               \fi\fi\fi
+               \expandafter\markertometa
+       \fi
+}
+
+\def\markertoinner#1{%
+       \ifx#1^^X
+       \else
+               \ifx#1(%
+               \else\ifx#1)%
+               \else\ifx#1.%
+               \else#1%
+               \fi\fi\fi
+               \expandafter\markertoinner
+       \fi
+}
+
 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip\itemmarkerskip}%
 \let\:=\singleitem}
 
 \zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
 \or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
 
+% List styles
+\sdef{item:o}{\raise0.2ex\hbox{$\bullet$}}
+\sdef{item:O}{\raise0.2ex\hbox{$\circ$}}
+\sdef{item:*}{\raise0.2ex\hbox{$\ast$}}
+\sdef{item:-}{--}
+\sdef{item:.}{\raise0.2ex\hbox{$\cdot$}}
+\sdef{item:n}{\the\itemcount}
+
+% List meta-styles
+\sdef{metaitem:=.}{\markerinner.}
+\sdef{metaitem:=)}{\markerinner)}
+\sdef{metaitem:(=)}{(\markerinner)}
+
 %%% Miscellanea %%%
 
 % {\I italic} with automatic italic correction