%November 1994, %Paradigm: plain's item extended %C.G. van der laan, cgl@rc.service.rig.nl \input blue.tex \loadtocmacros \loadindexmacros\preindex{\head{Index}} \tolerance500\hbadness=499\hfuzz=5pt \parindent=1pc \everyverbatim{\emc} \bluetitle Paradigms: Plain's \cs{item}-s extended \blueissue \maps{94}2 {\small revision March \on1996} \beginscript \bluehead A new series Hi folks. After having given birth to BLUe's Format\Dash yes YAF, yet another format, to paraphrase YACC\Dash I considered it of general interest to spread gems to the world outside via MAPS and hopefully via TTN's `Hey \Dash{} It works' column. The reason for me doing so is that apparently trivial design aspects need careful attention in this macro expansion branch of software engineering. We have to start allover from the basics---slowly and carefully---and end up with paradigms of macro expansion coding. I intend a series of backside of the envelope contributions. \bluehead BLUe's Design I ^^|\item| When you like plain's \cs{item}-s so much as I do then this is for you. Hang on! In practice we all like bulleted \cs{item}-s and \cs{item}-s with automatic numbering and lettering. It looks like---biased by \LaTeX---that we need some |\begin| and |\end| to begin and end. Not so! It can be done simpler, with nearly the same minimal markup as with \cs{item}. The extra is to end the list by \cs{smallbreak}, which is nearly natural.\ftn{I use \cs{smallskip} after \cs{item}-s for setting the list slightly apart from what follows. When a header follows, or you just like to end the list, say \cs{endlist} which \TeX nically ends the group.} Remember \TB~\on102, where Knuth states \beginquote `It is customary to put \cs{medskip} before and after a group of of itemized paragraphs, and to say \cs{noindent} before any closing remarks that apply to all of the cases.' \endquote I decided not to include \cs{noindent} because the list is set apart already. \bluesubhead Appetizer The coding of the bulleted item reads\ftn{\TB, exercise \on14.\on20.} \beginverbatim \def\bitem{\item{$\bullet$}} !endverbatim \bluesubhead Coding AN-items ^^|\Aitem| With automatic numbering and lettering we have to stop the automatism of increasing the counter and to reset the counter for subsequent use at the end of the list. In \cs{item} nothing special had to be done. Ending the paragraph via a blank line (or \cs{par}) was enough. We cannot modify \cs{par} locally because \cs{par} starts the replacement text of \cs{item} (and \cs{itemitem} as well). So the natural markup to let a blank line (or \cs{par}) end the list is not possible. I could not work along the remark made in \TB{} ex\on14.\on29{} either, because this goes wrong with nesting, read with the use of \cs{itemitem}. My solution is a mixture of coding borrowed from \cs{item} page \on355, \cs{beginchapter} \on418, and of \cs{d@nger} \on419{} of \TB.\ftn {The more I come to think of it the more ways of doing boil up. How to decide which one is the best?} \def\ftntxt{{\rm Do you see the extension for \cs{Aitem}?}} \beginverbatim \newcount\itemno \def\nitem{\bgroup \def\nitem{\advance\itemno1 \item{\the\prenum {\oldstyle\the\itemno }\the\postnum}} \def\smallbreak{\endgraf\egroup \smallbreak} \let\smallskip\smallbreak\nitem} \def\aitem{\bgroup\itemno96!ftn!ftntxt \def\aitem{\advance\itemno1 \item{\char\itemno.}} \def\smallbreak{\endgraf\egroup \smallbreak} \let\smallskip\smallbreak \aitem} \def\endlist{\endgraf\egroup} %and the defaults \prenum{(}\postnum{)} !endverbatim We not only have to end the paragraph(s) but also to end the scope. \blueexample Numbered and nested items \prenum{}\postnum{.} \beginverbatim Text preceding\\next line \prenum{}\postnum{.} \nitem first numbered item\\next line \itemitem- sublist\\next line \nitem second numbered item\\next line \itemitem- sublist\\next line \smallbreak Text in between\\next line \aitem first lettered item\\next line \aitem second lettered item\\next line \smallbreak Text after\\next line. !endverbatim with result \medskip Text preceding\\next line \nitem first numbered item\\next line \itemitem- sublist\\next line \nitem second numbered item\\next line \itemitem- sublist\\next line \smallbreak Text in between\\next line \aitem first lettered item\\next line \aitem second lettered item\\next line \smallbreak Text after\\ next line. \bluesubhead Enumerated items Along the same line we can add an enumerated item as follows. \beginverbatim \def\eitem{\bgroup \def\eitem##1{\item{##1}}% \def\smallbreak{\endgraf \egroup\smallbreak}% \let\smallskip\smallbreak \eitem} !endverbatim \bluesubhead Verbatim items Of late\ftn{In my tutorial flyer `Macro writing,' \on1995.} I needed a list of items with each item only verbatim texts. To use \vrt{} at the end and the beginning of each line and to add |\\| or so at the end is in the spirit of \TB, as done with \cs{displaylines}. Not bad but a nuisance to insert all those \vrt s. Another modular solution was to use \cs{bitem} and after that \beginverbatim \preverbatim{}\postverbatim{}\beginverbatim !endverbatim and to end each item entry by \thisverbatim{\catcode`\!=12 \catcode`\*=0 } \beginverbatim !endverbatim *endverbatim The minimal markup solution is to provide a \cs{verbitem} tag which assumes only verbatim text as entry. Pitfalls. The second and so on tag must begin with !verbitem.\\ The tag must appear on a line of its own.\\ End with !smallbreak. \beginverbatim \def\bitem{\begingroup \def\bitem{\item{$\bullet$}}% \def\smallbreak{\endverbatim \endgraf\endgroup\smallbreak}% \let\smallskip\smallbreak \bitem \def\item{\endverbatim%to close \par\hang\textindent}% } \def\verbitem{\bitem \preverbatim{}\postverbatim{}% \beginverbatim} !endverbatim Have fun, and all the best \makesignature \pasteuptoc \sortindex\pasteupindex \endscript