summaryrefslogtreecommitdiff
path: root/info/laan/paradigm/paradigm.itm
blob: e3e25928b917a05c3525f4dd64139a5b2db0111c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
%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<tag>| and |\end<tag>| 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