[NTG-context] packed list only if items > 5

Tomas Hala tomas.hala at mendelu.cz
Fri Nov 15 00:04:03 CET 2019


Hi Pablo,

I am not sure if the itemize environment can be configured on the fly.

The following code should solve your problem:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecounter[minforpacked] \setcounter[minforpacked][5]

\def\mystartitemize#1\stopitemize{%
        \definecounter[mycounter]
        {\def\startitem##1\stopitem{\incrementcounter[mycounter]}#1}
        \ifnum \rawcountervalue[mycounter]>\rawcountervalue[minforpacked] \setupitemize[packed]\fi
        \startitemize#1\stopitemize}

\starttext

\mystartitemize %normal
    \dorecurse{2}{\startitem text\stopitem}
\stopitemize
\thinrule
\mystartitemize %packed
    \dorecurse{7}{\startitem text\stopitem}
\stopitemize

\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Best wishes,

Tomáš 

Thu, Nov 14, 2019 ve 09:07:21PM +0100 Pablo Rodriguez napsal(a):
# Dear list,
# 
# I have the following sample:
# 
#     \starttext
#     \startitemize[\ifnum\currentnofitems>5 packed\fi]
#     \dorecurse{7}
#         {\startitem\currentitemnumber/\currentnofitems\stopitem}
#     \stopitemize
#     \stoptext
# 
# Is there any way to get a packed list if and only if it contains more
# than a given number of items?
# 
# Many thanks for your help,
# 
# Pablo
# --
# http://www.ousia.tk
# ___________________________________________________________________________________
# If your question is of interest to others as well, please add an entry to the Wiki!
# 
# maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
# webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
# archive  : https://bitbucket.org/phg/context-mirror/commits/
# wiki     : http://contextgarden.net
# ___________________________________________________________________________________

                                         Tomáš Hála
--------------------------------------------------------------------
Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky
Zemědělská 1, CZ-613 00 Brno,  tel. +420 545 13 22 28
--------------------------------------------------------------------
http://akela.mendelu.cz/~thala


More information about the ntg-context mailing list