strc-itm.mklx /size: 81 Kb    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=strc-itm,
3%D        version=2008.10.20,
4%D          title=\CONTEXT\ Structure Macros,
5%D       subtitle=Itemgroups,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Structure Macros / Itemgroups}
15
16\unprotect
17
18\newdimension\d_strc_itemgroups_max_width
19\newinteger  \c_strc_itemgroups_max_items
20
21\registerctxluafile{strc-itm}{autosuffix}
22
23%D As we analyze/register widths and such we could as well push and pop the numbers
24%D at the \LUA\ end (which saves a few calls).
25%D
26%D Cleaning up this module happened around the time when Kate Bush came up with the
27%D nicest numbered list of words: 50 Words For Snow. It's therefore no surprise that
28%D I had that cd running several times when updating this code. One of the
29%D highlights of 2011.
30%D
31%D This module needs to be rewritten but that is tricky with respect to
32%D compatibilitity. Basically each major variant (regular, text, columns,
33%D horizontal, etc) needs to be on its own.
34
35% todo: check breaks
36% todo: check grouping
37% todo: fixedconversion
38
39% \startitemize[n,packed]
40% \item test \item test \item test
41% \stopitemize
42%
43% \startitemize[n,packed,reverse]
44% \item test \item test \item test
45% \stopitemize
46%
47% \startitemize[n,packed,reverse] \item test \item test \stopitemize
48% \startitemize[continue]
49% \item test \startitemize[n,packed] \item test \item test \stopitemize
50% \item test
51% \item test
52% \stopitemize
53% \startitemize[continue] \item test \stopitemize
54%
55% \startitemize[n,packed] \item test \item test \stopitemize
56% \startitemize[continue] \item test            \stopitemize
57% \startitemize[continue] \item test            \stopitemize
58%
59% \setupwhitespace[big]
60% \starttext
61%     test \startitemize[joinedup]                \item test \item test \stopitemize test \par
62%     test \startitemize[joinedup,nowhite]        \item test \item test \stopitemize test \par
63%     test \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize test \par
64%     test \startitemize[joinedup,nowhite,after]  \item test \item test \stopitemize test \par
65% \stoptext
66%
67% test / example
68%
69% \startnarrower[left] \startcolumns[n=3] \startitemize
70% \item \input ward \item \input ward \item \input ward
71% \stopitemize \stopcolumns\stopnarrower \blank
72%
73% \startnarrower[left] \startitemize[columns,three]
74% \item \input ward \item \input ward \item \input ward
75% \stopitemize \stopnarrower \blank
76%
77% \setupitemize[leftmargin=1.5em] \startitemize[columns,three]
78% \item \input ward \item \input ward \item \input ward
79% \stopitemize \blank
80%
81% beware, we don't group (yet) as we want to keep the left/right skip
82%
83% \startitemize
84% \startitem \stopitem
85% some intermediate text that will properly indent
86% \startitem \stopitem
87% \stopitem
88%
89% so we need to keep that property
90%
91% \startitemize
92%   \starthead {xx} test \stophead
93%   \startitem test \stopitem
94%   \startitem test \stopitem
95% \stopitemize
96%
97% Sometimes the user demands get pretty weird:
98%
99% \startitemize
100%   \item test
101%   \item test
102%   \headsym{xx} test \par test
103% \stopitemize
104%
105% aligned items
106%
107% \startitemize[n,fit,broad][itemalign=flushright]
108%      \dorecurse{100}{\item The first item.}
109% \stopitemize
110%
111% \setupitemgroup[itemize][each][fit]
112% \setupitemgroup[itemize][each][distance=.5em,factor=1,itemalign=flushright]
113%
114% \startitemize[n]
115%      \dorecurse{100}{\item The first item.}
116% \stopitemize
117%
118% \defineitemgroup[gbitemize]
119% \setupitemgroup[gbitemize][each][headstyle=bold]
120%
121% \startgbitemize
122% \txt{italian} some italians like this kind of cross||breed between
123%   an itemize and a description
124% \txt{sicilians} i wonder how many sicilian mathematicians do a thesis
125%   on the math involved in predicting the next big bang of the vulcano
126% \stopgbitemize
127%
128% \startitemize[n,repeat]
129%     \noitem \startitemize[a] \item Item 1.a. \item Item 1.b. \stopitemize
130%     \noitem \startitemize[a] \item Item 2.a. \item Item 2.b. \stopitemize
131% \stopitemize
132%
133% \startitemize[n,repeat][width=0pt]
134%   \noitem \startitemize[a][width=2em] \item Item 1.a. \item Item 1.b. \stopitemize
135%   \noitem \startitemize[a][width=2em] \item Item 2.a. \item Item 2.b. \stopitemize
136% \stopitemize
137%
138% \startbuffer
139% \item
140%   \startitemize[n]
141%   \item item 1.1
142%   \item item 1.2
143%   \startitemize[n] \item item 1.2.1 \item item 1.2.2 \stopitemize
144%   \item item 1.3
145%   \stopitemize
146% \item
147%   \startitemize[n] \item item 2.1 \item item 2.2 \stopitemize
148% \item item 3
149%   \startitemize[n] \item item 3.1 \item item 3.2 \stopitemize
150% \item
151%   \startitemize[n] \item item 4.1 \item item 4.2 \stopitemize
152% \stopbuffer
153%
154% \startitemize[n,repeat,6*broad,packed] \getbuffer \stopitemize \blank[3*big]
155% \startitemize[n,repeat,packed]         \getbuffer \stopitemize \blank[3*big]
156% \setupitemize[each][atmargin][width=3em]
157% \startitemize[n,repeat,packed]         \getbuffer \stopitemize
158%
159% todo: assume startitem ... stopitem and do an autostopitem .. cleaner for
160% elements
161%
162% \startitemize[text][space=medium]
163% \item one \item two \item three
164% \stopitemize
165%
166% For Giuseppe "Oblomov" Bilotta, inspired on a suggestion by Taco
167% Hoekwater.
168%
169% \def\MyItemCommand#1{{\bf#1}\quad}
170% \setupitemgroup[itemize][command=\MyItemCommand]
171%
172% \startitemize
173% \item {test} is this okay?
174% \item {test} is this okay?
175% \item {test} is this okay?
176% \stopitemize
177
178\newconditional\c_strc_itemgroups_sub
179\newconditional\c_strc_itemgroups_head
180\newconditional\c_strc_itemgroups_intro
181\newconditional\c_strc_itemgroups_randomize
182\newconditional\c_strc_itemgroups_horizontal
183\newconditional\c_strc_itemgroups_collecting
184\newconditional\c_strc_itemgroups_auto_intro
185\newconditional\c_strc_itemgroups_pack
186\newconditional\c_strc_itemgroups_paragraph
187\newconditional\c_strc_itemgroups_text
188\newconditional\c_strc_itemgroups_no_par
189\newconditional\c_strc_itemgroups_text_saved
190\newconditional\c_strc_itemgroups_first
191\newconditional\c_strc_itemgroups_before
192\newconditional\c_strc_itemgroups_after
193\newconditional\c_strc_itemgroups_nowhite
194\newconditional\c_strc_itemgroups_joined
195\newconditional\c_strc_itemgroups_reverse
196\newconditional\c_strc_itemgroups_continue
197\newconditional\c_strc_itemgroups_fitting
198\newconditional\c_strc_itemgroups_indented_first
199\newconditional\c_strc_itemgroups_inline
200\newconditional\c_strc_itemgroups_columns
201\newconditional\c_strc_itemgroups_concat
202\newconditional\c_strc_itemgroups_txt
203\newconditional\c_strc_itemgroups_extra
204\newconditional\c_strc_itemgroups_repeat
205\newconditional\c_strc_itemgroups_inline_head
206\newconditional\c_strc_itemgroups_symbol
207\newconditional\c_strc_itemgroups_overlay
208
209% 0 = before/after
210% 1 = between unless before
211% 2 = between (auto)
212
213\newconstant   \c_strc_itemgroups_spacing_mode   \c_strc_itemgroups_spacing_mode\plustwo
214\newconditional\c_strc_itemgroups_auto_concat    \c_strc_itemgroups_auto_concat \conditionaltrue
215
216% 0=loose 1=tight 2=verytight
217
218\newinteger    \c_strc_itemgroups_optimize       \c_strc_itemgroups_optimize\plusone % tight
219
220\newboundary   \c_strc_itemgroups_boundary
221\newbox        \b_strc_itemgroups
222
223\newdimension  \d_strc_itemgroups_list_width
224\newdimension  \d_strc_itemgroups_asked_width
225
226%newdimension  \d_strc_itemgroups_max_width % defined already, used at the Lua end
227%newinteger    \c_strc_itemgroups_max_items % idem
228
229\def\d_strc_itemgroups_max_width_reference{\d_strc_itemgroups_max_width} % no alias!
230
231\newinteger    \c_strc_itemgroups_n_of_items
232\newinteger    \c_strc_itemgroups_nesting
233\newinteger    \c_strc_itemgroups_column_depth
234
235\def           \v_strc_itemgroups_counter        {itemgroup:\currentparentitemgroup}
236\lettonothing  \m_strc_itemgroups_repeat_start
237\def           \v_strc_itemgroups_unknown_symbol {?}
238\lettonothing  \m_strc_itemgroups_indenting
239\lettonothing  \m_strc_itemgroups_destination
240
241\mutable\let   \currentitemlevel                 \!!zerocount % public
242\mutable\def   \currentnofitems                  {\the\c_strc_itemgroups_max_items}
243\mutable\def   \currentitemindex                 {\the\c_strc_itemgroups_n_of_items}
244\mutable\def   \currentitemnumber                {\strc_counters_raw_sub\v_strc_itemgroups_counter\currentitemlevel} % public
245
246\newtoks       \itemgroupcommands                % maybe public
247
248\mutable\def          \currentitemgroupsymbol        {n} % here we cannot use a _ in the name
249\mutable\lettonothing \currentitemgroupconversionset     % here we cannot use a _ in the name
250\mutable\lettonothing \currentitemgroupsegments
251
252\def\strc_itemgroups_register_status
253  {\clf_registeritemgroup{\currentparentitemgroup}\c_strc_itemgroups_nesting\c_strc_itemgroups_n_of_items\dimexpr\itemgroupparameter\c!maxwidth\relax}
254
255\def\strc_itemgroups_check_n_of_items % we could do this at the lua end and save a call (i.e. will be dimen and counter)
256  {\clf_analyzeitemgroup{\currentparentitemgroup}\c_strc_itemgroups_nesting\relax
257   \edef\currentnofitems{\the\c_strc_itemgroups_max_items}}
258
259% todo: \dodosetreference -> \strc_counters_register_component (to be checked)
260
261\def\strc_itemgroups_insert_reference % we will make a decent number helper
262  {\iftrialtypesetting \orelse \ifempty\currentitemreference \else
263     \strc_itemgroups_insert_reference_indeed
264   \fi}
265
266\def\strc_itemgroups_insert_extra_reference
267  {\iftrialtypesetting \orelse \ifempty\currentitemreference \else
268     \normalexpanded{\textreference[\currentitemreference]{\strc_itemgroups_extra_symbol}}%
269   \fi}
270
271\def\strc_itemgroups_insert_reference_indeed % maybe we need a 'frozen counter' numberdata blob / quick hack .. .mive this to strc-ref
272  {% needs testing, gave problems:
273   \setnextinternalreference
274   % no need to collect nodes in \b_strc_destination_nodes here ... maybe at some point
275   \strc_references_start_destination_nodes
276   % this is somewhat over the top ... we should use the counter's reference
277   \clf_setdestinationattribute
278     {%
279         metadata {%
280             kind            {item}% was item, why?
281         \ifx\currentreferencecoding\s!xml
282             xmlroot         {\xmldocument}% only useful when text
283         \fi
284             catcodes        \catcodetable
285         }%
286         references {%
287             internal        \locationcount % no: this spoils references
288           % block           {\currentsectionblock}%
289             view            {\interactionparameter\c!focus}%
290             prefix          {\referenceprefix}%
291             reference       {\currentitemreference}%
292         }%
293         prefixdata {%
294             prefix          {\namedcounterparameter\v_strc_itemgroups_counter\c!prefix}%
295             separatorset    {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixseparatorset}%
296             conversion      {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversion}%
297             conversionset   {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversionset}%
298             set             {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixset}%
299             segments        {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixsegments}%
300           % segments        {\askedprefixsegments}%
301             connector       {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconnector}%
302         }%
303         numberdata {%
304             numbers         {\v_strc_itemgroups_counter}%
305             separatorset    {\namedcounterparameter\v_strc_itemgroups_counter\c!numberseparatorset}%
306           % conversion      {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversion}%
307           % conversionset   {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversionset}%
308           % fixedconversion {\currentitemgroupconversionset}%
309             conversionset   {fixed::\currentitemgroupconversionset}% temp hack
310           %
311           % for the moment no stopper, we need to make references configurable first
312           % stopper         {\namedcounterparameter\v_strc_itemgroups_counter\c!numberstopper}%
313             segments        {\namedcounterparameter\v_strc_itemgroups_counter\c!numbersegments}%
314         }%
315     }%
316   \relax
317   \strc_references_stop_destination_nodes
318   \xdef\currentdestinationattribute{\number\lastdestinationattribute}%
319   % will become an option:
320   \ifnum\lastdestinationattribute>\zerocount
321     \dontleavehmode\hbox attr \destinationattribute\lastdestinationattribute\bgroup
322       \strc_references_flush_destination_nodes
323     \egroup
324   \fi}
325
326%D Defining and setup:
327
328\installcorenamespace{itemgroup}
329\installcorenamespace{itemgroupoption}
330\installcorenamespace{itemgroupsetting}
331\installcorenamespace{itemgroupkeyword}
332\installcorenamespace{itemgroupalign}
333\installcorenamespace{itemgrouplocal}
334\installcorenamespace{itemgroupglobal}
335\installcorenamespace{itemgroupdistance}
336\installcorenamespace{itemgroupstack}
337\installcorenamespace{itemgroupfirst}
338\installcorenamespace{itemgroupstart}
339
340\installcommandhandler \??itemgroup {itemgroup} \??itemgroup
341
342\aliased\let\setupitemgroups\setupitemgroup
343
344\appendtoks
345    \frozen\instance\protected\edefcsname\e!start\currentitemgroup           \endcsname{\startitemgroup[\currentitemgroup]}%
346    \frozen\instance\protected\edefcsname\e!stop \currentitemgroup           \endcsname{\stopitemgroup}%
347    \frozen\instance\protected\edefcsname\e!setup\currentitemgroup\e!endsetup\endcsname{\setupitemgroup[\currentitemgroup]}% obsolete
348    \let\currentparentitemgroup\currentitemgroup
349    \definecounter[\v_strc_itemgroups_counter]%
350\to \everydefineitemgroup
351
352%D Global states
353
354\def\strc_itemgroups_store_continue_state#options#settings%
355   {\xdefcsname\??itemgroupoption \currentitemgroup\endcsname{\strc_itemgroups_process_options{#options}}%
356    \gdefcsname\??itemgroupsetting\currentitemgroup\endcsname{\setupcurrentitemgroup[#settings]}}
357
358\def\strc_itemgroups_fetch_continue_state
359  {\csname\??itemgroupoption \currentitemgroup\endcsname
360   \csname\??itemgroupsetting\currentitemgroup\endcsname}
361
362\def\strc_itemgroups_reset_continue_state
363  {\gletcsname\??itemgroupoption \currentitemgroup\endcsname\relax
364   \gletcsname\??itemgroupsetting\currentitemgroup\endcsname\relax}
365
366% These will become keywords. We will also add a feature to keep the while set
367% together.
368
369\definevspacing[\v!item @\v!no]        [penalty:0]     % allow
370\definevspacing[\v!item @\v!yes]       [penalty:10000] % never
371\definevspacing[\v!item @\v!tight]     [penalty:500]   % discourage
372\definevspacing[\v!item @\v!verytight] [penalty:5000]  % discourage more
373
374\definevspacing[\v!item @-5] [penalty:-5]
375\definevspacing[\v!item @5]  [penalty:5]
376
377\def\strc_itemgroups_insert_break_when_needed#break%
378  {\ifcase\c_strc_itemgroups_optimize
379     % loose
380   \orelse\ifconditional\c_strc_itemgroups_text
381     % horizontal
382   \else
383     #break\relax
384   \fi}
385
386\def\strc_itemgroups_insert_breakallow{\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_breakallow_indeed}
387\def\strc_itemgroups_insert_breakno   {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_breakno_indeed   }
388\def\strc_itemgroups_insert_break     {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_break_indeed     }
389\def\strc_itemgroups_insert_nobreak   {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_nobreak_indeed   }
390
391\def\strc_itemgroups_insert_breakallow_indeed
392  {\vspacing[\v!item @\v!no]}
393
394\def\strc_itemgroups_insert_breakno_indeed
395  {\vspacing[\v!item @\v!yes]}
396
397\def\strc_itemgroups_insert_break_indeed
398  {\flushnotes
399   \vspacing[\v!item @-5]}
400
401\def\strc_itemgroups_insert_nobreak_indeed
402  {\flushnotes
403   \ifinsidecolumns % todo
404     \vspacing[\v!item @5]%
405   \orelse\ifcase\c_strc_itemgroups_optimize
406   \or
407     % tight
408     \vspacing[\v!item @\v!tight]%
409   \else
410     % verytight
411     \vspacing[\v!item @\v!verytight]%
412   \fi}
413
414\protected\def\strc_itemgroups_process_options#options%
415  {\processcommacommand[#options]\strc_itemgroups_process_option} % expansion of options is handy for xml
416
417% \installcommalistprocessorcommand \strc_itemgroups_process_option_list \strc_itemgroups_process_option
418%
419% \protected\def\strc_itemgroups_process_options#options%
420%   {\normalexpanded{\strc_itemgroups_process_option_list[#options]}} % expansion of options is handy for xml
421
422\mutable\lettonothing\itemgroupfirst
423\mutable\lettonothing\itemgroupsecond
424
425\def\strc_itemgroups_process_option#option%
426  {\edef\scratchstringone{#option}%
427   \ifempty\scratchstringone\else
428     \splitatasterisk\scratchstringone\itemgroupfirst\itemgroupsecond
429     \ifempty\itemgroupsecond
430        \let\itemgroupsecond\itemgroupfirst
431        \let\itemgroupfirst\!!plusone
432     \fi
433     \ifcsname\??itemgroupkeyword\itemgroupsecond\endcsname
434       \lastnamedcs
435     \else
436       \strc_itemgroups_set_symbol\scratchstringone
437     \fi
438   \fi}
439
440\def\strc_itemgroups_process_set_option_pack
441  {\ifcase\c_strc_itemgroups_nesting \else
442     \c_strc_itemgroups_pack\conditionaltrue
443   \fi}
444
445\def\strc_itemgroups_process_set_option_unpack
446  {\ifcase\c_strc_itemgroups_nesting\else
447     \c_strc_itemgroups_pack\conditionalfalse
448   \fi}
449
450\defcsname\??itemgroupkeyword\!!zerocount\endcsname
451  {} % ignore 0
452
453\defcsname\??itemgroupkeyword\v!packed\endcsname
454  {\strc_itemgroups_process_set_option_pack}
455
456\defcsname\??itemgroupkeyword\v!unpacked\endcsname
457  {\strc_itemgroups_process_set_option_unpack}
458
459\defcsname\??itemgroupkeyword\v!intro\endcsname
460  {\c_strc_itemgroups_intro\conditionaltrue} % here? not set to false
461
462\defcsname\??itemgroupkeyword\v!autointro\endcsname
463  {\c_strc_itemgroups_auto_intro\conditionaltrue}
464
465\defcsname\??itemgroupkeyword\v!broad\endcsname
466  {\ifempty\itemgroupfirst
467     \let\itemgroupfirst\!!plusone
468   \fi
469   \letitemgroupparameter\c!factor\itemgroupfirst}
470
471\defcsname\??itemgroupkeyword\v!text\endcsname
472  {\c_strc_itemgroups_text\conditionaltrue
473   \c_strc_itemgroups_inline\conditionaltrue
474   \c_strc_itemgroups_joined\conditionaltrue
475   \strc_itemgroups_process_set_option_pack}
476
477\defcsname\??itemgroupkeyword\v!before\endcsname
478  {\c_strc_itemgroups_before\conditionaltrue}
479
480\defcsname\??itemgroupkeyword\v!after\endcsname
481  {\c_strc_itemgroups_after\conditionaltrue}
482
483\defcsname\??itemgroupkeyword\v!nowhite\endcsname
484  {\c_strc_itemgroups_nowhite\conditionaltrue}
485
486\defcsname\??itemgroupkeyword\v!margin\endcsname % signal
487  {\setitemgroupparameter\c!width{-2em}}
488
489\defcsname\??itemgroupkeyword\v!inmargin\endcsname % signal
490  {\setitemgroupparameter\c!width{-2em}}
491
492\defcsname\??itemgroupkeyword\v!atmargin\endcsname% signal
493  {\ifnum\c_strc_itemgroups_nesting>\plusone
494     \setitemgroupparameter\c!width{0em}%
495   \fi}
496
497\defcsname\??itemgroupkeyword\v!intext\endcsname
498  {\c_strc_itemgroups_inline\conditionaltrue}
499
500\defcsname\??itemgroupkeyword\v!headintext\endcsname
501  {\c_strc_itemgroups_inline_head\conditionaltrue}
502
503\defcsname\??itemgroupkeyword\v!loose\endcsname
504  {\c_strc_itemgroups_optimize\zerocount}
505
506\defcsname\??itemgroupkeyword\v!tight\endcsname % new per 2023-07-16
507  {\c_strc_itemgroups_optimize\plusone}
508
509\defcsname\??itemgroupkeyword\v!verytight\endcsname % new per 2023-07-16
510  {\c_strc_itemgroups_optimize\plustwo}
511
512\defcsname\??itemgroupkeyword\v!tight:\v!first\endcsname % new per 2023-07-16
513  {\c_strc_itemgroups_optimize\plusthree}
514
515\defcsname\??itemgroupkeyword\v!tight:\v!last\endcsname % new per 2023-07-16
516  {\c_strc_itemgroups_optimize\plusfour}
517
518\defcsname\??itemgroupkeyword\v!fit\endcsname
519  {\c_strc_itemgroups_fitting\conditionaltrue}
520
521\defcsname\??itemgroupkeyword\v!nofit\endcsname
522  {\c_strc_itemgroups_fitting\conditionalfalse}
523
524\defcsname\??itemgroupkeyword\v!paragraph\endcsname
525  {\c_strc_itemgroups_paragraph\conditionaltrue
526   \strc_itemgroups_process_set_option_pack}
527
528\defcsname\??itemgroupkeyword\v!joinedup\endcsname
529  {\c_strc_itemgroups_joined\conditionaltrue
530   \strc_itemgroups_process_set_option_pack}
531
532\defcsname\??itemgroupkeyword\v!notjoinedup\endcsname
533  {\c_strc_itemgroups_joined\conditionalfalse}
534
535\defcsname\??itemgroupkeyword\v!serried\endcsname
536  {\edef\itemgroupfirst{-\ifempty\itemgroupfirst1\else\itemgroupfirst\fi}%
537   \letitemgroupparameter\c!factor\itemgroupfirst}
538
539\defcsname\??itemgroupkeyword\v!stopper\endcsname
540  {\letitemgroupparameter\c!placestopper\v!yes} % keep {}
541
542\defcsname\??itemgroupkeyword\v!nostopper\endcsname
543  {\letitemgroupparameter\c!placestopper\v!no} % keep {}
544
545\defcsname\??itemgroupkeyword\v!repeat\endcsname
546  {\c_strc_itemgroups_repeat\conditionaltrue}
547
548\defcsname\??itemgroupkeyword\v!norepeat\endcsname
549  {\c_strc_itemgroups_repeat\conditionalfalse}
550
551\defcsname\??itemgroupkeyword\v!reverse\endcsname
552  {\c_strc_itemgroups_reverse\conditionaltrue}
553
554\defcsname\??itemgroupkeyword\v!columns\endcsname
555  {\c_strc_itemgroups_columns\conditionaltrue}
556
557\defcsname\??itemgroupkeyword\v!overlay\endcsname
558  {\c_strc_itemgroups_overlay\conditionaltrue}
559
560\defcsname\??itemgroupkeyword\v!one  \endcsname{\letitemgroupparameter\c!n\plusone}
561\defcsname\??itemgroupkeyword\v!two  \endcsname{\letitemgroupparameter\c!n\plustwo}
562\defcsname\??itemgroupkeyword\v!three\endcsname{\letitemgroupparameter\c!n\plusthree}
563\defcsname\??itemgroupkeyword\v!four \endcsname{\letitemgroupparameter\c!n\plusfour}
564\defcsname\??itemgroupkeyword\v!five \endcsname{\letitemgroupparameter\c!n\plusfive}
565\defcsname\??itemgroupkeyword\v!six  \endcsname{\letitemgroupparameter\c!n\plussix}
566\defcsname\??itemgroupkeyword\v!seven\endcsname{\letitemgroupparameter\c!n\plusseven}
567\defcsname\??itemgroupkeyword\v!eight\endcsname{\letitemgroupparameter\c!n\pluseight}
568\defcsname\??itemgroupkeyword\v!nine \endcsname{\letitemgroupparameter\c!n\plusnine}
569
570\defcsname\??itemgroupkeyword\v!standard\endcsname
571  {\setitemgroupparameter  \c!width        {1.5\emwidth}%
572   \setitemgroupparameter  \c!distance     {.5\emwidth}%
573  %\letitemgroupparameter  \c!factor       \!!zerocount
574   \letitemgroupparameter  \c!factor       {\zerocount}%
575   \setitemgroupparameter  \c!packcriterium{\zerocount}%
576   \resetitemgroupparameter\c!inner
577   \resetitemgroupparameter\c!beforehead
578   \letitemgroupparameter  \c!afterhead    \blank
579   \letitemgroupparameter  \c!before       \blank
580   \letitemgroupparameter  \c!inbetween    \blank
581   \letitemgroupparameter  \c!after        \blank}
582
583\def\strc_itemgroups_initialize_local
584  {\c_strc_itemgroups_inline\conditionalfalse
585   \c_strc_itemgroups_concat\conditionalfalse
586   \c_strc_itemgroups_txt\conditionalfalse
587   \c_strc_itemgroups_no_par\conditionalfalse
588   %
589   \c_strc_itemgroups_reverse\conditionalfalse
590   \c_strc_itemgroups_intro\conditionalfalse
591   \c_strc_itemgroups_auto_intro\conditionalfalse
592   \c_strc_itemgroups_before\conditionalfalse
593   \c_strc_itemgroups_after\conditionalfalse
594   \c_strc_itemgroups_nowhite\conditionalfalse
595   \c_strc_itemgroups_randomize\conditionalfalse
596   \c_strc_itemgroups_horizontal\conditionalfalse
597   \c_strc_itemgroups_collecting\conditionalfalse
598   \c_strc_itemgroups_intro\conditionalfalse
599   \c_strc_itemgroups_continue\conditionalfalse
600   % this will be a constant
601   \c_strc_itemgroups_head\conditionalfalse
602   \c_strc_itemgroups_sub\conditionalfalse
603   \c_strc_itemgroups_symbol\conditionalfalse
604   \c_strc_itemgroups_columns\conditionalfalse
605   \c_strc_itemgroups_overlay\conditionalfalse
606   % to be checked
607   \lettonothing\m_strc_itemgroups_destination
608   \lettonothing\strc_itemgroups_used_symbol   % ** start value
609   \lettonothing\strc_itemgroups_margin_symbol
610   \lettonothing\strc_itemgroups_extra_symbol
611   %
612   \global\letitemgroupparameter\c!maxwidth\!!zeropoint
613   }
614
615\defcsname\??itemgroupfirst\v!intro\endcsname
616  {\c_strc_itemgroups_intro\conditionaltrue}
617
618\defcsname\??itemgroupfirst\v!continue\endcsname
619  {\c_strc_itemgroups_continue\conditionaltrue}
620
621\defcsname\??itemgroupfirst\v!random\endcsname
622  {\c_strc_itemgroups_randomize\conditionaltrue
623   \c_strc_itemgroups_collecting\conditionaltrue}
624
625\defcsname\??itemgroupkeyword\v!horizontal\endcsname
626  {\c_strc_itemgroups_horizontal\conditionaltrue
627   \c_strc_itemgroups_collecting\conditionaltrue
628   \c_strc_itemgroups_inline\conditionaltrue
629   \c_strc_itemgroups_joined\conditionaltrue
630   \strc_itemgroups_process_set_option_pack}
631
632\def\strc_itemgroups_preset_stage_one#options%
633  {\processcommacommand[#options]\strc_itemgroups_preset_stage_one_indeed}
634
635% \installcommalistprocessorcommand \strc_itemgroups_preset_stage_one_list \strc_itemgroups_preset_stage_one_indeed
636%
637% \def\strc_itemgroups_preset_stage_one#options%
638%   {\normalexpanded{\strc_itemgroups_preset_stage_one_list[#options]}}
639
640\def\strc_itemgroups_preset_stage_one_indeed#option%
641  {\ifcsname\??itemgroupfirst#option\endcsname
642     \lastnamedcs
643   \fi}
644
645\ifdefined\dotagsetitemgroup \else \aliased\let\dotagsetitemgroup\relax             \fi
646\ifdefined\dotagsetitem      \else \aliased\let\dotagsetitem     \gobbleoneargument \fi
647
648\def\strc_itemgroups_tag_start_group
649  {\dostarttaggedchained\t!itemgroup\currentparentitemgroup\??itemgroup
650   \dotagsetitemgroup}
651
652\def\strc_itemgroups_tag_stop_group
653  {\dostoptagged}
654
655\def\strc_itemgroups_before_command
656  {\ifconditional\c_strc_itemgroups_nowhite
657     \ifconditional\c_strc_itemgroups_before
658       \ifcase\c_strc_itemgroups_nesting\or\itemgroupparameter\c!before\fi
659     \else
660       \nowhitespace
661     \fi
662   \orelse\ifconditional\c_strc_itemgroups_joined
663     % \empty
664   \else
665     \itemgroupparameter\c!before
666   \fi}
667
668\def\strc_itemgroups_after_command
669  {\ifconditional\c_strc_itemgroups_nowhite
670     \ifconditional\c_strc_itemgroups_after
671       \ifcase\c_strc_itemgroups_nesting\or\itemgroupparameter\c!after\fi
672     \else
673       \nowhitespace
674     \fi
675   \orelse\ifconditional\c_strc_itemgroups_joined
676     % \empty
677   \else
678     \itemgroupparameter\c!after
679   \fi}
680
681\def\strc_itemgroups_between_command
682  {\ifconditional\c_strc_itemgroups_nowhite
683     \nowhitespace
684   \orelse\ifconditional\c_strc_itemgroups_joined
685     % \empty
686   \else
687     \itemgroupparameter\c!inbetween
688   \fi}
689
690\def\strc_itemgroups_before_head_command
691  {\ifconditional\c_strc_itemgroups_nowhite
692     \nowhitespace
693   \orelse\ifconditional\c_strc_itemgroups_joined
694     % \empty
695   \else
696     \itemgroupparameter\c!beforehead
697   \fi}
698
699\def\strc_itemgroups_after_head_command
700  {\ifconditional\c_strc_itemgroups_nowhite
701     \nowhitespace
702   \orelse\ifconditional\c_strc_itemgroups_joined
703     % \empty
704   \else
705     \itemgroupparameter\c!afterhead
706   \fi}
707
708% compatible setup command:
709
710\let\strc_itemgroups_normal_setup\setupitemgroup
711
712\permanent\overloaded\tolerant\protected\def\setupitemgroup[#S#category]#spacer[#S#levels]#spacer[#S#options]#spacer[#S#settings]% category level|each options|settings settings|options
713  {\ifarguments
714     % nothing to set up
715   \or
716     \edef\strc_itemgroups_setup_what{#levels}%
717     \strc_itemgroups_normal_setup[#category]% == settings
718   \or
719     \edef\strc_itemgroups_setup_what{#levels}%
720     \strc_itemgroups_setup_each{#category}{#levels}%
721   \or
722     \edef\strc_itemgroups_setup_what{#levels}%
723     \ifx\strc_itemgroups_setup_what\v!each
724       \strc_itemgroups_setup_each{#category}{#options}%
725     \else
726       \strc_itemgroups_setup_list{#levels}{#category}{#options}%
727     \fi
728   \or
729     \edef\strc_itemgroups_setup_what{#levels}%
730     \ifx\strc_itemgroups_setup_what\v!each
731       \strc_itemgroups_setup_each{#category}{#options}%
732       \strc_itemgroups_setup_each{#category}{#settings}%
733     \else
734       \strc_itemgroups_setup_list{#levels}{#category}{#options}%
735       \strc_itemgroups_setup_list{#levels}{#category}{#settings}%
736     \fi
737   \fi}
738
739\def\strc_itemgroups_setup_each#category#whatever%
740  {\ifhastok={#whatever}%
741     \strc_itemgroups_normal_setup[#category][#whatever]%
742   \else
743     \strc_itemgroups_normal_setup[#category][\c!option={#whatever}]%
744   \fi}
745
746\def\strc_itemgroups_setup_list_level_a#category#whatever#level%
747  {\strc_itemgroups_normal_setup[#category:#level][#whatever]}
748
749\def\strc_itemgroups_setup_list_level_b#category#whatever#level%
750  {\strc_itemgroups_normal_setup[#category:#level][\c!option={#whatever}]}
751
752\def\strc_itemgroups_setup_list#subcategories#category#whatever%
753  {\ifhastok={#whatever}%
754     \processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_a{#category}{#whatever}}%
755   \else
756     \processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_b{#category}{#whatever}}%
757   \fi}
758
759\def\strc_itemgroups_increment_item_counter
760  {\ifconditional\c_strc_itemgroups_sub \else
761     \ifconditional\c_strc_itemgroups_symbol \else % \ifempty\strc_itemgroups_extra_symbol
762       \strc_counters_increment_sub\v_strc_itemgroups_counter\currentitemlevel
763     \fi
764   \fi}
765
766\protected\def\strc_itemgroups_insert_item_counter
767  {\ifconditional\c_strc_itemgroups_repeat
768     \ifcase\c_strc_itemgroups_nesting
769       % skip
770     \or
771       \strc_itemgroups_insert_item_counter_indeed % this could become an option
772     \else
773       \strc_itemgroups_insert_item_counter_indeed
774     \fi
775   \else
776     \strc_itemgroups_insert_item_counter_indeed
777   \fi}
778
779\installcorenamespace{itemstopper}
780
781\defcsname\??itemstopper\v!yes\endcsname
782  {\itemgroupparameter\c!stopper}
783
784\defcsname\??itemstopper\v!display\endcsname
785  {\ifconditional\c_strc_itemgroups_inline\else
786     \itemgroupparameter\c!stopper
787   \fi}
788
789\defcsname\??itemstopper\v!inline\endcsname
790  {\ifconditional\c_strc_itemgroups_inline
791     \itemgroupparameter\c!stopper
792   \fi}
793
794\def\strc_itemgroups_insert_item_counter_indeed % quite slow ... every time this setup .. but it
795  {\begingroup                                  % can be optimized ... best move some to strc-num
796   \setupcounter
797     [\v_strc_itemgroups_counter]%
798     [\c!prefix=\itemgroupparameter\c!prefix,
799      \c!prefixstopper=\itemgroupparameter\c!prefixstopper,
800      \c!prefixseparatorset=\itemgroupparameter\c!prefixseparatorset,
801      \c!prefixconversion=\itemgroupparameter\c!prefixconversion,
802      \c!prefixconversionset=\itemgroupparameter\c!prefixseparatorset,
803      \c!prefixset=\itemgroupparameter\c!prefixset,
804      \c!prefixsegments=\itemgroupparameter\c!prefixsegments,
805      \c!prefixconnector=\itemgroupparameter\c!prefixconnector,
806      \c!criterium=\itemgroupparameter\c!criterium,
807      \c!numberorder=\ifconditional\c_strc_itemgroups_reverse\v!reverse\else\v!normal\fi,
808      \c!numberstopper=\begincsname\??itemstopper\itemgroupparameter\c!placestopper\endcsname,
809      \c!numberconversionset=\v_strc_itemgroups_counter,
810      \c!numbersegments=\currentitemgroupsegments]%
811   % there will be a fixedconversion key
812   \normalexpanded{\defineconversionset[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
813  %\normalexpanded{\strc_sets_define_conversion_set[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
814   %
815   \convertedcounter[\v_strc_itemgroups_counter]% [\number\currentitemlevel]%
816   \strc_itemgroups_insert_reference
817   \endgroup}
818
819% needs testing (maybe it need to happen later)
820%
821% \appendtoks
822%    \setupcounter
823%      [\v_strc_itemgroups_counter]%
824%      [\c!prefix=\itemgroupparameter\c!prefix,
825%       \c!prefixstopper=\itemgroupparameter\c!prefixstopper,
826%       \c!prefixseparatorset=\itemgroupparameter\c!prefixseparatorset,
827%       \c!prefixconversion=\itemgroupparameter\c!prefixconversion,
828%       \c!prefixconversionset=\itemgroupparameter\c!prefixseparatorset,
829%       \c!prefixset=\itemgroupparameter\c!prefixset,
830%       \c!prefixsegments=\itemgroupparameter\c!prefixsegments,
831%       \c!prefixconnector=\itemgroupparameter\c!prefixconnector,
832%       \c!criterium=\itemgroupparameter\c!criterium,
833%       \c!numberorder=\ifconditional\c_strc_itemgroups_reverse\v!reverse\else\v!normal\fi,
834%       \c!numberstopper=\expdoif{\itemgroupparameter\c!placestopper}\v!yes{\itemgroupparameter\c!stopper},
835%       \c!numberconversionset=\v_strc_itemgroups_counter,
836%       \c!numbersegments=\currentitemgroupsegments]%
837% \to\itemgroupcommands
838%
839% \def\strc_itemgroups_insert_item_counter_indeed % quite slow ... every time this setup .. but it
840%   {\begingroup                                  % can be optimized ... best move some to strc-num
841%    % there will be a fixedconversion key
842%   %\normalexpanded{\defineconversionset[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
843%    \normalexpanded{\strc_sets_define_conversion_set[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
844%    %
845%    \convertedcounter[\v_strc_itemgroups_counter]% [\number\currentitemlevel]%
846%    \strc_itemgroups_insert_reference
847%    \endgroup}
848
849\lettonothing\strc_itemgroups_temp_symbol
850\lettonothing\strc_itemgroups_used_symbol
851\lettonothing\strc_itemgroups_asked_symbol
852\lettonothing\strc_itemgroups_margin_symbol
853\lettonothing\strc_itemgroups_extra_symbol
854
855\def\strc_itemgroups_set_symbol#symbol%
856  {\edef\strc_itemgroups_temp_symbol{#symbol}%
857   \ifempty\strc_itemgroups_temp_symbol \else
858     \doifelsesymboldefined\strc_itemgroups_temp_symbol
859        \strc_itemgroups_set_symbol_symbol
860        {\doifelseconversiondefined\strc_itemgroups_temp_symbol
861           \strc_itemgroups_set_symbol_conversion
862           \donothing}%
863   \fi}
864
865\def\strc_itemgroups_set_symbol_symbol
866  {\let\currentitemgroupsymbol\strc_itemgroups_temp_symbol
867   \strc_itemgroups_store_global_symbol\currentitemgroupsymbol
868   \strc_itemgroups_store_local_symbol\v_strc_itemgroups_unknown_symbol
869   \let\strc_itemgroups_used_symbol\strc_itemgroups_set_symbol_symbol_item
870   \lettonothing\strc_itemgroups_asked_symbol}
871
872\def\strc_itemgroups_set_symbol_conversion
873  {\let\currentitemgroupsymbol\strc_itemgroups_temp_symbol
874   \strc_itemgroups_store_global_symbol\currentitemgroupsymbol
875   \strc_itemgroups_store_local_symbol\strc_itemgroups_insert_item_counter
876   \let\strc_itemgroups_used_symbol\strc_itemgroups_set_symbol_conversion_item
877   \lettonothing\strc_itemgroups_asked_symbol}
878
879\def\strc_itemgroups_set_symbol_symbol_item
880  {\symbol[\currentitemgroupsymbol]}
881
882\def\strc_itemgroups_set_symbol_conversion_item
883  {\ifconditional\c_strc_itemgroups_text
884     % maybe block stopper here, but one can as well clone an itemgroup then
885     \itemgroupparameter\c!lefttext
886     \strc_itemgroups_fetch_local_symbol
887     \itemgroupparameter\c!righttext
888   \else
889     \itemgroupparameter\c!left
890     \strc_itemgroups_fetch_local_symbol
891     \itemgroupparameter\c!right
892   \fi}
893
894\def\strc_itemgroups_calculate_list_width#level%
895  {\let\m_strc_itemgroups_saved\currentitemgroup
896   \cdef\currentitemgroup{\currentparentitemgroup:\number#level}%
897   \ifdim\d_strc_itemgroups_max_width>\zeropoint
898     \d_strc_itemgroups_list_width\d_strc_itemgroups_max_width
899   \orelse\ifnum\itemgroupparameter\c!factor>\zerocount
900     \d_strc_itemgroups_list_width\itemgroupparameter\c!step\relax
901     \ifzeropt\d_strc_itemgroups_list_width \d_strc_itemgroups_list_width=.5em\fi
902     \multiplyby\d_strc_itemgroups_list_width \itemgroupparameter\c!factor
903     \advanceby\d_strc_itemgroups_list_width\itemgroupparameter\c!width\relax
904   \else
905     \d_strc_itemgroups_list_width\itemgroupparameter\c!width\relax
906   \fi
907   \advanceby\d_strc_itemgroups_list_width\itemgroupparameter\c!distance\relax
908   \let\currentitemgroup\m_strc_itemgroups_saved}
909
910\lettonothing\p_itemgroups_options
911\lettonothing\p_itemgroups_extra_options
912
913\permanent\tolerant\protected\def\startitemgroup[#S#category]#spacer[#S#options]#spacer[#S#settings]%
914  {\begingroup % (1)
915   \nofarguments\lastarguments
916   \cdef\currentitemgroup{#category}% no nested mixing of itemgroups
917   \let\currentparentitemgroup\currentitemgroup
918   \global\advanceby\c_strc_itemgroups_nesting\plusone
919   \def\currentitemlevel{\the\c_strc_itemgroups_nesting}%
920   \normalexpanded{\chaintocurrentitemgroup{\currentparentitemgroup:\currentitemlevel}}%
921   \cdef\currentitemgroup{\currentparentitemgroup:\currentitemlevel}%
922   %
923   \edef\p_itemgroups_options{\itemgroupparameter\c!option}%
924   \lettonothing\p_itemgroups_extra_options
925   \ifcase\nofarguments
926     \strc_itemgroups_start_indeed{}%
927   \or
928     \strc_itemgroups_start_indeed{}%
929   \or
930     \ifhastok={#options}%
931       \strc_itemgroups_start_indeed{#options}%
932     \else
933       \edef\p_itemgroups_extra_options{#options}%
934       \strc_itemgroups_start_indeed{}%
935     \fi
936   \or
937     \edef\p_itemgroups_extra_options{#options}%
938     \strc_itemgroups_start_indeed{#settings}%
939   \fi}
940
941\def\strc_itemgroups_start_indeed#settings%
942  {\ifempty\p_itemgroups_options
943     \let\p_itemgroups_options\p_itemgroups_extra_options
944   \orelse\ifempty\p_itemgroups_extra_options
945     % ok
946   \else
947     \edef\p_itemgroups_options{\p_itemgroups_options,\p_itemgroups_extra_options}%
948   \fi
949   \begingroup % (2)
950   \the\itemgroupcommands
951   \setconditional\c_strc_itemgroups_text_saved\c_strc_itemgroups_text
952   \strc_itemgroups_initialize_local
953   \strc_itemgroups_preset_stage_one\p_itemgroups_options
954   \iftrialtypesetting
955     \strc_counters_save\v_strc_itemgroups_counter
956   \fi
957\globalpushmacro\c_strc_itemgroups_n_of_items
958\global\c_strc_itemgroups_n_of_items\zerocount
959   \strc_itemgroups_check_n_of_items
960   \ifempty\p_itemgroups_options
961     \strc_itemgroups_setup_symbol_default
962     \strc_itemgroups_reset_continue_state
963     \setupcurrentitemgroup[#settings]%
964   \else
965     \strc_itemgroups_process_options\p_itemgroups_options
966     \setupcurrentitemgroup[#settings]%
967     \ifconditional\c_strc_itemgroups_continue
968       \strc_itemgroups_setup_symbol_continue
969       \strc_itemgroups_fetch_continue_state
970     \else
971       \strc_itemgroups_setup_symbol_asked
972       \strc_itemgroups_store_continue_state\p_itemgroups_options{#settings}%
973     \fi
974   \fi
975   %
976   \ifhmode
977     \ifconditional\c_strc_itemgroups_auto_concat
978       \ifnum\lastboundary=\c_strc_itemgroups_boundary
979         \c_strc_itemgroups_concat\conditionaltrue
980       \fi
981     \fi
982     \ifconditional\c_strc_itemgroups_text_saved
983     \orelse\ifconditional\c_strc_itemgroups_text
984     \orelse\ifconditional\c_strc_itemgroups_no_par
985     \else
986       \par
987     \fi
988   \fi
989   %
990   \ifconditional\c_strc_itemgroups_pack
991     \ifnum\currentnofitems>\itemgroupparameter\c!packcriterium\relax\else
992       \c_strc_itemgroups_pack\conditionalfalse
993     \fi
994   \fi
995   %
996   \ifconditional\c_strc_itemgroups_text % also does inline
997     % ignore
998   \orelse\ifnum\c_strc_itemgroups_nesting=\plusone % NIEUW
999     \doadaptleftskip {\itemgroupparameter\c!margin}%
1000     \doadaptleftskip {\itemgroupparameter\c!leftmargin}%
1001     \doadaptrightskip{\itemgroupparameter\c!rightmargin}%
1002   \fi
1003   %
1004   \doadaptleftskip {\itemgroupparameter\c!leftmargindistance}%
1005   \doadaptrightskip{\itemgroupparameter\c!rightmargindistance}%
1006   %
1007   \edef\m_strc_itemgroups_spacing{\itemgroupparameter\c!spacing}%
1008   \ifx\m_strc_itemgroups_spacing\v!before
1009     \c_strc_itemgroups_spacing_mode\zerocount
1010   \orelse\ifx\m_strc_itemgroups_spacing\v!inbetween
1011     \c_strc_itemgroups_spacing_mode\plusone
1012   \orelse\ifx\m_strc_itemgroups_spacing\v!auto
1013     \c_strc_itemgroups_spacing_mode\plustwo
1014   \fi
1015   %
1016   \usealignparameter\itemgroupparameter
1017   \edef\m_strc_itemgroups_indenting{\itemgroupparameter\c!indenting}%
1018   \ifnum\c_strc_itemgroups_nesting>\zerocount
1019     \c_strc_itemgroups_first\conditionaltrue
1020     \ifconditional\c_strc_itemgroups_continue \else
1021       \strc_counters_restart_sub\v_strc_itemgroups_counter\currentitemlevel{\numexpr\itemgroupparameter\c!start-\plusone\relax}%
1022     \fi
1023   \fi
1024   \ifempty\strc_itemgroups_used_symbol
1025     \strc_itemgroups_set_symbol\strc_itemgroups_asked_symbol % ** default value
1026     \ifempty\strc_itemgroups_used_symbol
1027       \let\currentitemgroupsymbol\currentitemlevel % ** fall back
1028     \fi
1029   \fi
1030   \ifconditional\c_strc_itemgroups_auto_intro\ifnum\prevgraf<\plusthree
1031     \c_strc_itemgroups_intro\conditionaltrue
1032   \fi\fi
1033   \ifconditional\c_strc_itemgroups_paragraph
1034     \ifnum\c_strc_itemgroups_nesting>\plusone
1035       \resetitemgroupparameter\c!inbetween
1036     \fi
1037   \fi
1038   \ifconditional\c_strc_itemgroups_pack
1039     \resetitemgroupparameter\c!inbetween
1040   \fi
1041   \ifconditional\c_strc_itemgroups_columns
1042     \ifinsidecolumns\orelse\ifcase\c_strc_itemgroups_column_depth
1043       \global\c_strc_itemgroups_column_depth\c_strc_itemgroups_nesting % global ?
1044       \strc_itemgroups_before_command
1045       \strc_itemgroups_tag_start_group
1046       \strc_itemgroups_start_columns
1047     \fi
1048   \fi
1049   \ifconditional\c_strc_itemgroups_fitting
1050     \ifdim\d_strc_itemgroups_max_width>\zeropoint
1051       \letitemgroupparameter\c!width\d_strc_itemgroups_max_width_reference
1052     \fi
1053   \fi
1054   \strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting
1055   \ifdim\d_strc_itemgroups_list_width>\zeropoint\relax
1056     \ifconditional\c_strc_itemgroups_inline\else
1057       \frozen\advanceby\leftskip\d_strc_itemgroups_list_width\relax
1058     \fi
1059   \fi
1060   \ifempty\m_strc_itemgroups_repeat_start
1061     \let\currentitemgroupconversionset \currentitemgroupsymbol
1062     \edef\currentitemgroupsegments     {\currentitemlevel}%
1063   \else
1064     \edef\currentitemgroupconversionset{\currentitemgroupconversionset,\currentitemgroupsymbol}%
1065     \edef\currentitemgroupsegments     {\m_strc_itemgroups_repeat_start:\currentitemlevel}%
1066   \fi
1067   \d_strc_itemgroups_asked_width\itemgroupparameter\c!width\relax
1068   \startcollectitems}
1069
1070\let\startcollectitems\relax
1071\let\stopcollectitems \relax
1072
1073\letcsname\??itemgroupalign\v!flushleft \endcsname\relax
1074\letcsname\??itemgroupalign\v!right     \endcsname\relax
1075\letcsname\??itemgroupalign\v!flushright\endcsname\hfill
1076\letcsname\??itemgroupalign\v!left      \endcsname\hfill
1077\letcsname\??itemgroupalign\v!middle    \endcsname\hfil
1078\letcsname\??itemgroupalign\v!center    \endcsname\hfil
1079
1080\def\strc_itemgroups_left_sym_filler
1081  {\csname\??itemgroupalign\itemgroupparameter\c!symalign\endcsname}
1082
1083% symbols + states
1084
1085\def\strc_itemgroups_store_global_symbol#symbol%
1086  {\gletcsname\??itemgroupglobal\currentitemgroup:\currentitemlevel\endcsname#symbol}
1087
1088\def\strc_itemgroups_store_local_symbol#symbol%
1089  {\gletcsname\??itemgrouplocal\currentitemgroup:\currentitemlevel\endcsname#symbol}
1090
1091\def\strc_itemgroups_fetch_global_symbol
1092  {\csname\??itemgroupglobal\currentitemgroup:\currentitemlevel\endcsname}
1093
1094\def\strc_itemgroups_fetch_local_symbol
1095  {\csname\??itemgrouplocal\currentitemgroup:\currentitemlevel\endcsname}
1096
1097\def\strc_itemgroups_setup_symbol_default
1098  {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}%
1099   \strc_itemgroups_store_global_symbol\empty}
1100
1101\def\strc_itemgroups_setup_symbol_continue
1102  {\ifcsname\??itemgroupglobal\currentitemgroup:\currentitemlevel\endcsname
1103     \let\strc_itemgroups_asked_symbol\strc_itemgroups_fetch_global_symbol
1104   \else
1105     \let\strc_itemgroups_asked_symbol\currentitemlevel
1106   \fi}
1107
1108\def\strc_itemgroups_setup_symbol_asked
1109   {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}}
1110
1111\ifdefined\strc_itemgroups_start_columns
1112
1113    % already defined in page-mix
1114
1115\else
1116
1117    % will be redefined in page-mix
1118
1119    \ifdefined\startcolumns \else
1120        \protected\def\startcolumns[#S#settings]{}
1121        \protected\def\stopcolumns              {}
1122    \fi
1123
1124    \def\strc_itemgroups_start_columns
1125      {\startcolumns
1126         [\c!n=\itemgroupparameter\c!n,
1127          \c!height=,
1128          \c!rule=\v!off,
1129          \c!balance=\v!yes,
1130          \c!align=\v!no]}
1131
1132    \def\strc_itemgroups_stop_columns
1133      {\stopcolumns}
1134
1135\fi
1136
1137\permanent\protected\def\stopitemgroup
1138  {\stopcollectitems
1139   \ifconditional\c_strc_itemgroups_text
1140     \removeunwantedspaces
1141     \space
1142     \ignorepars % \ignorespaces
1143   \else
1144     \par
1145   \fi
1146   \strc_itemgroups_register_status
1147 % \ifconditional\c_strc_itemgroups_first \else
1148   \ifnum\c_strc_itemgroups_n_of_items>\zerocount % different criterium
1149     \dostoptagged
1150     \dostoptagged
1151   % \endgroup % (3)
1152   \fi
1153   \ifnum\c_strc_itemgroups_column_depth=\c_strc_itemgroups_nesting\relax
1154     \strc_itemgroups_stop_columns
1155     \global\c_strc_itemgroups_column_depth\zerocount % global ?
1156     \strc_itemgroups_tag_stop_group
1157     \strc_itemgroups_after_command
1158     \dontrechecknextindentation
1159   \orelse\ifnum\c_strc_itemgroups_nesting=\plusone
1160     \strc_itemgroups_insert_breakallow
1161     \strc_itemgroups_tag_stop_group
1162     \strc_itemgroups_after_command
1163     \useindentnextparameter\itemgroupparameter
1164   \else
1165     % nieuw, not yet nobreak handling
1166     \strc_itemgroups_tag_stop_group
1167     \ifcase\c_strc_itemgroups_spacing_mode
1168       \strc_itemgroups_after_command
1169     \or
1170       \strc_itemgroups_after_command
1171     \fi
1172     \dontrechecknextindentation
1173   \fi
1174   % new test, needed in sidefloats (surfaced in volker's proceedings)
1175   \iftrialtypesetting
1176     \strc_counters_restore\v_strc_itemgroups_counter % could happen in LUA
1177   \fi
1178\globalpopmacro\c_strc_itemgroups_n_of_items
1179   \global\advanceby\c_strc_itemgroups_nesting\minusone
1180   \xdef\currentitemlevel{\the\c_strc_itemgroups_nesting}%
1181  %\ifconditional\c_strc_itemgroups_text
1182     \endgroup % (2)
1183     \endgroup % (1)
1184  %\else
1185  %  \endgroup % (2)
1186  %  \endgroup % (1)
1187  %  \par % hm, already done, and dangerous as \c_strc_itemgroups_text is already forgotten
1188  %\fi
1189   \dorechecknextindentation}
1190
1191% The items.
1192
1193\def\strc_itemgroups_start_item_first
1194  {\c_strc_itemgroups_first\conditionalfalse
1195 % \begingroup % (3)
1196   \ifcase\c_strc_itemgroups_nesting
1197                                           % 0
1198   \or
1199     \strc_itemgroups_start_item_first_one % 1
1200   \else
1201     \strc_itemgroups_start_item_first_two % 2+
1202   \fi}
1203
1204\def\strc_itemgroups_start_item_first_one
1205  {\ifcase\c_strc_itemgroups_column_depth
1206     \ifconditional\c_strc_itemgroups_intro\strc_itemgroups_insert_breakno\fi
1207     \strc_itemgroups_before_command
1208     \strc_itemgroups_tag_start_group
1209     \ifconditional\c_strc_itemgroups_intro\strc_itemgroups_insert_breakno\fi
1210   \fi}
1211
1212\newinteger\c_strc_itemgroups_prev_level
1213
1214\def\strc_itemgroups_inbetween_command
1215  {\nameditemgroupparameter{\currentparentitemgroup:\the\c_strc_itemgroups_prev_level}\c!inbetween}
1216
1217\def\strc_itemgroups_start_item_first_two
1218  {\ifconditional\c_strc_itemgroups_paragraph\else
1219     \c_strc_itemgroups_prev_level\numexpr\c_strc_itemgroups_nesting-\plusone\relax
1220     \ifcase\c_strc_itemgroups_spacing_mode
1221       \strc_itemgroups_before_command
1222     \or
1223       \ifempty\strc_itemgroups_before_command % should possibly expand to empty
1224         \strc_itemgroups_inbetween_command
1225       \else
1226         \strc_itemgroups_before_command
1227       \fi
1228     \else
1229       \strc_itemgroups_inbetween_command
1230     \fi
1231     \strc_itemgroups_tag_start_group
1232   \fi}
1233
1234\def\strc_itemgroups_start_item_next
1235  {%\dostoptagged % moved
1236   %\dostoptagged % moved
1237   \ifconditional\c_strc_itemgroups_text
1238     \ifhmode
1239       % WS: make the distance between items customizable, think about better default values -> see itemize-1.tex
1240       \strc_itemgroups_set_text_item_distance% HH: moved out and made configurable (sort of)
1241       \removeunwantedspaces
1242       \ifnum\numexpr\c_strc_itemgroups_n_of_items+\plusone\relax=\c_strc_itemgroups_max_items
1243         \itemgroupparameter\c!lasttextseparator
1244       \else
1245         \itemgroupparameter\c!textseparator
1246       \fi
1247       \ifempty\m_strc_itemgroups_text_distance
1248         % safeguard
1249       \else
1250         \hskip\m_strc_itemgroups_text_distance\relax
1251       \fi
1252     \fi
1253   \else
1254     \strc_itemgroups_between_command
1255   \fi}
1256
1257% c_strc_itemgroups_concat:
1258%
1259% the problem is that we use leftskip so concat cannot reliable take the height into
1260% account; it's .. rather tricky when white space in there anyway (due to \par) .. so
1261% we rely on a special blank method
1262%
1263% \startitemize[n]
1264%     \item bla
1265%     \item \startitemize[a]
1266%         \item bla $\displaystyle\int^{x^{y^4}}$ \item bla
1267%     \stopitemize
1268% \stopitemize
1269
1270\mutable\lettonothing\currentitemreference
1271
1272\noaligned\tolerant\permanent\protected\def\startitemgroupitem[#reference]% we can reuse more
1273  {\strc_itemgroups_begin
1274   \def\currentitemreference{#reference}%
1275   \ifconditional\c_strc_itemgroups_text
1276     % begin of item
1277   \orelse\ifconditional\c_strc_itemgroups_no_par
1278     % special
1279   \else
1280     \par
1281   \fi
1282   \ifconditional\c_strc_itemgroups_concat
1283     \strc_itemgroups_insert_breakno
1284   \fi
1285 % \ifconditional\c_strc_itemgroups_first
1286 %   \strc_itemgroups_start_item_first
1287 % \else
1288 %   \strc_itemgroups_start_item_next
1289 % \fi
1290 % now:
1291   \strc_itemgroups_increment_item_counter
1292   \ifnum\c_strc_itemgroups_n_of_items>\zerocount % different criterium
1293     \dostoptagged % moved here
1294     \dostoptagged % moved here
1295     \strc_itemgroups_start_item_next
1296   \else
1297     \strc_itemgroups_start_item_first
1298   \fi
1299   \ifconditional\c_strc_itemgroups_concat
1300     \spac_overlay_lines % see spac-ver.mkvi ... a typical potential problem
1301     \c_strc_itemgroups_concat\conditionalfalse
1302   \fi
1303   \dostarttagged\t!item\empty
1304  % \dotagsetitem\empty
1305   \dostarttagged\t!itemtag\empty
1306   \strc_itemgroups_insert_item
1307   \dostoptagged
1308   \ifconditional\c_strc_itemgroups_pack
1309     \setupwhitespace[\v!none]%
1310   \fi
1311   \itemgroupparameter\c!inner % will become obsolete (better use setups)
1312   \strc_itemgroups_margin_symbol
1313   \let\strc_itemgroups_margin_symbol\relax
1314   \dostarttagged\t!itemcontent\empty
1315   \begstrut % \strut
1316   \nobreak                            % else problems with intext items
1317   \seteffectivehsize % NEW !
1318   \boundary\c_strc_itemgroups_boundary % was signal
1319   \itemgroupparameter\c!command}
1320
1321\noaligned\protected\permanent\def\stopitemgroupitem
1322  {\ifhmode
1323     \endstrut % new per 2017-12-15
1324   \fi
1325   \ifconditional\c_strc_itemgroups_text
1326     % nothing
1327   \else
1328     \endgraf
1329   \fi
1330   \strc_itemgroups_end}
1331
1332\lettonothing\strc_itemgroups_begin
1333\lettonothing\strc_itemgroups_end
1334
1335\tolerant\permanent\protected\def\startitemgrouphead[#reference]%
1336  {\ifconditional\c_strc_itemgroups_first \else
1337     \strc_itemgroups_insert_breakallow
1338   \fi
1339   \ifconditional\c_strc_itemgroups_pack \else
1340     \strc_itemgroups_before_head_command
1341   \fi
1342   \ifconditional\c_strc_itemgroups_first
1343     \ifconditional\c_strc_itemgroups_intro \else
1344       \ifcase\c_strc_itemgroups_nesting
1345         \strc_itemgroups_insert_breakallow
1346       \fi
1347     \fi
1348   \fi
1349  %\strc_itemgroups_start_item[#reference]%
1350   \startitemgroupitem[#reference]%
1351   \pickupgroupedcommand
1352     \strc_itemgroups_start_head_indeed
1353     \strc_itemgroups_stop_head_indeed
1354     \strc_itemgroups_head_body_indeed}
1355
1356\permanent\protected\def\stopitemgrouphead
1357  {\dostoptagged
1358   \stopitemgroupitem}
1359
1360\protected\def\strc_itemgroups_start_head_indeed
1361  {\c_strc_itemgroups_head\conditionaltrue
1362   \dotagsetitem\s!head% % weird place
1363   \dostarttagged\t!itemhead\empty
1364   \useitemgroupstyleandcolor\c!headstyle\c!headcolor
1365   \ignorepars} % \ignorespaces
1366
1367\protected\def\strc_itemgroups_stop_head_indeed
1368  {\removeunwantedspaces
1369   \dostoptagged
1370   \ifconditional\c_strc_itemgroups_inline_head
1371       \space
1372       \ignorepars % \ignorespaces
1373   \else
1374     \ifconditional\c_strc_itemgroups_text
1375       \space
1376       \ignorepars % \ignorespaces
1377     \else
1378       \par
1379     \fi
1380     \strc_itemgroups_insert_breakno
1381     \ifconditional\c_strc_itemgroups_pack\else\strc_itemgroups_after_head_command\fi
1382     \strc_itemgroups_insert_breakno
1383  \fi}
1384
1385\protected\def\strc_itemgroups_head_body_indeed
1386  {\dostarttagged\t!itembody\empty
1387   \noindentation
1388   \ignorepars} % \ignorespaces
1389
1390% Simple commands.
1391
1392\protected\def\strc_itemgroups_start_do_item
1393  {\startitemgroupitem}
1394
1395\protected\def\strc_itemgroups_start_no_item
1396  {\lettonothing\currentitemreference
1397   \strc_itemgroups_increment_item_counter
1398  %\advanceby\c_strc_itemgroups_n_of_items\plusone
1399   \setbox\b_strc_itemgroups\emptyhbox
1400   \strc_itemgroups_check_for_repeated
1401   \ignorepars} % \ignorespaces
1402
1403\protected\def\strc_itemgroups_start_button[#destination]%
1404  {\edef\m_strc_itemgroups_destination{#destination}%
1405   \startitemgroupitem}
1406
1407\protected\def\strc_itemgroups_start_symbol#text%
1408  {\def\strc_itemgroups_extra_symbol{#text}%
1409   \c_strc_itemgroups_symbol\conditionaltrue
1410   \startitemgroupitem
1411   \dotagsetitem\s!symbol}
1412
1413\protected\def\strc_itemgroups_start_dummy
1414  {\strc_itemgroups_start_symbol
1415  %\strut\strut} % two ?
1416   \begstrut}
1417
1418\protected\def\strc_itemgroups_start_subitem
1419  {\c_strc_itemgroups_sub\conditionaltrue
1420   \startitemgroupitem
1421   \dotagsetitem\s!sub}
1422
1423\protected\def\strc_itemgroups_start_edge#text%
1424  {\strc_itemgroups_start_symbol
1425     {\strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting
1426      \dostarttagged\t!ignore\empty % for the moment, maybe an attribute
1427      \hbox to \d_strc_itemgroups_list_width
1428        {#text\hskip\itemgroupparameter\c!distance}%
1429      \dostoptagged}}
1430
1431\protected\def\strc_itemgroups_start_margin#text%
1432  {\def\strc_itemgroups_margin_symbol % brrr
1433     {\dostarttagged\t!ignore\empty % for the moment, maybe an attribute
1434      \llap
1435        {\begingroup
1436         \useitemgroupstyleandcolor\c!marstyle\c!marcolor
1437         #text% keep em/ex local
1438         \endgroup
1439         \hskip\dimexpr\leftskip+\leftmargindistance\relax}%
1440      \dostoptagged}%
1441   \startitemgroupitem
1442   \dotagsetitem\s!margin}
1443
1444\protected\def\strc_itemgroups_start_text#text%
1445  {\def\strc_itemgroups_extra_symbol{#text}%
1446   \c_strc_itemgroups_symbol\conditionaltrue
1447   \c_strc_itemgroups_txt\conditionaltrue
1448   \startitemgroupitem}
1449
1450\protected\tolerant\def\strc_itemgroups_start_items[#1]%
1451  {\strc_itemgroups_start_edge
1452     {\localcontrolledloop
1453        \plusone
1454        \ifchknumber#1\or\lastchknumber\else0\itemgroupparameter\c!items\fi
1455        \plusone
1456        {\strc_itemgroups_used_symbol\hss}%
1457      \unskip}}
1458
1459\protected\permanent\def\startspecialitemgroupitem[#name]% todo: frozen
1460  {\ifcsname\??itemgroupstart#name\endcsname
1461      \expandafter\lastnamedcs
1462    \else
1463      \expandafter\strc_itemgroups_start_do_item
1464    \fi}
1465
1466\protected\permanent\def\stopspecialitemgroupitem % todo: frozen
1467  {\stopitemgroupitem}
1468
1469\letcsname\??itemgroupstart\v!item\endcsname\strc_itemgroups_start_do_item
1470\letcsname\??itemgroupstart\v!sub \endcsname\strc_itemgroups_start_subitem
1471\letcsname\??itemgroupstart\v!sym \endcsname\strc_itemgroups_start_symbol
1472\letcsname\??itemgroupstart\v!ran \endcsname\strc_itemgroups_start_edge
1473\letcsname\??itemgroupstart\v!its \endcsname\strc_itemgroups_start_items
1474\letcsname\??itemgroupstart\v!mar \endcsname\strc_itemgroups_start_margin
1475\letcsname\??itemgroupstart\v!txt \endcsname\strc_itemgroups_start_text
1476\letcsname\??itemgroupstart\v!no  \endcsname\strc_itemgroups_start_no_item
1477
1478\def\strc_itemgroups_optimize_breaks_both
1479  {\ifcase\c_strc_itemgroups_max_items
1480   \orelse\ifnum\c_strc_itemgroups_max_items=\plusthree
1481     \ifnum\c_strc_itemgroups_n_of_items>\plusone
1482       \strc_itemgroups_insert_nobreak
1483     \fi
1484   \orelse\ifnum\c_strc_itemgroups_max_items>\plusthree
1485     \ifnum\c_strc_itemgroups_n_of_items=\plustwo
1486       \ifconditional\c_strc_itemgroups_intro
1487         \strc_itemgroups_insert_breakno
1488       \else
1489         \strc_itemgroups_insert_nobreak
1490       \fi
1491     \orelse\ifnum\c_strc_itemgroups_max_items=\c_strc_itemgroups_n_of_items\relax
1492       \strc_itemgroups_insert_nobreak
1493     \orelse\ifnum\c_strc_itemgroups_n_of_items>\plustwo
1494       \strc_itemgroups_insert_break
1495     \orelse\ifconditional\c_strc_itemgroups_intro
1496     \else
1497       \strc_itemgroups_insert_break
1498     \fi
1499   \fi}
1500
1501\def\strc_itemgroups_optimize_breaks_first
1502  {\ifcase\c_strc_itemgroups_max_items
1503   \orelse\ifnum\c_strc_itemgroups_max_items=\plusthree
1504     \ifnum\c_strc_itemgroups_n_of_items<\plusthree   % !
1505       \strc_itemgroups_insert_nobreak                % !
1506     \else                                            % !
1507       \strc_itemgroups_insert_break                  % !
1508     \fi                                              % !
1509   \orelse\ifnum\c_strc_itemgroups_max_items>\plusthree
1510     \ifnum\c_strc_itemgroups_n_of_items=\plustwo
1511       \ifconditional\c_strc_itemgroups_intro
1512         \strc_itemgroups_insert_breakno
1513       \else
1514         \strc_itemgroups_insert_nobreak
1515       \fi
1516     \orelse\ifnum\c_strc_itemgroups_max_items=\c_strc_itemgroups_n_of_items\relax
1517       \strc_itemgroups_insert_break                  % !
1518     \orelse\ifnum\c_strc_itemgroups_n_of_items>\plustwo
1519       \strc_itemgroups_insert_break
1520     \orelse\ifconditional\c_strc_itemgroups_intro
1521     \else
1522       \strc_itemgroups_insert_break
1523     \fi
1524   \fi}
1525
1526\def\strc_itemgroups_optimize_breaks_last
1527  {\ifcase\c_strc_itemgroups_max_items
1528   \orelse\ifnum\c_strc_itemgroups_max_items=\plusthree
1529     \ifnum\c_strc_itemgroups_n_of_items>\plustwo % !
1530       \strc_itemgroups_insert_nobreak            % !
1531     \else                                        % !
1532       \strc_itemgroups_insert_break              % !
1533     \fi                                          % !
1534   \orelse\ifnum\c_strc_itemgroups_max_items>\plusthree
1535     \ifnum\c_strc_itemgroups_n_of_items=\plustwo
1536      \ifconditional\c_strc_itemgroups_intro
1537        \strc_itemgroups_insert_breakno
1538      \else
1539        \strc_itemgroups_insert_break             % !
1540      \fi
1541     \orelse\ifnum\c_strc_itemgroups_max_items=\c_strc_itemgroups_n_of_items\relax
1542       \strc_itemgroups_insert_nobreak
1543     \orelse\ifnum\c_strc_itemgroups_n_of_items>\plustwo
1544       \strc_itemgroups_insert_break
1545     \orelse\ifconditional\c_strc_itemgroups_intro
1546     \else
1547       \strc_itemgroups_insert_break
1548     \fi
1549   \fi}
1550
1551\def\strc_itemgroups_optimize_breaks
1552  {\ifcase\c_strc_itemgroups_column_depth
1553     \ifconditional\c_strc_itemgroups_optimize  % loose
1554     \or \strc_itemgroups_optimize_breaks_both  % tight
1555     \or \strc_itemgroups_optimize_breaks_both  % verytight
1556     \or \strc_itemgroups_optimize_breaks_first % tight:first
1557     \or \strc_itemgroups_optimize_breaks_last  % tight:last
1558     \fi
1559   \fi}
1560
1561\def\strc_itemgroups_handle_text_item
1562  {\scratchdimen\wd\b_strc_itemgroups
1563   \advanceby \scratchdimen \itemgroupparameter\c!distance\relax
1564   \ifdim\scratchdimen>\d_strc_itemgroups_list_width
1565     \advanceby\scratchdimen -\d_strc_itemgroups_list_width
1566   \else
1567     \scratchdimen\zeropoint
1568   \fi
1569   \llap{\hbox to \d_strc_itemgroups_list_width{\ifconditional\c_strc_itemgroups_sub\llap{+\enspace}\fi\box\b_strc_itemgroups\hss}}% was: \hfill
1570   \hskip\scratchdimen}
1571
1572\def\strc_itemgroups_handle_lapped_item_positive
1573  {\llap
1574     {\dontcomplain
1575      \hbox to \d_strc_itemgroups_list_width
1576        {\ifconditional\c_strc_itemgroups_sub
1577           \dostarttagged\t!ignore\empty
1578           \llap{+\enspace}%
1579           \dostoptagged
1580         \fi
1581         \strc_itemgroups_left_sym_filler
1582         \box\b_strc_itemgroups % can already have a forced widt, only factor handled here
1583         \hfil
1584         \hskip\itemgroupparameter\c!distance}}}
1585
1586\def\strc_itemgroups_handle_lapped_item_negative
1587  {\llap
1588     {\ifconditional\c_strc_itemgroups_sub
1589        \dostarttagged\t!ignore\empty
1590        \llap{+\enspace}%
1591        \dostoptagged
1592      \fi
1593      \box\b_strc_itemgroups
1594      \hskip\leftmargindistance}}
1595
1596\def\strc_itemgroups_handle_groups_text_item
1597  {\hbox
1598     {\ifconditional\c_strc_itemgroups_sub
1599        \dostarttagged\t!ignore\empty
1600        +\enspace
1601        \dostoptagged
1602      \fi
1603      \scratchwidth\wd\b_strc_itemgroups
1604      \box\b_strc_itemgroups
1605      \ifzerodim\scratchwidth\else
1606        \hskip\interwordspace % not configureable (yet), could be \c!textdistance
1607      \fi}%
1608   \nobreak}
1609
1610\def\strc_itemgroups_handle_groups_inline_item
1611  {\hbox to \d_strc_itemgroups_list_width
1612     {\ifconditional\c_strc_itemgroups_sub
1613        \dostarttagged\t!ignore\empty
1614        \llap{+\enspace}%
1615        \dostoptagged
1616      \fi
1617      \box\b_strc_itemgroups
1618      \hss}} % was: \hfill
1619
1620\protected\def\strc_itemgroups_start_head_sym#text%
1621  {\def\strc_itemgroups_extra_symbol{#text}%
1622   \c_strc_itemgroups_symbol\conditionaltrue
1623   \c_strc_itemgroups_head\conditionaltrue
1624  %\strc_itemgroups_start_head}
1625   \startitemgrouphead}
1626
1627\def\strc_itemgroups_make_symbol_box
1628  {\setbox\b_strc_itemgroups\autodirhbox
1629     {\ifconditional\c_strc_itemgroups_head
1630        \ifconditional\c_strc_itemgroups_symbol
1631          \strc_itemgroups_insert_extra_reference
1632          \useitemgroupstyleandcolor\c!symstyle\c!symcolor
1633          \strc_itemgroups_extra_symbol
1634        \else
1635          \useitemgroupstyleandcolor\c!headstyle\c!headcolor
1636          \strc_itemgroups_used_symbol
1637        \fi
1638      \else
1639        \ifconditional\c_strc_itemgroups_symbol
1640          \strc_itemgroups_insert_extra_reference
1641          \useitemgroupstyleandcolor\c!symstyle\c!symcolor
1642          \strc_itemgroups_extra_symbol
1643        \else
1644          \useitemgroupstyleandcolor\c!style\c!color
1645          \strc_itemgroups_used_symbol
1646        \fi
1647      \fi}%
1648   \lettonothing\strc_itemgroups_extra_symbol
1649   \c_strc_itemgroups_symbol\conditionalfalse}
1650
1651\def\strc_itemgroups_make_fitting_box
1652  {\ifdim\wd\b_strc_itemgroups>\itemgroupparameter\c!maxwidth\relax
1653     \normalexpanded{\global\setitemgroupparameter{\c!maxwidth}{\the\wd\b_strc_itemgroups}}%
1654   \fi
1655   \ifdim\d_strc_itemgroups_max_width>\zeropoint
1656     \setbox\b_strc_itemgroups\simplealignedbox
1657       {\dimexpr\d_strc_itemgroups_max_width+\itemgroupparameter\c!distance\relax}%
1658       {\itemgroupparameter\c!itemalign}%
1659       {\box\b_strc_itemgroups\hskip\itemgroupparameter\c!distance}%
1660   \fi}
1661
1662\def\strc_itemgroups_make_aligned_box
1663  {\ifempty{\itemgroupparameter\c!itemalign}\else
1664     \setbox\b_strc_itemgroups\simplealignedbox
1665       {\dimexpr\d_strc_itemgroups_asked_width+\itemgroupparameter\c!distance\relax}%
1666       {\itemgroupparameter\c!itemalign}%
1667       {\box\b_strc_itemgroups\hskip\itemgroupparameter\c!distance}%
1668   \fi}
1669
1670\def\strc_itemgroups_make_destination_box
1671  {\iftrialtypesetting \orelse \ifempty\m_strc_itemgroups_destination \else
1672     \setbox\b_strc_itemgroups\hbox{\directgotobox{\box\b_strc_itemgroups}[\m_strc_itemgroups_destination]}%
1673   \fi}
1674
1675\def\strc_itemgroups_check_indenting
1676  {\c_strc_itemgroups_indented_first\conditionalfalse
1677   \ifempty\m_strc_itemgroups_indenting \else
1678     \normalexpanded{\setupindenting[\v!reset,\v!yes,\m_strc_itemgroups_indenting]}%
1679     \ifconditional\c_spac_indentation_indent_first % better is to have a mode
1680       \ifcstok{\itemgroupparameter\c!alignsymbol}\v!yes\else
1681         \c_strc_itemgroups_indented_first\conditionaltrue
1682       \fi
1683     \fi
1684   \fi}
1685
1686\def\strc_itemgroups_check_for_repeated
1687  {\ifconditional\c_strc_itemgroups_repeat
1688     \ifempty\m_strc_itemgroups_repeat_start
1689       \edef\m_strc_itemgroups_repeat_start{\currentitemlevel}%
1690     \fi
1691   \else
1692     \lettonothing\m_strc_itemgroups_repeat_start
1693   \fi}
1694
1695\newconditional\c_strc_itemgroups_ignore
1696
1697\noaligned\permanent\protected\def\startignoreditem % kind of private
1698  {\global\c_strc_itemgroups_ignore\conditionaltrue
1699   \startitem}
1700
1701\noaligned\permanent\protected\def\stopignoreditem % kind of private
1702  {\stopitem
1703   \global\c_strc_itemgroups_ignore\conditionalfalse}
1704
1705\def\strc_itemgroups_insert_item
1706  {\ifconditional\c_strc_itemgroups_text % again?
1707    % begin of item
1708   \orelse\ifconditional\c_strc_itemgroups_no_par % again?
1709    % begin of item
1710   \else
1711     \par % done twice?
1712   \fi
1713   \iftrialtypesetting\else
1714     \global\advanceby\c_strc_itemgroups_n_of_items\plusone
1715   \fi
1716   \ifconditional\c_strc_itemgroups_ignore\else
1717     \strc_itemgroups_optimize_breaks
1718     \strc_itemgroups_check_indenting
1719     \dontleavehmode
1720     \ifconditional\c_strc_itemgroups_indented_first
1721       \hskip-\parindent
1722     \fi
1723     \strc_itemgroups_make_symbol_box
1724     \strc_itemgroups_make_destination_box
1725     \ifconditional\c_strc_itemgroups_fitting
1726       \strc_itemgroups_make_fitting_box
1727     \orelse\ifdim\d_strc_itemgroups_asked_width>\zeropoint
1728       \strc_itemgroups_make_aligned_box
1729     \fi
1730     \lettonothing\m_strc_itemgroups_destination
1731     \ht\b_strc_itemgroups\strutheight % just in case a symbols is not yet available in
1732     \dp\b_strc_itemgroups\strutdepth  % the current run (more a mkii mp side artifact)
1733     \strc_itemgroups_check_for_repeated
1734     \ifdim\d_strc_itemgroups_asked_width<\zeropoint\relax
1735       \strc_itemgroups_handle_lapped_item_negative
1736     \else
1737       \ifzeropt\d_strc_itemgroups_asked_width
1738         \strc_itemgroups_calculate_list_width\plusone
1739       \else
1740         \strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting
1741       \fi
1742       \ifconditional\c_strc_itemgroups_text
1743         \strc_itemgroups_handle_groups_text_item
1744       \orelse\ifconditional\c_strc_itemgroups_inline
1745         \strc_itemgroups_handle_groups_inline_item
1746       \orelse\ifconditional\c_strc_itemgroups_txt
1747         \strc_itemgroups_handle_text_item
1748       \else
1749         \strc_itemgroups_handle_lapped_item_positive
1750       \fi
1751     \fi
1752     \c_strc_itemgroups_head\conditionalfalse
1753     \c_strc_itemgroups_sub\conditionalfalse
1754     \ifconditional\c_strc_itemgroups_indented_first
1755       \hskip\parindent
1756     \fi
1757   \fi
1758   \ignorepars} % \ignorespaces
1759
1760\def\strc_itemgroups_start_item_nop
1761  {\lettonothing\currentitemreference
1762   \strc_itemgroups_increment_item_counter
1763   \global\advanceby\c_strc_itemgroups_n_of_items\plusone
1764   \setbox\b_strc_itemgroups\hbox
1765     {\useitemgroupstyleandcolor\c!style\c!color
1766      \strc_itemgroups_used_symbol}%
1767   \strc_itemgroups_check_for_repeated
1768   \ignorepars} % \ignorespaces
1769
1770\defcsname\??itemgroupdistance\v!none\endcsname
1771  {\let\m_strc_itemgroups_text_distance\zeropoint}
1772
1773\defcsname\??itemgroupdistance\v!space\endcsname
1774  {\def\m_strc_itemgroups_text_distance{\interwordspace\s!plus\interwordstretch\s!minus\interwordshrink}}
1775
1776\defcsname\??itemgroupdistance\endcsname % catches empty value
1777  {\let\m_strc_itemgroups_text_distance\zeropoint}
1778
1779\protected\def\strc_itemgroups_set_text_item_distance
1780  {\edef\m_strc_itemgroups_text_distance{\itemgroupparameter\c!textdistance}%
1781   \ifempty\m_strc_itemgroups_text_distance
1782   % \let\m_strc_itemgroups_text_distance\zeropoint % safeguard elsewhere
1783   \orelse\ifcsname\??itemgroupdistance\m_strc_itemgroups_text_distance\endcsname
1784     \lastnamedcs
1785   \else
1786     \strc_itemgroups_set_text_item_distance_indeed
1787   \fi}
1788
1789\def\strc_itemgroups_set_text_item_distance_indeed
1790  {\assignvalue
1791     \m_strc_itemgroups_text_distance
1792     \m_strc_itemgroups_text_distance
1793     {.5\interwordspace\s!plus.5\emwidth}%
1794     {\interwordspace  \s!plus  \emwidth}%
1795     {\emwidth         \s!plus  \interwordstretch\s!minus\interwordshrink}}
1796
1797% \protected\def\strc_itemgroups_default_command
1798%   {\EveryPar{\ignorespaces}% needed ?
1799%    \ignorespaces}
1800
1801\protected\def\strc_itemgroups_default_command
1802  {\ignorepars} % \ignorespaces
1803
1804%D Special case:
1805
1806\protected\def\strc_itemgroups_head#text\par
1807  {\startitemgrouphead{#text}}
1808
1809%D The local commands:
1810
1811\ifdefined\item             \else         \let\item            \relax \fi % defined later
1812\ifdefined\sub              \else \aliased\let\sub             \relax \fi
1813\ifdefined\sym              \else \aliased\let\sym             \relax \fi
1814\ifdefined\ran              \else \aliased\let\ran             \relax \fi
1815\ifdefined\its              \else \aliased\let\its             \relax \fi
1816\ifdefined\mar              \else \aliased\let\mar             \relax \fi
1817\ifdefined\noitem           \else \aliased\let\noitem          \relax \fi
1818\ifdefined\itm              \else \aliased\let\itm             \relax \fi
1819\ifdefined\but              \else \aliased\let\but             \relax \fi
1820%ifdefined\nop              \else         \let\nop             \relax \fi % used often by myself
1821\ifdefined\txt              \else \aliased\let\txt             \relax \fi
1822\ifdefined\head             \else         \let\head            \relax \fi % defined later
1823\ifdefined\headsym          \else \aliased\let\headsym         \relax \fi
1824\ifdefined\startitem        \else         \let\startitem       \relax \fi % defined later
1825\ifdefined\stopitem         \else \aliased\let\stopitem        \relax \fi
1826\ifdefined\starthead        \else \aliased\let\starthead       \relax \fi
1827\ifdefined\stophead         \else \aliased\let\stophead        \relax \fi
1828\ifdefined\startspecialitem \else \aliased\let\startspecialitem\relax \fi
1829\ifdefined\stopspecialitem  \else \aliased\let\stopspecialitem \relax \fi
1830
1831\appendtoks
1832    \enforced\let\item            \strc_itemgroups_start_do_item
1833    \enforced\let\sub             \strc_itemgroups_start_subitem
1834    \enforced\let\sym             \strc_itemgroups_start_symbol
1835    \enforced\let\ran             \strc_itemgroups_start_edge
1836    \enforced\let\its             \strc_itemgroups_start_items
1837    \enforced\let\mar             \strc_itemgroups_start_margin
1838    \enforced\let\noitem          \strc_itemgroups_start_no_item
1839    \enforced\let\itm             \strc_itemgroups_start_do_item
1840    \enforced\let\but             \strc_itemgroups_start_button
1841    \enforced\let\nop             \strc_itemgroups_start_dummy
1842    \enforced\let\txt             \strc_itemgroups_start_text
1843    \enforced\let\head            \strc_itemgroups_head
1844    \enforced\let\headsym         \strc_itemgroups_start_head_sym
1845    \enforced\let\startitem       \startitemgroupitem
1846    \enforced\let\stopitem        \stopitemgroupitem
1847    \enforced\let\starthead       \startitemgrouphead
1848    \enforced\let\stophead        \stopitemgrouphead
1849    \enforced\let\startspecialitem\startspecialitemgroupitem
1850    \enforced\let\stopspecialitem \stopspecialitemgroupitem
1851\to \itemgroupcommands
1852
1853\ifx\currentinterface \s!english \else
1854
1855    \def\next#1#2{\ifcsname#1\endcsname\else\enforced\aliased\letcsname#1\endcsname#2\fi}
1856
1857    \etoksapp\itemgroupcommands{%
1858        \next{\v!item        }\strc_itemgroups_start_do_item
1859        \next{\v!sub         }\strc_itemgroups_start_subitem
1860        \next{\v!sym         }\strc_itemgroups_start_symbol
1861        \next{\v!ran         }\strc_itemgroups_start_edge
1862        \next{\v!head        }\strc_itemgroups_head
1863        \next{\v!its         }\strc_itemgroups_start_items
1864        \next{\v!mar         }\strc_itemgroups_start_margin
1865        \next{\v!txt         }\strc_itemgroups_start_text
1866        \next{\e!start\v!item}\startitemgroupitem
1867        \next{\e!stop \v!item}\stopitemgroupitem
1868        \next{\e!start\v!head}\startitemgrouphead
1869        \next{\e!stop \v!head}\stopitemgrouphead
1870    }
1871
1872  % \let\next\relax
1873
1874\fi
1875
1876\relaxvalueifundefined \v!item
1877\relaxvalueifundefined \v!sub
1878\relaxvalueifundefined \v!sym
1879\relaxvalueifundefined \v!ran
1880\relaxvalueifundefined \v!head
1881\relaxvalueifundefined \v!its
1882\relaxvalueifundefined \v!mar
1883\relaxvalueifundefined \v!txt
1884\relaxvalueifundefined {\e!start\v!item}
1885\relaxvalueifundefined {\e!stop \v!item}
1886\relaxvalueifundefined {\e!start\v!head}
1887\relaxvalueifundefined {\e!stop \v!head}
1888
1889%D A nice example of a plugin:
1890%D
1891%D \startbuffer
1892%D \startitemize[a,random,packed]
1893%D \startitem first  \stopitem \startitem second \stopitem
1894%D \startitem third  \stopitem \startitem fourth \stopitem
1895%D \stopitemize
1896%D
1897%D \startitemize[a,random,packed]
1898%D \startitem first  \stopitem \startitem second \stopitem
1899%D \startitem third  \stopitem \startitem fourth \stopitem
1900%D \stopitemize
1901%D
1902%D \startitemize[a,packed]
1903%D \startitem first  \stopitem \startitem second \stopitem
1904%D \startitem third  \stopitem \startitem fourth \stopitem
1905%D \stopitemize
1906%D \stopbuffer
1907%D
1908%D \typebuffer \getbuffer
1909
1910% better collectitems als conditional and a real plugin mechanism (some day)
1911
1912\newinteger\c_strc_itemgroups_collected_stored
1913\newinteger\c_strc_itemgroups_collected_done
1914\newinteger\c_strc_itemgroups_collected_current
1915
1916\let\strc_itemgroups_collected_store\relax
1917
1918\lettonothing\m_strc_itemgroups_collected
1919
1920\normalexpanded{\def\strc_itemgroups_collected_store#1\csname\e!stop\v!item\endcsname}%
1921  {\advanceby\c_strc_itemgroups_collected_stored\plusone
1922   \defcsname\??itemgroupstack\the\c_strc_itemgroups_collected_stored\endcsname
1923     {\startitemgroupitem#1\stopitemgroupitem}}
1924
1925\def\strc_itemgroups_collected_flush_randomize
1926  {\m_strc_itemgroups_collected}
1927
1928\def\strc_itemgroups_collected_flush_horizontal
1929  {\begingroup
1930   \scratchcounter\itemgroupparameter\c!n\relax
1931   \ifnum\c_strc_itemgroups_collected_done>\plusone
1932     \ifcase\modulonumber\scratchcounter\c_strc_itemgroups_collected_done\relax
1933       % compensate for rounding errors
1934       \hfill % \hskip\zeropoint plus \scaledpoint minus \scaledpoint
1935       \allowbreak
1936     \fi
1937   \fi
1938   \noindent % no \dontleavehmode
1939   \hbox to \dimexpr\availablehsize/\scratchcounter\relax{\m_strc_itemgroups_collected\hss}%
1940   \endgroup}
1941
1942\def\strc_itemgroups_collected_flush_indeed
1943  {\m_strc_itemgroups_collected
1944   \letcsname\??itemgroupstack\the\c_strc_itemgroups_collected_current\endcsname\undefined}
1945
1946\def\strc_itemgroups_collected_flush
1947  {\ifconditional\c_strc_itemgroups_randomize
1948     \getrandomcount\c_strc_itemgroups_collected_current\plusone\c_strc_itemgroups_collected_stored
1949   \else
1950     \advanceby\c_strc_itemgroups_collected_current\plusone
1951   \fi
1952   \ifcsname\??itemgroupstack\the\c_strc_itemgroups_collected_current\endcsname
1953     \edef\m_strc_itemgroups_collected{\lastnamedcs}%
1954     \ifconditional\c_strc_itemgroups_horizontal
1955       \strc_itemgroups_collected_flush_horizontal
1956     \else
1957       \strc_itemgroups_collected_flush_indeed
1958     \fi
1959     \advanceby\c_strc_itemgroups_collected_done\plusone
1960   \fi
1961   \ifnum\c_strc_itemgroups_collected_done<\c_strc_itemgroups_collected_stored
1962     \expandafter\strc_itemgroups_collected_flush
1963   \fi}
1964
1965\protected\permanent\def\stopcollectitems % todo: frozen
1966  {\ifconditional\c_strc_itemgroups_collecting
1967     \c_strc_itemgroups_collected_done   \zerocount
1968     \c_strc_itemgroups_collected_current\zerocount
1969     \ifnum\c_strc_itemgroups_collected_stored>\zerocount
1970       \ifconditional\c_strc_itemgroups_horizontal
1971         \strc_itemgroups_before_command
1972         \c_strc_itemgroups_first\conditionalfalse
1973         \strc_itemgroups_collected_flush
1974        %\strc_itemgroups_after_command % triggered elsewhere
1975       \else
1976         \strc_itemgroups_collected_flush
1977       \fi
1978     \fi
1979   \fi}
1980
1981\protected\permanent\def\startcollectitems % todo: frozen
1982  {\ifconditional\c_strc_itemgroups_collecting
1983     \c_strc_itemgroups_collected_stored\zerocount
1984     \enforced\letcsname\e!start\v!item\endcsname\strc_itemgroups_collected_store
1985   \fi}
1986
1987%D Left-overs:
1988
1989\permanent\protected\def\item % todo: frozen
1990  {\strc_itemgroups_item_alone}
1991
1992\tolerant\def\strc_itemgroups_item_alone[#category]#:#text\par
1993  {\ifempty{#category}%
1994     \startitemgroup[\v!itemize]%
1995   \else
1996     \startitemgroup[#category]%
1997   \fi
1998   \startitem#text\stopitem
1999   \stopitemgroup}
2000
2001\permanent\protected\def\head % todo: frozen
2002  {\strc_itemgroups_head_alone}
2003
2004\def\strc_itemgroups_head_alone[#category]#head\par#body\par
2005  {\ifempty{#category}%
2006     \startitemgroup[\v!itemize]%
2007   \else
2008     \startitemgroup[#category]%
2009   \fi
2010   \starthead{#head}#body\stophead
2011   \stopitemgroup}
2012
2013\pushoverloadmode
2014
2015\permanent\protected\defcsname\e!start\v!item\endcsname
2016  {\startitemgroup[\v!itemize]%
2017   \startitemgroupitem
2018   \enforced\letcsname\e!stop\v!item\endcsname\strc_itemgroups_stop_item}
2019
2020\aliased\letcsname\e!stop\v!item\endcsname\relax
2021
2022\permanent\protected\def\strc_itemgroups_stop_item
2023  {\stopitemgroupitem
2024   \stopitemgroup}
2025
2026\popoverloadmode
2027
2028% \def\sym#text%
2029%   {\noindent
2030%    \begingroup
2031%    \setbox\scratchbox\hbox{\settrialtypesetting#text}%
2032%    \setbox\scratchbox\hbox\ifdim\wd\scratchbox<1em to 1.5\else spread 1\fi em{#text\hfil}%
2033%    \normalexpanded{\box\scratchbox\endgroup\hangindent\the\wd\scratchbox}%
2034%    \ignorepars} % \ignorespaces
2035
2036%D End of plugin.
2037
2038%D Something for tables:
2039
2040\permanent\tolerant\protected\def\itemtag[#reference]% we can reuse more
2041  {% what if empty
2042   \def\currentitemreference{#reference}%
2043   \iftrialtypesetting
2044     \strc_counters_save\v_strc_itemgroups_counter
2045     \strc_itemgroups_increment_item_counter
2046     \strc_itemgroups_insert_item_tag_indeed
2047     \strc_counters_restore\v_strc_itemgroups_counter
2048   \else
2049     \strc_itemgroups_increment_item_counter
2050     \strc_itemgroups_insert_item_tag_indeed
2051   \fi}
2052
2053\def\strc_itemgroups_insert_item_tag_indeed
2054  {\letitemgroupparameter\c!distance\zeropoint
2055   %letitemgroupparameter\c!width\zeropoint
2056   \strc_itemgroups_make_symbol_box
2057   \strc_itemgroups_make_destination_box
2058   \lettonothing\m_strc_itemgroups_destination
2059   \ht\b_strc_itemgroups\strutheight
2060   \dp\b_strc_itemgroups\strutdepth
2061   \box\b_strc_itemgroups
2062   \ignorepars} % \ignorespaces
2063
2064%D New per 2023-08-01
2065
2066\newdimension\d_strc_itemgroups_inbetween_table
2067\newdimension\d_strc_itemgroups_column_distance
2068\newdimension\d_strc_itemgroups_column_width
2069
2070\def\strc_itemgroups_table_begin
2071  {\NC}
2072
2073\def\strc_itemgroups_table_end_row
2074  {\NR
2075   \ifzerodim\d_strc_itemgroups_inbetween_table\orelse\ifnum
2076     \numexpression
2077       \c_strc_itemgroups_n_of_items/\c_strc_itemgroups_columns
2078     \relax<\numexpression
2079       \c_strc_itemgroups_max_items /\c_strc_itemgroups_columns
2080     \relax
2081        \noalign{\m_strc_itemgroups_inbetween}%
2082      % \TB[\the\d_strc_itemgroups_inbetween_table]%
2083   \fi}
2084
2085\noaligned\def\strc_itemgroups_table_end
2086  {\ifcase\numexpression\c_strc_itemgroups_n_of_items mod \c_strc_itemgroups_columns\relax
2087     \expandafter\strc_itemgroups_table_end_row
2088   \fi}
2089
2090\protected\def\strc_itemgroups_table_wrapup
2091  {\iftrialtypesetting\orelse\ifcase\c_tabl_tabulate_column\else
2092     \beginlocalcontrol % horrible hack to prevens crcr issues
2093     \expandafter\endlocalcontrol\expandedloop
2094       \numexpr\c_tabl_tabulate_column+\plusone\relax
2095       \c_tabl_tabulate_nofcolumns
2096       \plusone
2097       {\startignoreditem\strut\stopignoreditem}%
2098   \fi}
2099
2100\let\strc_itemgroups_table_pickup\relax
2101
2102\setupitemgroup[\c!columndistance=\emwidth]
2103
2104\lettonothing\m_strc_itemgroups_after
2105\lettonothing\m_strc_itemgroups_inbetween
2106
2107\tolerant\permanent\protected\def\strc_itemgroups_start_table[#1]#*[#S#2]#*[#S#3]%
2108  {\ifcase\currentitemlevel\relax
2109     \startitemgroup[#1][#2][#3]%
2110     \itemgroupparameter\c!before
2111   \orelse\ifhmode
2112     \strut
2113     \startitemgroup[#1][#2][#3]%
2114     \ifconditional\c_strc_itemgroups_overlay
2115       \blank[\v!overlay]%
2116     \else
2117       \itemgroupparameter\c!before
2118     \fi
2119   \else
2120     \startitemgroup[#1][#2][#3]%
2121     \itemgroupparameter\c!before
2122   \fi
2123   \edef\m_strc_itemgroups_after    {\itemgroupparameter\c!after}%
2124   \edef\m_strc_itemgroups_inbetween{\itemgroupparameter\c!inbetween}%
2125   \setbox\scratchbox\vbox{\m_strc_itemgroups_inbetween}%
2126   \d_strc_itemgroups_inbetween_table\htdp\scratchbox
2127   \letitemgroupparameter\c!before\relax
2128   \letitemgroupparameter\c!after\relax
2129   \letitemgroupparameter\c!inbetween\relax
2130   \c_strc_itemgroups_columns\itemgroupparameter\c!n
2131   \let\strc_itemgroups_begin\strc_itemgroups_table_begin
2132   \let\strc_itemgroups_end  \strc_itemgroups_table_end
2133   %
2134   % horrible ... we have \dividebydsize\textwidth{1em}{3}
2135   %
2136   \scratchdistance\itemgroupparameter\c!columndistance
2137   \d_strc_itemgroups_column_distance\dimexpr\leftskip+\rightskip\relax
2138   \d_strc_itemgroups_column_width\hsize
2139   \c_strc_itemgroups_no_par\conditionaltrue % blocks a par that interferes with tagging
2140   \advanceby\d_strc_itemgroups_column_width   -\c_strc_itemgroups_columns\d_strc_itemgroups_column_distance
2141   \divideby \d_strc_itemgroups_column_width    \c_strc_itemgroups_columns
2142   \advanceby\d_strc_itemgroups_column_distance \scratchdistance
2143   \advanceby\d_strc_itemgroups_column_width   -\scratchdistance
2144   \advanceby\d_strc_itemgroups_column_width    \dimexpr\scratchdistance/\c_strc_itemgroups_columns\relax
2145   %
2146   \c_strc_itemgroups_optimize\zerocount % otherwise we inject vertical breaks between struts
2147   % inlining confusses the verbose name parser
2148   \normalexpanded{\strc_itemgroups_table_bootstrap
2149     \csname\e!start#1\v!table\endcsname
2150     \csname\e!stop #1\v!table\endcsname % watch the 'l' specification below, maybe a format key
2151     {\expandedrepeat \c_strc_itemgroups_columns {|p(\the\d_strc_itemgroups_column_width)l}|}}}
2152
2153\protected\def\strc_itemgroups_table_bootstrap#1#2#3%
2154  {\protected\def\strc_itemgroups_table_pickup##L#1##R#2##1%
2155     {\tabl_tabulate_disable_tagging
2156      \starttabulate[#3][\c!before=,\c!after=,\c!split=\v!no,\c!unit=\the\d_strc_itemgroups_column_distance]%
2157        ##1\relax\strc_itemgroups_table_wrapup
2158      \stoptabulate
2159      \normalexpanded{\stopitemgroup\m_strc_itemgroups_after}}%
2160   \strc_itemgroups_table_pickup}
2161
2162\appendtoks
2163    \frozen\instance\protected\edefcsname\e!stop \currentitemgroup\v!table\endcsname
2164      {}% {\strc_itemgroups_stop_table}
2165    \frozen\instance\protected\edefcsname\e!start\currentitemgroup\v!table\endcsname
2166      {\strc_itemgroups_start_table[\currentitemgroup]}%
2167\to \everydefineitemgroup
2168
2169%D Done again.
2170
2171\setupitemgroup
2172  [\c!margin=\zeropoint,
2173   \c!leftmargin=\zeropoint,
2174   \c!rightmargin=\zeropoint,
2175   \c!leftmargindistance=\zeropoint,
2176   \c!rightmargindistance=\zeropoint,
2177   \c!indentnext=\v!yes,
2178   \c!width=1.5\emwidth,
2179   \c!factor=0,
2180  %\c!distance=.5em, % is now:
2181   \c!step=.5\emwidth, % deals with broad
2182   \c!distance=\zeropoint,
2183  %\c!align=\v!normal, % definitely not \v!normal !
2184  %\c!symalign=,
2185  %\c!color=,
2186  %\c!indenting=, % untouched if empty
2187  %\c!style=,
2188   \c!marstyle=\v!type,
2189  %\c!symstyle=,
2190  %\c!headstyle=,
2191  %\c!marcolor=,
2192  %\c!symcolor=,
2193  %\c!headcolor=,
2194  %\c!beforehead=,
2195   \c!symcolor=\itemgroupparameter\c!color, % new per 2012.01.17
2196   \c!symstyle=\itemgroupparameter\c!style, % new per 2012.01.17
2197   \c!afterhead=\blank,
2198   \c!before=\blank,
2199   \c!inbetween=\blank,
2200   \c!after=\blank,
2201  %\c!stopper=.,
2202   \c!placestopper=\v!yes,
2203   \c!stopper=.,
2204  %\c!inner=,
2205   \c!n=2,
2206   \c!items=4,
2207   \c!levels=10,
2208   \c!lefttext=(,
2209   \c!righttext=),
2210   \c!start=1,
2211   \c!packcriterium=\zerocount,
2212   \c!criterium=\v!all, % permits 0 and negative numbers
2213  %\c!option=,
2214   \c!textdistance=\v!space, % none big medium small <dimension>
2215   \c!lasttextseparator=\itemgroupparameter\c!textseparator,
2216  %\c!lasttextseparator=,
2217   \c!command=\strc_itemgroups_default_command,
2218   \c!indenting=\v!next,
2219  %\c!alignsymbol=v!no,
2220   \c!symbol=\currentitemlevel,
2221   \c!prefix=\v!no,
2222  %\c!prefixstopper=.,
2223  %\c!prefixseparatorset=,
2224  %\c!prefixconversion=,
2225  %\c!prefixconversionset=,
2226  %\c!prefixset=,
2227  %\c!prefixsegments=1:100,
2228   \c!prefixconnector=.,
2229   \c!numberseparatorset=,
2230   \c!numberconversionset=,
2231   \c!numberstopper=.,
2232   \c!numbersegments=1]
2233
2234\defineitemgroup
2235  [\v!itemize]
2236
2237%D This is really ugly I should get rid of the global mess, whuch is a side
2238%D effect of the simple \type {\item} interface that we're stuck with for
2239%D compatibility reasons. See footnotes for usage. It's probablynot robust
2240%D for mixed itemgroups so in the end I need to get rid of the globals. One
2241%D problem is that counters are set.
2242
2243\defineitemgroup
2244  [\v!itemize:\v!note]
2245
2246\def\strc_itemgroups_push
2247  {\edef\strc_itemgroups_pop
2248     {\xdef\noexpand\currentitemlevel{\currentitemlevel}%
2249      \global\c_strc_itemgroups_nesting     \the\c_strc_itemgroups_nesting     \relax
2250      \global\c_strc_itemgroups_column_depth\the\c_strc_itemgroups_column_depth\relax}%
2251   \global\c_strc_itemgroups_column_depth\zerocount
2252   \global\c_strc_itemgroups_nesting     \zerocount
2253   \glet\currentitemlevel\!!zerocount
2254   \enforced\permanent\protected\def\startitemize{\startitemgroup[\v!itemize:\v!note]}%
2255   \enforced\permanent\protected\def\stopitemize {\stopitemgroup}}
2256
2257\let\strc_itemgroups_pop\relax
2258
2259\protect \endinput
2260