0% found this document useful (0 votes)
123 views10 pages

Ordered Lists in Latex

1. The document discusses modifying the numbering styles of ordered lists in LaTeX using the enumerate environment. 2. By default, enumerate uses arabic numbers for the first level, lowercase letters for the second level, lowercase Roman numerals for the third level, and uppercase letters for the fourth level. These styles can be modified using commands like \renewcommand. 3. An example modifies the first level to use uppercase Roman numerals instead of arabic numbers, showing how the \labelenum and \theenum variables are updated but cross-referencing is not affected.

Uploaded by

Nabil Kchiri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views10 pages

Ordered Lists in Latex

1. The document discusses modifying the numbering styles of ordered lists in LaTeX using the enumerate environment. 2. By default, enumerate uses arabic numbers for the first level, lowercase letters for the second level, lowercase Roman numerals for the third level, and uppercase letters for the fourth level. These styles can be modified using commands like \renewcommand. 3. An example modifies the first level to use uppercase Roman numerals instead of arabic numbers, showing how the \labelenum and \theenum variables are updated but cross-referencing is not affected.

Uploaded by

Nabil Kchiri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Ordered lists in LTEX using the enumerate environment

Jorge A. R. Duran Samuel G. R. Duran

[email protected] [email protected]

May 15, 2020

Contents
1 Ordered Lists using the enumerate environment 1

2 Modifying the numbering styles 3

3 Placing some xed test in a nested list 8

4 Including section number in list number 9

References 9

1 Ordered Lists using the enumerate environment


Under the \enumerate environment, ordered lists are generated using the control sequence
\item in each entry. Each enumerated item can be labeled and referred through the
\label{ } and \ref{ } commands, respectively. The default numbering styles in the
nested four listings under the enumerate environment are:

ˆ 1, 2, . . . 4 for the rst level (arabic numbers)

ˆ (a), (b) . . . (d) for the second level (lowercase letters)

ˆ i, ii, . . . iv for the third level (lowercase Roman numerals)

ˆ A, B . . . C for the fourth level (uppercase letters)

while their referring styles are:

ˆ 1, 2, . . . 4 for the rst level

1
ˆ 1(a), 1 (b) . . . 1(d) for the second level

ˆ 1(a)i, 1(a)ii, . . . 1(a)iv for the third level

ˆ 1(a)iA, 1(a)iB . . . 1(a)iC for the fourth level

We will use as an example of nested list up to the fourth depth level, a list consisting
of countries, states, regions and cities from our continent. The LATEX code and its output
are shown side by side with the help of package fancyvrb-ex [2]. This will be done with
all the examples in this article.

1 \begin{enumerate}
2 \item Brazil \label{it:br}

3 \begin{enumerate}
1. Brazil 4 \item Rio de Janeiro \label{it:rj}
5 \item Sao Paulo \label{it:sp}
(a) Rio de Janeiro
6 \item Parana \label{it:pr}
(b) Sao Paulo 7 \begin{enumerate}
(c) Parana 8 \item Oeste Par. \label{it:oest_par}
i. Oeste Par. 9 \item Centro-Sul Par. \label{it:met_cur}
10 \begin{enumerate}
ii. Centro-Sul Par.
11 \item Curitiba \label{it:cur}
A. Curitiba
12 \item S. J. dos Pinhais \label{it:sjp}
B. S. J. dos Pinhais
13 \end{enumerate}
iii. Centro-Sul Par. 14 \item Centro-Sul Par. \label{it:csp}
iv. Sudoeste Par. 15 \item Sudoeste Par.
(d) Bahia 16 \end{enumerate}
(e) Mato Grosso do Sul 17 \item Bahia
18 \item Mato Grosso do Sul
2. Cuba 19 \end{enumerate}
20 \item Cuba \label{it:cub}
(a) Villa Clara
21 \begin{enumerate}
(b) Havana 22 \item Villa Clara
3. Argentina 23 \item Havana
24 \end{enumerate}
25 \item Argentina

26 \end{enumerate}

If at any part of the current document we need to refer to the item S. J. dos Pinhais,
for example, which is at the deepest level of our list (the fourth), we can invoke the \ref{}
command using the corresponding label we associated to this item in LATEX code, in this

2
case {it:sjp}, as the command's argument. The same logical is applied to indicate the
region, state and country where S. J. dos Pinhais is located as shown below:

1 The city \ref{it:sjp} is located


The city 1(c)iiB is located at the region
2 at the region of \ref{it:met_cur}
of 1(c)ii in the state 1c that belong to the
3 in the state \ref{it:pr} that belong
country 1.
4 to the country \ref{it:br}.

2 Modifying the numbering styles


In LATEX lists each level has an associated \labelenumXX and \theenumXX variables, where
XX = i . . . iv point for the level. The enumXX is the counter that increase its value at each
call to the \item inside of the enumerate environment. Let's check the current values of
these variables at level one:

