Changes

Jump to navigation Jump to search
m
Reverted edit of !!!!!!!!!!!!TROLL!!!!!!!!!!!!!!!!!!!!!, changed back to last version by Taco
< [[Structurals]] | [[Enumerations]] >

Sometimes, you might want to enumerate things using a number conversion (that is, the letter or symbol or whatever that "numbers" the item) which isn't one existing ConTeXt enumerations. For example, [[User:Mojca Miklavec|Mojca Miklavec]] recently (2005/07/26) pointed out on the mailing list that, in Slovenian, it is traditional to letter things using the Slovenian alphabet, which doesn't quite match the English one. [[User:Hagen|Hans]] provided this example of how to create a new enumeration in ConTeXt, which defines a "Mojcanian" numbering system, and a conversion based on those numbers:

<texcode>
\def\mojcaniannumber#1%
{\ifcase#1 \or m\or o\or j\or c\or a\or
m\or i\or k\or l\or a\or v\or e\or c\else
\expandafter\mojcaniannumber\expandafter{\the\numexpr#1-13\relax}\fi}

\defineconversion[s][\mojcaniannumber]
</texcode>

(The last line of the definition is a cleverness to repeat the letters over and over as needed; more traditional orderings tend to replace that with a simple <tt>-</tt> to indicate an out-of-range letter.)

We can test this, using the following code:

<texcode>
\starttext
\startitemize[s,columns,five,packed,broad]
\dorecurse{50}{\item test\endgraf}
\stopitemize
\stoptext
</texcode>

<context>
\def\mojcaniannumber#1%
{\ifcase#1 \or m\or o\or j\or c\or a\or
m\or i\or k\or l\or a\or v\or e\or c\else
\expandafter\mojcaniannumber\expandafter{\the\numexpr#1-13\relax}\fi}

\defineconversion[s][\mojcaniannumber]

\starttext
\startitemize[s,columns,five,packed,broad]
\dorecurse{50}{\item test\endgraf}
\stopitemize
\stoptext
</context>

Conversions can also be language-specific. For instance, suppose that we want the default "character" conversion to be Mojcanian numbers when the language is Slovenian. This can be done with the following conversion defintion:

<texcode>
\defineconversion[sl][a][\mojcaniannumber]
</texcode>

We can test this one like so:

<texcode>
\starttext
English:
\startitemize[a,columns,five,packed,broad]
\dorecurse{15}{\item test\endgraf}
\stopitemize

Slovenian:
\language[sl]
\startitemize[a,columns,five,packed,broad]
\dorecurse{15}{\item test\endgraf}
\stopitemize

\stoptext
</texcode>

<context>
\def\mojcaniannumber#1%
{\ifcase#1 \or m\or o\or j\or c\or a\or
m\or i\or k\or l\or a\or v\or e\or c\else
\expandafter\mojcaniannumber\expandafter{\the\numexpr#1-13\relax}\fi}

\defineconversion[sl][a][\mojcaniannumber]

\starttext
English:
\startitemize[a,columns,five,packed,broad]
\dorecurse{15}{\item test\endgraf}
\stopitemize

Slovenian:
\language[sl]
\startitemize[a,columns,five,packed,broad]
\dorecurse{15}{\item test\endgraf}
\stopitemize

\stoptext
</context>

An alternate way of defining conversions is via a list. This has the advantage of being simpler and clearer to program, but the disadvantage that one can't include clever things like repeating the letters <i>ad infinitum</i>, or doubling them up ("..., x, y, z, aa, ab, ac, ...") as the default character enumerations do. For example:

<texcode>
\defineconversion[s][m, o, j, c, a, m, i, k, l, a, v, e, c]
</texcode>

This produces the following, using an <tt>itemize</tt> environment much like the previous examples. Notice how, once we run out of letters, the conversion simply produces empty labels.

<context>
\defineconversion[s][m, o, j, c, a, m, i, k, l, a, v, e, c]
\starttext
\startitemize[s,columns,five,packed,broad]
\dorecurse{20}{\item test\endgraf}
\stopitemize
\stoptext
</context>

There are a number of additional examples of conversion definitions in <tt>core-con.tex</tt>, which is where ConTeXt's default conversions are defined.

Navigation menu