Difference between revisions of "Enumerations"

From Wiki
Jump to navigation Jump to search
(Added section "Horizontal spacing")
(35 intermediate revisions by 13 users not shown)
Line 1: Line 1:
< [[Structurals]]
 
 
 
= Overview of commands =
 
= Overview of commands =
  
Line 14: Line 12:
 
</texcode>
 
</texcode>
  
The <cmd>startitemize</cmd> command takes optional parameters (see the documentation of <cmd>startitemgroup</cmd> for a complete list), for example a number conversion may be given, with the following predefined types:
+
The {{cmd|startitemize}} command takes optional parameters (see the documentation of {{cmd|startitemgroup}} for a complete list), for example a number conversion may be given, with the following predefined types:
  
 
<table>
 
<table>
Line 28: Line 26:
 
</table>
 
</table>
  
It is also possible to define your own number conversions; see [[User-Defined Enumerations]]. If you have loaded the [[Chinese]] module, you can also use <tt>c</tt> (and some more) for Chinese numbers.
+
It is also possible to define your own number conversions; see [[User-Defined Enumerations]]. You can also use <tt>cn</tt> (and some more) for Chinese numbers.
 +
 
 +
When the selected language is Slovenian or Spanish, items are numbered using their proper alphabets (the Slovenian enumeration includes č, š and ž; the Spanish enumeration includes ñ). You can change to the international enumeration with <code>alphabetic</code>, <code>Alphabetic</code>.
  
 
Additional parameters include
 
Additional parameters include
 
* <tt>continue</tt> (start where the previous itemization  was finished, to allow text injections),
 
* <tt>continue</tt> (start where the previous itemization  was finished, to allow text injections),
 +
* <tt>reverse</tt> (numbers the items in reverse, i.e. descending, order),
 
* <tt>packed</tt> (less vertical space between items),  
 
* <tt>packed</tt> (less vertical space between items),  
 
* <tt>inmargin</tt> (place enumeration symbols into the margin), and
 
* <tt>inmargin</tt> (place enumeration symbols into the margin), and
Line 38: Line 39:
 
== \setupitemize ==
 
== \setupitemize ==
  
To change the general layout of enumerations, there is <cmd>setupitemize</cmd>.  It accepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply.   
+
To change the general layout of enumerations, there is {{cmd|setupitemize}}.  It accepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply.   
  
You will find more about <cmd>setupitemize</cmd> at <cmd>defineitemgroup</cmd>.
+
You will find more about {{cmd|setupitemize}} at {{cmd|setupitemgroup}} and {{cmd|defineitemgroup}}.
 +
 
 +
== \item (and friends) ==
 +
 
 +
* {{cmd|item}} to print ordinary items
 +
* {{cmd|sym}} to print an item with a custom symbol
 +
* {{cmd|mar}} to print an item with margin text
 +
* {{cmd|sub}} to print an item with a continuation mark
 +
* {{cmd|its}} to print an item with a row of marks (for response ranges)
 +
* {{cmd|ran}} to print a range for the {{cmd|its}} row
 +
* {{cmd|head}} to print a head within the list
 +
* {{cmd|but}} to print an item whose mark is an interactive button
  
 
== \defineitemgroup ==
 