1 \begin{itemize}
ˆ \theenumi = 3 2 \item \verb!\theenumi! = \theenumi
3 \item \verb!\labelenumi! =
ˆ \labelenumi = 3. 4 \labelenumi
5 \end{itemize}

Since the default numbering styles for the rst level are arabic numbers, the rst time
that LATEX code found an \item inside the enumerate environment the counter enumi is
set to the value 1. But this happens three times at the rst level in our example list (it
has three countries) so a call to the value stored in the counter, which is made through
\theenumi returns a value of 3. The \labelenumi just adds a lower point to \theenumi.
The same logical applies to the second level, as shown below:

1 \begin{itemize}
ˆ \theenumii = b 2 \item \verb!\theenumii! = \theenumii
3 \item \verb!\labelenumii! =
ˆ \labelenumii = (b) 4 \labelenumii
5 \end{itemize}

The enumii has counted only from a . . . b since in the example list only two countries
(Brazil and Cuba) have some of their states listed. The numbering styles for each depth

3
can be modify by the user through the \renewcommand{label}{style} command, where
label is the list depth being modied and style is how you want that number to be
shown. We can styled both, the \labelenumXX and the \theenumXX variables using the
following macros:

ˆ \alph{number} : lowercase letters

ˆ \Alph{number} : uppercase letters

ˆ \arabic{number} : numbers

ˆ \roman{number} : lowercase roman numerals

ˆ \Roman{number} : uppercase roman numerals

For example, let's change the number style to uppercase roman numerals at the rst
depth of our example list. This can be accomplished through the command

\renewcommand{\labelenumi}{\Roman{enumi}:}

If we invoke the new values for the controlling variables, this is the result:

1 \begin{itemize}
ˆ \theenumi = 3 2 \item \verb!\theenumi! = \theenumi
3 \item \verb!\labelenumi! =
ˆ \labelenumi = III: 4 \labelenumi
5 \end{itemize}

We have styled only the \labelenumi variable but the \theenumi remains counting
using the default arabic numbers. The result of invoking a cross reference to Cuba e.g.
which has the \label{it:cub} is the following:

1 \begin{itemize}
2 \item[] \verb!\ref{it:cub}! =
\ref{it:cub} = 2
3 \ref{it:cub}
4 \end{itemize}

In spite of the fact that Cuba is now identied by a II: in the example list, as can be
easily veried reprinting the original code:

4
1 \begin{enumerate}
2 \item Brazil \label{it:br}

3 \begin{enumerate}
I: Brazil 4 \item Rio de Janeiro \label{it:rj}
5 \item Sao Paulo \label{it:sp}
(a) Rio de Janeiro
6 \item Parana \label{it:pr}
(b) Sao Paulo 7 \begin{enumerate}
(c) Parana 8 \item Oeste Par. \label{it:oest_par}
i. Oeste Par. 9 \item Centro-Sul Par. \label{it:met_cur}
10 \begin{enumerate}
ii. Centro-Sul Par.
11 \item Curitiba \label{it:cur}
A. Curitiba
12 \item S. J. dos Pinhais \label{it:sjp}
B. S. J. dos Pinhais
13 \end{enumerate}
iii. Centro-Sul Par. 14 \item Centro-Sul Par. \label{it:csp}
iv. Sudoeste Par. 15 \item Sudoeste Par.
(d) Bahia 16 \end{enumerate}
(e) Mato Grosso do Sul 17 \item Bahia
18 \item Mato Grosso do Sul
II: Cuba 19 \end{enumerate}
20 \item Cuba \label{it:cub}
(a) Villa Clara
21 \begin{enumerate}
(b) Havana 22 \item Villa Clara
III: Argentina 23 \item Havana
24 \end{enumerate}
25 \item Argentina

26 \end{enumerate}

In order to maintaining the equivalence between the true label of the entry in the
list and its cross reference we should also styled \theenumi variable using this command
(without the colon):

\renewcommand{\theenumi}{\Roman{enumi}}

Invoking again the position of Cuba in the list we have:

1 \begin{itemize}
2 \item[] \verb!\ref{it:cub}! =
\ref{it:cub} = 2
3 \ref{it:cub}
4 \end{itemize}

5
Clearly the cross reference remains incorrect. Remember that the variable \theenumi
is updated at each call to the command \item and this only can be done if we run again
the code for our example list. But we will not do that because it will destroy all our
previous demonstrations, unless we change the \label of each item. Indeed, the style of
any cross reference to our example list will change to uppercase roman numerals in the
whole document as it should, since that means that the \ref{} command always nd at
the whole document for the most recent value of the associate identier.
Any of the forms we have seen in this section for modifying the numbering styles
in nested lists should be valid unless any other instruction, placed right before of the
\begin{enumerate} modify its eects. For example, consider the following list:

1 \begin{enumerate}
2 \item Local approaches. \label{it:la}
I: Local approaches. 3 \begin{enumerate}
4 \item The NSIF Concept.
(a) The NSIF Concept.
5 \item The SED Concept.
(b) The SED Concept. 6 \end{enumerate}
7 \item Global approaches. \label{it:ga}
II: Global approaches.
8 \begin{enumerate}
(a) The NS Concept. 9 \item The NS Concept.
(b) The SS Concept. 10 \item The SS Concept.
11 \end{enumerate}
12 \end{enumerate}

