Difference between revisions of "Enumerations"

From Wiki
Jump to navigation Jump to search
m (conversion n and N are identical)
(added pretty printing and sample)
Line 1: Line 1:
 
The most basic form of using enumerations in ConTeXt is
 
The most basic form of using enumerations in ConTeXt is
  
 +
<texcode>
 
  \startitemize
 
  \startitemize
 
  \item here we list the points,
 
  \item here we list the points,
 
  \item one after the other.
 
  \item one after the other.
 
  \stopitemize
 
  \stopitemize
 +
</texcode>
  
The <tt>\startitemize</tt> command takes optional parameters (see the documentation of <tt>\startitemgroup</tt> for a complete list), for example a number conversion may be given, with the following predefined types:
+
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:
  
 
<table>
 
<table>
  <tr><td><tt>n or N</tt></td><td>Usually the default: a numbered list</td></tr>
+
  <tr><td><tt>n</tt> or <tt>N</tt></td><td>Usually the default: a numbered list</td></tr>
 
  <tr><td><tt>m</tt></td><td>A numbered list, with lowercase (&ldquo;medieval&rdquo;, aka &ldquo;oldstyle&rdquo;) numbers.</td></tr>
 
  <tr><td><tt>m</tt></td><td>A numbered list, with lowercase (&ldquo;medieval&rdquo;, aka &ldquo;oldstyle&rdquo;) numbers.</td></tr>
 
  <tr><td><tt>1</tt> &hellip; <tt>8</tt></td><td>Different kinds of bullets.  All items get the same symbol.</td></tr>
 
  <tr><td><tt>1</tt> &hellip; <tt>8</tt></td><td>Different kinds of bullets.  All items get the same symbol.</td></tr>
Line 20: Line 22:
 
</table>
 
</table>
  
Additional parameters include <tt>continue</tt> (start where the previous itemization  was finished, to allow text injections), <tt>packed</tt> (less vertical space between items), and <tt>inmargin</tt> (place enumeration symbols into the margin).
+
Additional parameters include
 +
* <tt>continue</tt> (start where the previous itemization  was finished, to allow text injections),
 +
* <tt>packed</tt> (less vertical space between items), and
 +
* <tt>inmargin</tt> (place enumeration symbols into the margin).
  
To change the general layout of enumerations, there is <tt>\setupitemize</tt>.  Itaccepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply.  There is an example below.
+
To change the general layout of enumerations, there is <cmd>setupitemize</cmd>.  Itaccepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply.  There is an example below.
  
 
For finer control, it is advisable to create new types of itemization, using the command <tt>\defineitemgroup</tt> (which unfortunately seems undocumented).  For example, something similar to the LaTeX <tt>itemize</tt> environment can be defined as follows:
 
For finer control, it is advisable to create new types of itemization, using the command <tt>\defineitemgroup</tt> (which unfortunately seems undocumented).  For example, something similar to the LaTeX <tt>itemize</tt> environment can be defined as follows:
  
 +
<texcode>
 
   \defineitemgroup[ltxitm][levels=5]
 
   \defineitemgroup[ltxitm][levels=5]
 
   %
 
   %
Line 54: Line 60:
 
   %
 
   %
 
   \stoptext
 
   \stoptext
 +
</texcode>
 +
 +
gives
 +
 +
<context>
 +
  \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
 +
</context>

Revision as of 15:03, 12 September 2004

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., …
AItems 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.

Additional parameters include

  • continue (start where the previous itemization was finished, to allow text injections),
  • packed (less vertical space between items), and
  • inmargin (place enumeration symbols into the margin).

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

For finer control, it is advisable to create new types of itemization, using the command \defineitemgroup (which unfortunately seems undocumented). For example, something similar to the LaTeX itemize environment can be defined as follows:

  \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

gives