Jump to content

LaTeX/List Structures

From Wikibooks, open books for an open world

LaTeX

Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics
  5. How to get help

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Customizing Page Headers and Footers‎
  14. Importing Graphics
  15. Floats, Figures and Captions
  16. Footnotes and Margin Notes
  17. Hyperlinks
  18. Labels and Cross-referencing
  19. Initials

Mechanics

  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Text

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Scientific Reports (Bachelor Report, Master Thesis, Dissertation)
  2. Letters
  3. Presentations
  4. Teacher's Corner
  5. Curriculum Vitae
  6. Academic Journals (MLA, APA, etc.)

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics

Programming

  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Creating Package Documentation
  5. Themes

Miscellaneous

  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks

Appendices

  1. Authors
  2. Links
  3. Package Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this boxedit the TOC


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

[edit | edit source]

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 types:

  • itemize for a bullet list
  • enumerate for an enumerated list and
  • description for a descriptive list.

All lists follow the basic format:

\begin{list_type}
   \item {The first item}
   \item The second item 
   \item The third etc \ldots
\end{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. Item content could be in the curly brackets for reading convenience of long items.


Try out the examples below, to see what the lists look like in a real document.

\documentclass{article}
\usepackage{blindtext}
\begin{document}

\begin{itemize}
  \item \blindtext
  \item \blindtext
\end{itemize}

\begin{enumerate}
  \item \blindtext
  \item \blindtext
\end{enumerate}

\begin{description}
  \item [Ant] \blindtext
  \item [Elephant] \blindtext
\end{description}

\end{document}
Sample output of lists in LaTeX. Itemize, enumerate, and description.


LaTeX will happily allow you to insert a list environment into an existing one (up to a depth of four, more levels are available using packages). 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}
\item The first item
\begin{enumerate}
\item Nested item 1
\item Nested item 2
\end{enumerate}
\item The second item
\item The third etc \ldots
\end{enumerate}

Some special lists

[edit | edit source]

Sometimes you feel the need to better align the different list items. If you are using a KOMA-script class (or package scrextend), the labeling environment is handy. It takes a mandatory argument that contains the longest of your labels.

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\usepackage{scrextend}
\addtokomafont{labelinglabel}{\sffamily}
\begin{document}
\blindtext
\begin{labeling}{alligator}
  \item [ant] really busy all the time
  \item [chimp] likes bananas
  \item [alligator] very dangerous animal, sharp teeth, long
muscular tail and a bit of text that is longer than one
line and shows the alignment of text quite nicely
\end{labeling}
\end{document}


If you are on tight space limitations and only have short item descriptions, you may want to have the list inline. Please note that the example also shows how to change the font.

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\usepackage[inline]{enumitem}
\usepackage{xcolor}
\begin{document}
\blindtext Coco likes fruit. Her favorites are:
\begin{enumerate*}[label={\alph*)},font={\color{red!50!black}\bfseries}]
\item bananas
\item apples
\item oranges and
\item lemons.
\end{enumerate*}
\blindtext
\end{document}



If you want a horizontal list, package tasks can be handy. In combination with a package like exsheets, you can prepare exam papers for students.

\documentclass[12pt]{article}
\usepackage{tasks}
\usepackage{exsheets}
\SetupExSheets[question]{type=exam}
\begin{document}
\begin{question}
	Which one of the entries does not fit with the others?
	\begin{tasks}(4)
		\task mercury
		\task iron
		\task lead
		\task zinc
	\end{tasks}
\end{question}
\settasks{
	label=(\roman*),
	label-width=4ex
}
\begin{question}
	What is a funkyton?
	\begin{tasks}(2)
		\task A dancing electron
		\task A dancing proton
		\task A dancing neutron
		\task A Dixie Dancing Duck
	\end{tasks}
\end{question}
\end{document}

Customizing lists

[edit | edit source]

When dealing with lists containing just a few words per item, the standard lists often take up too much space. Package enumitem provides you a simple interface to customize the appearance of lists.

You can change the appearance of lists globally in the preamble, or just for single lists using the optional argument of the environment. Have a look at the following example where the list on the right is more compact using noitemsep.

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\usepackage{enumitem}
\begin{document}
\blindtext
\begin{itemize}
  \item more work
  \item more responsibility
  \item more satisfaction
\end{itemize}
\blindtext
\newpage
\blindtext
\begin{itemize}[noitemsep]
  \item more work
  \item more responsibility
  \item more satisfaction
\end{itemize}
\blindtext
\end{document}

An example for alignment and the width of the label.

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\usepackage{enumitem}
\begin{document}
\blindtext Coco likes fruit. Her favourites are:
\begin{description}[align=left]
  \item [Kate] some detail
  \item [Christina]some detail
  \item [Laura]some detail
\end{description}

\begin{description}[align=right]
  \item [Kate] some detail
  \item [Christina]some detail
  \item [Laura]some detail
\end{description}

\begin{description}[align=right,labelwidth=3cm]
  \item [Kate] some detail
  \item [Christina]some detail
  \item [Laura]some detail
\end{description}

\blindtext
\end{document}

The documentation of package enumitem goes into more detail with respect to what can be changed and how. You can even define your own lists. Environments like labeling and tasks can be changed differently, details can be found in the package documentation respectively.

Easylist package

[edit | edit source]

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}
& Main item~:
&& Sub item.
&& Another sub item.
\end{easylist}

It features predefined styles which you can set as optional argument.

\begin{easylist}[itemize]
% ...
\end{easylist}

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 style 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 Hide = n 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]
\ListProperties(Style2*=,Numbers=a,Numbers1=R,FinalMark={)})
& Main item~:
&& Sub item.
&& Another sub item.
\end{easylist}

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}
\ListProperties(Hide=100, Hang=true, Progressive=3ex, Style*=-- ,
Style2*=$\bullet$ ,Style3*=$\circ$ ,Style4*=\tiny$\blacksquare$ )
% ...

\begin{easylist}
& Blah
& Blah
&& Blah
&&& Blah
&&&& Blah
&&&&& Blah
\end{easylist}

– Blah
  Blah
   Blah
    Blah
     – 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$ )}
\newcommand\myenumerate{\ListProperties(Space=2\baselineskip)}

% ...
\begin{easylist} \myitemize
& Blah
\end{easylist}

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
\begin{easylist}
& ...
\end{easylist}
\Deactivate

Besides using easylist along with figures may cause some trouble to the layout and the indentation. LaTeX lists do not have this problem.

To use easylist with Beamer, each frame that uses easylist must be marked as fragile:

\begin{frame}[fragile]
...
\begin{easylist}[itemize]
...
\end{easylist}
...
\end{frame}



Previous: Fonts Index Next: Special Characters