== \defineitemgroup ==
 
   
 
   
For finer control, it is advisable to create new types of itemization, using the command <cmd>defineitemgroup</cmd> (which unfortunately seems undocumented).  For example:
+
For finer control, it is advisable to create new types of itemization, using the command {{cmd|defineitemgroup}}.  For example:
  
 
{|
 
{|
Line 83: Line 95:
 
|
 
|
 
| <context>
 
| <context>
 +
  \setuppapersize[A7]
 
   \defineitemgroup[ltxitm][levels=5]
 
   \defineitemgroup[ltxitm][levels=5]
 
   %
 
   %
Line 116: Line 129:
 
= Customization details and examples =
 
= Customization details and examples =
  
==Labels==
+
==Manual labels==
  
 
{|
 
{|
Line 123: Line 136:
 
  |-
 
  |-
 
  |<context>
 
  |<context>
 +
\setuppapersize[A8,landscape]
 
\starttext
 
\starttext
 
\setupitemize[left=(, right=), margin=4em, stopper=]
 
\setupitemize[left=(, right=), margin=4em, stopper=]
Line 142: Line 156:
 
|-
 
|-
 
|<context>
 
|<context>
 +
\setuppapersize[A8,landscape]
 
\starttext
 
\starttext
 
\startitemize[R,fit][itemalign=flushright,stopper={ --- }]
 
\startitemize[R,fit][itemalign=flushright,stopper={ --- }]
Line 155: Line 170:
 
|-
 
|-
 
|<context>
 
|<context>
 +
\setuppapersize[A8,landscape]
 
\starttext
 
\starttext
 
\startitemize[n,packed][start=42,stopper={\space}]
 
\startitemize[n,packed][start=42,stopper={\space}]
Line 170: Line 186:
 
|-
 
|-
 
|<context>
 
|<context>
 +
\setuppapersize[A8,landscape]
 
\starttext
 
\starttext
 
\startitemize[a,packed]
 
\startitemize[a,packed]
Line 183: Line 200:
 
\stoptext
 
\stoptext
 
</context>
 
</context>
|Irregular item types can be inserted via [[cmd:sym|<tt>\sym{#1}</tt>]] [http://article.gmane.org/gmane.comp.tex.context/61731]:
+
|Irregular item types can be inserted via {{cmd|sym}}: <tt>\sym{#1}</tt> [http://article.gmane.org/gmane.comp.tex.context/61731]:
 
<texcode>
 
<texcode>
 
\startitemize[a]
 
\startitemize[a]
Line 199: Line 216:
 
these insertions: it continues after the last one as if they didn't exist.
 
these insertions: it continues after the last one as if they didn't exist.
 
  |}
 
  |}
 +
 +
== Expanded subnumbers ==
 +
 +
To specify that item numbers should also be leading numbers in any subitemizations, use the {{code|repeat}} keyword.
 +
 +
<context source=yes>
 +
\setuppapersize[A7]
 +
 +
% Indentation is a bit odd; cannot reproduce off-wiki.
 +
 +
\setupitemgroup[itemize][1][n,repeat]
 +
\setupitemgroup[itemize][2][a,repeat]
 +
\setupitemgroup[itemize][3][n]
 +
 +
This is our item list:
 +
 +
\startitemize
 +
    \item ...          % 1
 +
    \startitemize
 +
        \item ...      % 1.a
 +
        \startitemize
 +
            \item ...  % 1.a.1
 +
        \stopitemize
 +
        \item ...      % 1.b
 +
        \startitemize
 +
            \item ...  % 1.b.1
 +
            \item ...  % 1.b.2
 +
        \stopitemize
 +
    \stopitemize
 +
    \item ...          % 1
 +
\stopitemize
 +
</context>
 +
 +
To add change the separator mark, you have to setup the {{code|numberseparatorset}} key of the {{code|itemgroup:itemize}} counter. This example removes the separator mark entirely.
 +
 +
<context source=yes mode=mkiv>
 +
\setuppapersize[A7]
 +
 +
\setupitemgroup[itemize][1][n,repeat][width=1em]
 +
\setupitemgroup[itemize][2][a,repeat][width=2em]
 +
\setupitemgroup[itemize][3][n]      [width=3em]
 +
 +
\defineseparatorset[none][][]
 +
 +
\setupcounter[itemgroup:itemize][numberseparatorset=none]
 +
\startitemize
 +
    \item ...          % 1
 +
    \startitemize
 +
        \item ...      % 1a
 +
        \startitemize
 +
            \item ...  % 1a1
 +
        \stopitemize
 +
    \stopitemize
 +
\stopitemize
 +
</context>
  
 
== Vertical spacing ==
 
== Vertical spacing ==
Line 224: Line 296:
  
 
<context>
 
<context>
 +
\setuppapersize[A7]
 
\setuplayout[scale=0.8,width=9cm]
 
\setuplayout[scale=0.8,width=9cm]
 
\setupwhitespace[big]
 
\setupwhitespace[big]
 
\definesymbol[1][$\triangleright$]
 
\definesymbol[1][$\triangleright$]
 
\startcolumns
 
\startcolumns
{\bf joinedup:}                \startitemize[joinedup]                \item test \item test \stopitemize after \par
+
{\bf joinedup:}                \par before \startitemize[joinedup]                \item test \item test \stopitemize after \par
{\bf joinedup,nowhite:}        \startitemize[joinedup,nowhite]        \item test \item test \stopitemize after \column
+
{\bf nowhite:}                \par before \startitemize[nowhite]                \item test \item test \stopitemize after \par
{\bf joinedup,nowhite,before:} \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize after \par
+
{\bf joinedup,nowhite:}        \par before \startitemize[joinedup,nowhite]        \item test \item test \stopitemize after \column
{\bf joinedup,nowhite,after:}  \startitemize[joinedup,nowhite,after]  \item test \item test \stopitemize after
+
{\bf joinedup,nowhite,before:} \par before \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize after \par
 +
{\bf joinedup,nowhite,after:}  \par before \startitemize[joinedup,nowhite,after]  \item test \item test \stopitemize after
 
\stopcolumns
 
\stopcolumns
 
</context>
 
</context>
 +
 +
 +
 +
It is also (at least in mkiv) possible to do
 +
<texcode>
 +
Text before
 +
\startitemize[before={\blank[small]},after={\blank[small]},inbetween={\blank[medium]}]
 +
\item test
 +
\item test
 +
\stopitemize
 +
Text after
 +
</texcode>
 +
to control the vertical space.
 +
 +
 +
 +
To prevent an unwanted pagebreak before the list, there is an <tt>intro</tt> parameter :
 +
<texcode>
 +
The following list is on the same page as this paragraph :
 +
\startitemize[intro]
 +
  \startitem foo \stopitem
 +
  \startitem bar \stopitem
 +
\stopitemize
 +
</texcode>
  
 
==Horizontal spacing==
 
==Horizontal spacing==
Line 257: Line 355:
 
|
 
|
 
|<context>
 
|<context>
 +
\setuppapersize[A7]
 
\startitemize[width=1em,distance=0pt]
 
\startitemize[width=1em,distance=0pt]
 
\item Using width=1em,distance=0pt
 
\item Using width=1em,distance=0pt
Line 306: Line 405:
 
|
 
|
 
|<context>
 
|<context>
 +
\setuppapersize[A8,landscape]
 
\starttext
 
\starttext
  
Line 321: Line 421:
 
\item one
 
\item one
 
\item two
 
\item two
 +
\stopitemize
 +
 +
And the text continues after the list
 +
 +
\stoptext
 +
 +
</context>
 +
|}
 +
 +
From a discussion on the mailing list, the following was suggested (note that you have to enclose your items in {{cmd|startitem}} and {{cmd|stopitem}}, using  {{cmd|item}} only does not work):
 +
 +
{|
 +
! width="35%"|
 +
! width="5%"|
 +
! width="60%"|
 +
|-
 +
| <texcode>
 +
\starttext
 +
 +
Some previous sentence before the list
 +
 +
\startitemize[a,horizontal,three]
 +
\startitem first \stopitem
 +
\startitem second \stopitem
 +
\startitem third \stopitem
 +
\startitem fourth \stopitem
 +
\startitem fifth \stopitem
 +
\startitem sixth \stopitem
 +
\stopitemize
 +
 +
And the text continues after the list
 +
 +
\stoptext
 +
</texcode>
 +
|
 +
|<context>
 +
\setuppapersize[A8,landscape]
 +
\starttext
 +
 +
Some previous sentence before the list
 +
 +
\startitemize[a,horizontal,two]
 +
\startitem first \stopitem
 +
\startitem second \stopitem
 +
\startitem third \stopitem
 +
\startitem fourth \stopitem
 
\stopitemize
 
\stopitemize
  
Line 333: Line 479:
  
 
== Randomizing items ==
 
== Randomizing items ==
It is possible to make ConTeXt randomize the items in enumerations; this can come handy when, e.g., typesetting tests.  You have to add a <tt>random</tt> option to <cmd>startitemize</cmd>.  There are two caveats:
+
It is possible to make ConTeXt randomize the items in enumerations; this can come handy when, e.g., typesetting tests.  You have to add a <tt>random</tt> option to {{cmd|startitemize}}.  There is a caveat:
# You have to say <cmd>startitem</cmd> ... <cmd>stopitem</cmd> instead of <cmd>item</cmd> ... .
+
# You have to say {{cmd|startitem}} ... {{cmd|stopitem}} instead of {{cmd|item}} ... .
# Somehow the first item does not get randomized. (I learned from the mailing list - thanks, Aditya! - that adding a <cmd>nextrandom</cmd> somewhere earlier helps.)
 
 
Example:
 
Example:
  
Line 344: Line 489:
 
  |-
 
  |-
 
  | <texcode>
 
  | <texcode>
\nextrandom
 
 
\startitemize[random]
 
\startitemize[random]
 
\startitem A \stopitem
 
\startitem A \stopitem
Line 354: Line 498:
 
|
 
|
 
| <context>
 
| <context>
\nextrandom
 
 
\startitemize[random]
 
\startitemize[random]
 
\startitem A \stopitem
 
\startitem A \stopitem
Line 385: Line 528:
 
  |
 
  |
 
  | <context>
 
  | <context>
 +
\setuppapersize[A8,landscape]
 
\starttext
 
\starttext
 
\startitemize[n]
 
\startitemize[n]
Line 394: Line 538:
 
As seen in \in{item}[foo] on page \at{page}[foo], B is teh shizzle.
 
As seen in \in{item}[foo] on page \at{page}[foo], B is teh shizzle.
 
\stoptext
 
\stoptext
 +
</context>
 +
|}
 +
 +
== Associative lists ==
 +
Wolfgang suggested [https://mailman.ntg.nl/pipermail/ntg-context/2022/105437.html] a clever use of alignment options using which one can create associative lists (for example, to pose associative questions):
 +
{|
 +
! width="50%"|
 +
! width="5%"|
 +
! width="45%"|
 +
|-
 +
| <texcode>
 +
\bTABLE
 +
[frame=off,
 +
width=.4\textwidth,
 +
columndistance=.2\textwidth,
 +
align={normal,lohi}]
 +
\bTR
 +
\bTD
 +
\startitemize[8,random][align=righttoleft]
 +
\startitem {\lefttoright One} \stopitem
 +
\startitem {\lefttoright Two} \stopitem
 +
\startitem {\lefttoright Three} \stopitem
 +
\stopitemize
 +
\eTD
 +
\bTD
 +
\startitemize[8,random]
 +
\startitem First \stopitem
 +
\startitem Second \stopitem
 +
\startitem Third \stopitem
 +
\startitem Foruth \stopitem
 +
\stopitemize
 +
\eTD
 +
\eTR
 +
\eTABLE
 +
</texcode>
 +
|
 +
| <context>
 +
\setuppapersize[A8,landscape]
 +
\bTABLE[frame=off,width=.4\textwidth,columndistance=.2\textwidth,align={normal,lohi}]
 +
\bTR
 +
\bTD
 +
\startitemize[8,random][align=righttoleft]
 +
\startitem {\lefttoright One} \stopitem
 +
\startitem {\lefttoright Two} \stopitem
 +
\startitem {\lefttoright Three} \stopitem
 +
\stopitemize
 +
\eTD
 +
\bTD
 +
\startitemize[8,random]
 +
\startitem First \stopitem
 +
\startitem Second \stopitem
 +
\startitem Third \stopitem
 +
\startitem Foruth \stopitem
 +
\stopitemize
 +
\eTD
 +
\eTR
 +
\eTABLE
 
</context>
 
</context>
 
|}
 
|}
  
 
=Further Reading=
 
=Further Reading=
* [[\startitemize]]
+
 
 +
* [[User-Defined Enumerations]]: Defining a new numbering scheme.
 +
* [[Command/startitemize]]
 +
* The source: {{src|strc-itm.mkvi}}
 +
* [[Description]] (definition lists)
 +
 
 +
[[Category:Basics]]

Revision as of 12:03, 16 April 2022

Overview of commands

\startitemize

The most basic form of using enumerations in ConTeXt is

 \startitemize
 \item here we list the points,
 \item one after the other.
 \stopitemize

The \startitemize command takes optional parameters (see the documentation of \startitemgroup for a complete list), for example a number conversion may be given, with the following predefined types:

n or NUsually the default: a numbered list
mA numbered list, with lowercase (“medieval”, aka “oldstyle”) numbers.
18Different kinds of bullets. All items get the same symbol.
aItems are numbered a., b., c., …
AItems are numbered A., B., C., …
AKItems are numbered A., B., C., …, in small caps.
rItems are numbered in lowercase Roman numerals.
RItems are numbered in uppercase Roman numerals.
KRItems are numbered in uppercase Roman numerals, small caps style.

It is also possible to define your own number conversions; see User-Defined Enumerations. You can also use cn (and some more) for Chinese numbers.

When the selected language is Slovenian or Spanish, items are numbered using their proper alphabets (the Slovenian enumeration includes č, š and ž; the Spanish enumeration includes ñ). You can change to the international enumeration with alphabetic, Alphabetic.

Additional parameters include

  • continue (start where the previous itemization was finished, to allow text injections),
  • reverse (numbers the items in reverse, i.e. descending, order),
  • packed (less vertical space between items),
  • inmargin (place enumeration symbols into the margin), and
  • text (paragraph enumerations, formats the items as a running text).

\setupitemize

To change the general layout of enumerations, there is \setupitemize. It accepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply.

You will find more about \setupitemize at \setupitemgroup and \defineitemgroup.

\item (and friends)

  • \item to print ordinary items
  • \sym to print an item with a custom symbol
  • \mar to print an item with margin text
  • \sub to print an item with a continuation mark
  • \its to print an item with a row of marks (for response ranges)
  • \ran to print a range for the \its row
  • \head to print a head within the list
  • \but to print an item whose mark is an interactive button

\defineitemgroup

For finer control, it is advisable to create new types of itemization, using the command \defineitemgroup. For example:

  \defineitemgroup[ltxitm][levels=5]
  %
  \setupitemgroup[ltxitm][1][1]
  \setupitemgroup[ltxitm][2][2]
  \setupitemgroup[ltxitm][3][3,packed]
  \setupitemgroup[ltxitm][4][4,packed]
  \setupitemgroup[ltxitm][5][5,packed]
  %
  \starttext
  %
  \startltxitm
    \item Consider
      \startltxitm
      \item this part
      \item and also these subpoints:
        \startltxitm
        \item one
        \item two
        \item three
          \startltxitm
            \item threeandahalf
          \stopltxitm
        \item four
        \stopltxitm
      \stopltxitm
  \stopltxitm
  %
  \stoptext

Customization details and examples

Manual labels

\setupitemize[left=(, right=), margin=4em, stopper=]
\startitemize[a]
\item one item,
\item next item.
\stopitemize
  • margin is from left margin to start of item text
  • stopper is the dot (or whatever) after the "number"
\startitemize[R,fit][itemalign=flushright,stopper={ --- }]
\dorecurse{5}{\item blablabla}
\stopitemize

You can tell ConTeXt to begin item numbering at given offset [1]:

\startitemize[n,fit][start=42,stopper={\space}]
\dorecurse{3}{\item Lorem ipsum}
\stopitemize
Irregular item types can be inserted via \sym: \sym{#1} [2]:
\startitemize[a]
\item bar
\sym{1.}  foo
\sym{2.}  bar
\sym{3.}  foo
\sym{5.}  bar
\sym{8.}  foo
\sym{13.} bar
\item foo
\stopitemize

Note that the original (alphabetically enumerated) order is not affected by these insertions: it continues after the last one as if they didn't exist.

Expanded subnumbers

To specify that item numbers should also be leading numbers in any subitemizations, use the repeat keyword.

\setuppapersize[A7]

% Indentation is a bit odd; cannot reproduce off-wiki.

\setupitemgroup[itemize][1][n,repeat]
\setupitemgroup[itemize][2][a,repeat]
\setupitemgroup[itemize][3][n]

This is our item list:

\startitemize
    \item ...          % 1
    \startitemize
        \item ...      % 1.a
        \startitemize
            \item ...  % 1.a.1
        \stopitemize
        \item ...      % 1.b
        \startitemize
            \item ...  % 1.b.1
            \item ...  % 1.b.2
        \stopitemize
    \stopitemize
    \item ...          % 1
\stopitemize

To add change the separator mark, you have to setup the numberseparatorset key of the itemgroup:itemize counter. This example removes the separator mark entirely.

\setuppapersize[A7]

\setupitemgroup[itemize][1][n,repeat][width=1em]
\setupitemgroup[itemize][2][a,repeat][width=2em]
\setupitemgroup[itemize][3][n]       [width=3em]

\defineseparatorset[none][][]

\setupcounter[itemgroup:itemize][numberseparatorset=none]
\startitemize
    \item ...          % 1
    \startitemize
        \item ...      % 1a
        \startitemize
            \item ...  % 1a1
        \stopitemize
    \stopitemize
\stopitemize

Vertical spacing

This is the way how you can set spacing before and after itemize when working with

\setupwhitespace[big]

An option nowhite comes in handy:

paragraph before

\startitemize[joinedup,nowhite,after]
\item first
\item second
\stopitemize

paragraph after

These are all the four possible combinations of whitespace settings that you might want to use:



It is also (at least in mkiv) possible to do

Text before
\startitemize[before={\blank[small]},after={\blank[small]},inbetween={\blank[medium]}]
\item test
\item test
\stopitemize
Text after

to control the vertical space.


To prevent an unwanted pagebreak before the list, there is an intro parameter :

The following list is on the same page as this paragraph :
\startitemize[intro]
  \startitem foo \stopitem
  \startitem bar \stopitem
\stopitemize

Horizontal spacing

To control the space between the item symbol (bullet) and the item text

you can use eather the broad option

\startitemize[n*broad] %replace n with a number (e.g "3").
	\item Test
\stopitemize

or you can use absolute values (for fine tuning):

\startitemize[width=1em,distance=0pt]
	\item Test
\stopitemize

Multicolumn

Hans posted a solution to the list for a multicolumn enumeration that counts across then down, instead of down then across. When he posted it (Dec 21, 2005), he said the joinedup option does not work, but he would fix that. This is a version without the tufte and zapf text

\starttext

Some previous sentence before the list

\startitemize[columns,n,joinedup]
\item one
\item two
\stopitemize
\startitemize[continue,columns,joinedup]
\item one
\item two
\stopitemize
\startitemize[continue,columns,joinedup]
\item one
\item two
\stopitemize

And the text continues after the list

\stoptext

From a discussion on the mailing list, the following was suggested (note that you have to enclose your items in \startitem and \stopitem, using \item only does not work):

\starttext

Some previous sentence before the list

\startitemize[a,horizontal,three]
\startitem first \stopitem
\startitem second \stopitem
\startitem third \stopitem
\startitem fourth \stopitem
\startitem fifth \stopitem
\startitem sixth \stopitem
\stopitemize

And the text continues after the list

\stoptext

Other considerations

Randomizing items

It is possible to make ConTeXt randomize the items in enumerations; this can come handy when, e.g., typesetting tests. You have to add a random option to \startitemize. There is a caveat:

  1. You have to say \startitem ... \stopitem instead of \item ... .

Example:

\startitemize[random]
\startitem A \stopitem
\startitem B \stopitem
\startitem C \stopitem
%\startitem F \stopitem
\stopitemize

Referring to items

You can also use a reference to an item, just like a chapter or section. See also References.

\starttext
\startitemize[n]
\item A
\item[foo] B
\item C
\stopitemize
\dots
As seen in \in{item}[foo] on page \at{page}[foo], B is teh shizzle.
\stoptext

Associative lists

Wolfgang suggested [3] a clever use of alignment options using which one can create associative lists (for example, to pose associative questions):

\bTABLE
[frame=off,
 width=.4\textwidth,
 columndistance=.2\textwidth,
 align={normal,lohi}]
\bTR
\bTD
\startitemize[8,random][align=righttoleft]
\startitem {\lefttoright One} \stopitem
\startitem {\lefttoright Two} \stopitem
\startitem {\lefttoright Three} \stopitem
\stopitemize
\eTD
\bTD
\startitemize[8,random]
\startitem First \stopitem
\startitem Second \stopitem
\startitem Third \stopitem
\startitem Foruth \stopitem
\stopitemize
\eTD
\eTR
\eTABLE

Further Reading