As expected, the labels at the rst level depth remains using uppercase roman numer-
als. We can return to the default conguration placing the following command at at the
beginning of the environment, as follows:

\renewcommand{\labelenumi}{\arabic{enumi}}

6
1 \renewcommand{\labelenumi}{\arabic{enumi}}
2 \begin{enumerate}

3 \item Local approaches. \label{it:la}


1 Local approaches.
4 \begin{enumerate}
(a) The NSIF Concept. 5 \item The NSIF Concept.
(b) The SED Concept. 6 \item The SED Concept.
7 \end{enumerate}
2 Global approaches. 8 \item Global approaches. \label{it:ga}
9 \begin{enumerate}
(a) The NSC Concept.
10 \item The NSC Concept.
(b) The SS Concept. 11 \item The SS Concept.
12 \end{enumerate}
13 \end{enumerate}

7
3 Placing some xed test in a nested list
Quite often it is necessary to put some xed text in each entry of a numbered list. More
common examples include words as Example, Question, etc. This can be done by reden-
ing the \labelenumXX commands. The following example consist of a hypothetical test
with two questions, two items each. We will use only the rst letter of the word Question.
The \renewcommand is necessary only due to the introduction of the letter Q plus a call to
the counter at the rst level depth. Except for this letter, the rest of the code would be
unnecessary because \theenumi is the default value for the \labelenumi in the enumerate
environment.

\renewcommand{\labelenumi}{Q - \theenumi}

1 \renewcommand{\labelenumi}{Q - \theenumi}
2 \begin{enumerate}

Q - 1 Discourse on these local approaches: 3 \item Discourse on these local approaches:


4 \begin{enumerate}
(a) The NSIF
5 \item The NSIF \label{it:nsif}
(b) The SED 6 \item The SED \label{it:sed}
\end{enumerate}
Q - 2 Discourse on these global ap- 7
8 \item Discourse on these global approaches:
proaches:
9 \begin{enumerate}
(a) The NSC 10 \item The NSC \label{it:nsc}
(b) The SSC 11 \item The SSC \label{it:ssc}
12 \end{enumerate}
13 \end{enumerate}

If the label for the second item of the rst question is \label{it:sed} we realize that
the cross reference to this line does not include the letter Q:

1 \begin{itemize}
\ref{it:sed} = 1b 2 \item [] \verb!\ref{it:sed}! = \ref{it:sed}
3 \end{itemize}

This is not a main drawback since the only thing that we do for xing is to insert
the letter Q or even the entire word Question before calling the \ref command. There
are other alternatives using, for example the enumerate or enumitem packages. Note that
the names for the package and environment are the same (enumerate) but this is just a

8
coincidence.

4 Including section number in list number


We arrive to \thesection = 4, which obviously tell us that is the LATEX macro we
should use in order to incorporate the section number to the labels and counters in
the enumerate environment. Once again, the \renewcommand will be used to accomplish
this task:

1 \renewcommand{\theenumi}{\thesection.\arabic{enumi}}
2 \begin{enumerate}

Q - 4.1 Discourse on these local approaches: 3 \item Discourse on these local approaches:
4 \begin{enumerate}
(a) The NSIF
5 \item The NSIF \label{it:nsif1}
(b) The SED 6 \item The SED \label{it:sed1}
\end{enumerate}
Q - 4.2 Discourse on these global ap- 7
8 \item Discourse on these global approaches:
proaches:
9 \begin{enumerate}
(a) The NSC 10 \item The NSC \label{it:nsc1}
(b) The SSC 11 \item The SSC \label{it:ssc1}
12 \end{enumerate}
13 \end{enumerate}

Since section 3 we add the letter Q to the \labelenumi of any enumerate environment
and we know from the section 2 that this setup will be valid if no other modication is
found before the \begin{enumerate}. For this reason the letter is preserved in the above
list. Also note that we changed the \label of the entries at the second level. Can you
guest the reason of that? If you answered not to modify this cross reference, you are right.
Let's make a cross reference to the topic SED which stands for Strain Energy Density
in the last version of our test example:

1 \begin{itemize}
2 \item [] \verb!\ref{it:sed}! =
\ref{it:sed} = 4.1b
3 \ref{it:sed1}
4 \end{itemize}

As expected, the cross reference now includes the section number.

9
References
[1] D. Datta. LATEX in 24 Hours: A practical Guide for Scientic Writing. Springer
International Publishing, Gewerbestrasse 11, 6330 Cham, Switzerland, 2017. ISBN
978-3-319-47830-2.

[2] T. V. Zand. The fancyvrb package: Fancy Verbatims in LATEX. Technical report,
Princeton University, Princeton, USA, 2020. URL https://ctan.org/pkg/fancyvrb.

10

You might also like