LaTeX/List Structures
| Getting Started
Common Elements
Mechanics Technical Texts
Special Pages Special Documents Creating Graphics Programming Miscellaneous Help and Recommendations Appendices |
Convenient and predictable list formatting is one of the many advantages of using LaTeX. Users of WYSIWYG word processors can sometimes be frustrated by the software's attempts to determine when they intend lists to begin and end. As a mark-up language, LaTeX gives more control over the structure and content of lists.
List Structures
Lists often appear in documents, especially academic, as their purpose is often to present information in a clear and concise fashion. List structures in LaTeX are simply environments which essentially come in three flavors: itemize, enumerate and description.
All lists follow the basic format:
|
\begin{list_type} |
All three of these types of lists can have multiple paragraphs per item: just type the additional paragraphs in the normal way, with a blank line between each. So long as they are still contained within the enclosing environment, they will automatically be indented to follow underneath their item.
Itemize
This environment is for your standard bulleted list of items.
|
\begin{itemize} |
Enumerate
The enumerate environment is for ordered lists, where by default, each item is numbered sequentially.
|
\begin{enumerate} |
Description
The description environment is slightly different. You can specify the item label by passing it as an optional argument (although optional, it would look odd if you didn't include it!). Ideal for a series of definitions, such as a glossary.
|
\begin{description} |
Sometimes you want a description where the text begins on a new line. This cannot easily be done with \\. The trick is to use \hfill.
|
\begin{description} |
Nested lists
LaTeX will happily allow you to insert a list environment into an existing one (up to a depth of four -- if you need more than four, use the easylist package). Simply begin the appropriate environment at the desired point within the current list. Latex will sort out the layout and any numbering for you.
|
\begin{enumerate} |
Customizing lists
Customizing LaTeX is outside the beginners' domain. While not necessarily difficult in itself, because beginners are already overwhelmed with the array of commands and environments, moving on to more advanced topics runs the risk of confusion.
However, since the tutorial aims at being complete, we shall still include a brief guide on customizing lists. Feel free to skip!
Note that in the following when \renewcommand is used it must appear after the \begin{document} instruction so the changes made are taken into account. This is needed for both enumerated and itemized lists.
Also beware of the spaces in the label definitions. It is a common error!
Line spacing
As you may have noticed, in standard LaTeX document classes, the vertical spacing between items, and above and below the lists as a whole, is more than between paragraphs: it may look odd if the descriptions are too short.
Using packages
If you want tightly-packed lists, use the mdwlist package (included in the mdwtools bundle), which provides compact, "starred" versions of the previous environments, i.e. itemize*, enumerate* and description*. They work exactly in the same way, but the output is more compact. Other packages providing compacted lists are paralist and enumitem.
Alternatively, use the memoir class and with \tightlists.
Customizing manually
Inside lists you can redefine some length/dimension variables of LaTeX, for example using:
|
\begin{itemize} \itemsep1pt \parskip0pt \parsep0pt |
Alternatively, to create a unified look in your document you can define your own enumerate environment:
|
\newenvironment{my_enumerate}{ |
Another approach is to redefine the \item command globally.
|
\newlength{\wideitemsep} |
Customizing enumerated lists
Using packages
The thing people want to change most often with Enumerated lists are the counters. A quick solution to this problem is provided by the enumerate package of David Carlisle[1], or the more sophisticated package enumitem by Javier Bezos[2]. When using enumerate, it is possible to specify the style of the numbering: \begin{enumerate}[style].
The options A, a, I, i and 1 define the style and are self-explanatory, anything else is treated as text. To use any of the style tokens as text they can be enclosed in braces, e.g. {A} will give a literal A. [3]
Manually
To go any further and do it yourself instead, a brief introduction to LaTeX counters is required. You should check the dedicated chapter as we will not delve into the details for now.
There are four individual counters that are associated with itemized lists, each one represents the four possible levels of nesting, which are called:
|
enumi |
The counter is incremented by \item before it is printed. For example to reset enumi use:
|
\begin{enumerate} |
5. fifth element |
The command responsible for formatting the various levels of nesting are
|
\labelenumi |
Example:
|
\renewcommand{\labelenumi}{(\Roman{enumi})} |
This simply redefines the appearance of the label, which is fine, providing that you do not intend to cross-reference to a specific item within the list, in which case the reference will be printed in the original format. This issue does not arise if you redefine the counter printer:
|
\renewcommand{\theenumi}{\Roman{enumi}} |
Customizing itemised lists
Itemized lists are not as complex as they do not need to count. Therefore, to customize, you simply change the labels. It can be done manually for each entry with \item[new symbol], eg \item[$\star$].
The itemize labels are accessed via \labelitemi, \labelitemii, \labelitemiii, \labelitemiv, for the four respective levels.
|
\renewcommand{\labelitemi}{\textgreater} |
The above example would set the labels for the first level to a greater than (>) symbol. Of course, the text symbols available in Latex are not very exciting. Why not use one of the ZapfDingbat symbols, as described in the Symbols section. Or use a mathematical symbol:
|
\renewcommand{\labelitemi}{$\star$} |
Itemized list with tightly set items, that is with no vertical space between two consecutive items, can be created as follows.
|
\begin{itemize} |
Inline lists
Inline lists are a special case as they require the use of the paralist package which provides the inparaenum environment (with an optional formatting specification in square brackets):
|
\usepackage{paralist} |
To change the styles of the counter, tokens A, a, I, i, and 1 can be used in the optional argument to produce the counter with one of the styles \Alph, \alph, \Roman, \roman and \arabic. For example: \begin{inparaenum}[(i)] produces the labels (i), (ii), (iii) ...
Other packages providing inline lists are shortlst and enumitem.
Easylist package
The easylist package allows you to create list using a more convenient syntax and with infinite nested levels. It is also very customizable.
Load the package with the control character as optional argument:
|
\usepackage[ampersand]{easylist} |
The easylist environment will default to enumerations.
|
\begin{easylist} |
It features predefined styles which you can set as optional argument.
|
\begin{easylist}[itemize] |
Available styles:
- tractatus
- checklist - All items have empty check boxes next to them
- booktoc - Approximately the format used by the table of contents of the book class
- articletoc - Approximately the format used by the table of contents of the article class
- enumerate - The default
- itemize
You can customize lists with the \ListProperties(...) command and revert back the customization with \newlist{}. Yes, that's parentheses for \ListProperties parameters.
The Style parameter sets the style of counters and text, the Style* parameter sets the sytle of counters, and the Style** parameter sets the style of text. The parameter Numbers determines the way that the numbers are displayed and the possible values are r or R (for lower and upper case Roman numerals), l or L (for lower and upper case letters), a (for Arabic numbers, the default), and z (for Zapf's Dingbats).
The FinalMark parameter sets the punctuation of the final counter (Ex: FinalMark3={)}) while FinalSpace sets the amount of space between the item and the item's text. The Margin parameter sets the distance from the left margin (Ex: FinalSpace2=1cm). The Progressive parameter sets the distance from the left margin of all items in proportion to their level.
The {{{1}}} parameter prevents the first n counters from appearing in all levels. If there is a number after a parameter (Ex: Style3*) then this numbers indicates the level that it will affect (Ex: Style3=\color{red}).
Example of custom enumerate:
|
\begin{easylist}[enumerate] |
Note that we put the FinalMark argument between {} to avoid LaTeX understanding it as the end of the properties list. Now we change the default properties to print a custom itemize:
|
\usepackage{amssymb} |
– Blah |
Spaces in Style parameters are important. The Style* parameter acts as a default value and easylist will use a medium dash for level 1, 5 and onward.
You can also define custom styles using LaTeX macros:
|
\newcommand\myitemize{\ListProperties(Hide=100, Hang=true, Progressive=3ex, Style*=$\star$ )} |
Important note: easylist has some drawbacks. First if you need to put an easylist inside an environment using the same control character as the one specified for easylist, you may get an error. To circumvent it, use the following commands provided by easylist:
|
\Activate |
Besides using easylist along with figures may cause some trouble to the layout and the indentation. LaTeX lists do not have this problem.
Currently easylist does not work with Beamer.
Blah
Blah
Blah