# Tag Archives: itemize

## Inline lists in LaTeX using paralist

The paralist package implements the three standard lists: itemize, enumerate and description for usage within paragraphs. In other words, the package provides a way to create inline lists placed within normal text.

Besides the inline environments for the standard lists, the package also provides support to format the labels (bullets, numbering, etc.). However, for labeling and formatting of lists in general, I recommend the more powerful enumitem package. Please, see the paralist package documentation for more details on the functionality provided by the package.

The code for inline lists is straight forward and resamples the way standard lists are created. Therefore, I only posted one minimal working example for each environment below, without further explanations.

For more details on the standard list environments see this post and sample code here.

##### Inline enumerate (inparaenum)

\documentclass[11pt]{article}
\usepackage{paralist}
\begin{document}
This includes:
\begin{inparaenum}[1)]
\end{inparaenum}
to be completed by the end of the month.
\end{document}

Open code in writeLaTeX.

##### Inline itemize (inparaitem)

\documentclass[11pt]{article}
\usepackage{paralist}
\begin{document}
This includes:
\begin{inparaitem}
\end{inparaitem}
to be completed by the end of the month.
\end{document}

Open code in writeLaTeX.

\documentclass[11pt]{article}
\usepackage{paralist}
\begin{document}
This includes:
to be completed by the end of the month.
\end{document}

Open code in writeLaTeX.

According to the author, the last environment was added for completeness rather than usefulness.

If you do have any better idea than my brainless repetition of the same code, please let me know below!

You might have wondered about the link “Open code in writeLaTeX”. I am testing a collaboration with the folks over at writeLaTeX. The idea is to provide the possibility to open the code with one click in the browser, play with the examples and see the result right away. Let me know whether you find this useful!

## Side-by-side content in beamer presentations

There are two ways (and possibly more) to place content side-by-side in a beamer presentation, the columns and the minipage environments. The first is a beamer-specific environment and is therefore only available in a beamer presentation. Whereas the latter has other applications and is available in all document-classes.

##### General considerations

In any LaTeX document, there is a predefined width available for text, \textwidth. In order to place content side-by-side, this width has to be split in such a way that the total width of all elements does not exceed \textwidth. Otherwise, LaTeX will automatically break the line and place elements on top of each other, which is usually not desired. The value \textwidth can be used to define the width of a column or minipage. For example, 0.33\textwidth takes a third of width of a page available for content. LaTeX also adds a small horizontal space between elements. Therefore, in order to split a page into three equal parts, 0.3\textwidth might be a more reasonable number. If required, one can add more horizontal white-space between two elements using \quad or \qquad.

##### The columns environment

The columns environment is only available in the beamer document-class and might therefore be lesser known.

Basic command structure:

\begin{columns}
\begin{column}{0.48\textwidth}
%Content
\end{column}
\begin{column}{0.48\textwidth}
%Content
\end{column}
\end{columns}

And here is a complete minimal working example:

\documentclass{beamer}
\begin{document}
\begin{frame}{The columns environment}
\begin{columns}
\begin{column}{0.47\textwidth}
\begin{itemize}
\item First item
\item Second item
\item Third item
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\rule{\textwidth}{0.75\textwidth}
\end{column}
\end{columns}
\end{frame}
\end{document}

##### The minipage environment

I wrote an article on the minipage environment quite some time ago. In beamer, the usage is not different.

The command is used as follows:

\begin{minipage}{0.45\textwidth}
%Content
\end{minipage}

Below is a complete minimal working example:

\documentclass{beamer}
\begin{document}
\begin{frame}{The minipage environment}
\begin{minipage}{0.47\textwidth}
\begin{itemize}
\item First item
\item Second item
\item Third item
\end{itemize}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\rule{\textwidth}{0.75\textwidth}
\end{minipage}
\end{frame}
\end{document}

##### Final note

Even though there are differences, I don’t know of any advantage of one method over the other when placing content side-by-side. However, I suggest choosing one environment and sticking to it throughout a presentation.

## Cross-referencing list items

List items of numbered lists (enumerate) can be cross-referenced using the standard \label{} and \ref{} command pair. Cross-referencing description items is not supported by default, but can be done with a few additional lines of code in the preamble.

Enumerate
Ordered or numbered lists are cross-referenced with the label-ref command pair similar to figures, tables or chapters. The label can either be place right after \item or after the item’s text. The cross-reference \ref{} works within and outside the list as shown in the example below.

\documentclass[11pt]{article}
\usepackage{hyperref}
\begin{document}
\begin{enumerate}
\item \label{itm:first} This is a numbered item
\item Another numbered item \label{itm:second}
\item \label{itm:third} Same as \ref{itm:first}
\end{enumerate}
Cross-referencing items \ref{itm:second} and \ref{itm:third}.
\end{document}

Cross-referencing numbered items in lists (enumerate).

Loading the hyperref package, automatically adds links to cross-references and allows navigation to list items by clicking the reference.

Description
By default, items in a description can’t be cross-referenced. LaTeX would just use the number of the section/chapter. SX has a solution with a few lines of additional code in the preamble.

\documentclass[11pt]{article}
\usepackage{enumitem, hyperref}
\makeatletter
\def\namedlabel#1#2{\begingroup
#2%
\def\@currentlabel{#2}%
\phantomsection\label{#1}\endgroup
}
\makeatother
\begin{document}
\begin{description}[style=multiline, labelwidth=1.5cm]
\item[\namedlabel{itm:rule1}{Rule 1}] Everything is easy with \LaTeX
\item[\namedlabel{itm:rule2}{Rule 2}] Sometimes it is not that easy\\
$\to$ \ref{itm:rule1} applies
\end{description}
\end{document}

Cross-referencing description items

The code in the preamble defines a new command namedlabel which produces the name when cross-referencing the item. In the example, the enumitem package is loaded for a correct alignment of multiline items (see documentation for details)

Itemize
Cross-referencing items in unordered lists (bullet items) is not supported and wouldn’t make sense anyway, since individual items don’t have an unique identifier.

## Increase enumerate & itemize depth with enumitem

The default maximum depth for the list environments enumerate and itemize is four. Using more than four nested levels will lead to the error: “Too deeply nested”.

One way to increase the depth of a list is using a mix of enumerate and itemize. However, obviously, some levels will be a bulleted rather than enumerated.

The enumitem package allows you to define new lists with an arbitrary number of levels. For example, let’s create nested lists with up to five levels.
Define a new list longenum of type enumerate which has 5 levels. Set the label style for each level they way you like. I used roman, alph and arabic.

\usepackage{enumitem}
\newlist{longenum}{enumerate}{5}
\setlist[longenum,1]{label=\roman*)}
\setlist[longenum,2]{label=\alph*)}
\setlist[longenum,3]{label=\arabic*)}
\setlist[longenum,4]{label=(\roman*)}
\setlist[longenum,5]{label=(\alph*)}

That’s all you need to know. The rest is straight forward, just use longenum instead of enumerate for each level and create a nested lists with up to 5 levels.

Here is the complete sample code with the output below:

\documentclass[11pt]{article}
\usepackage{enumitem}
\newlist{longenum}{enumerate}{5}
\setlist[longenum,1]{label=\roman*)}
\setlist[longenum,2]{label=\alph*)}
\setlist[longenum,3]{label=\arabic*)}
\setlist[longenum,4]{label=(\roman*)}
\setlist[longenum,5]{label=(\alph*)}
\begin{document}
\section*{Enumerated list with 5 levels}
\begin{longenum}
\item Level 1 first
\item Level 1 second
\begin{longenum}
\item Level 2 first
\item Level 2 second
\begin{longenum}
\item Level 3 first
\item Level 3 second
\begin{longenum}
\item Level 4 first
\item Level 4 second
\begin{longenum}
\item Level 5 first
\item Level 5 second
\end{longenum}
\end{longenum}
\end{longenum}
\end{longenum}
\end{longenum}
\end{document}

Enumitem package documentation.

## Beamer: An introduction to LaTeX presentations

Beamer is a LaTeX document class that provides extensive functionality to create presentations. Here, I will only show the basics and after reading this guide you will be able to create a simple presentation in LaTeX. I am aware there are a lot of tutorials available out there and this is not different from any other tutorial. I hope however, I can encourage some of you who have hesitated so far, for whatever reason, to create your next presentation with LaTeX. And I’m sure it will be a lot of fun, with similar effort. I should add that the output will obviously be a PDF file (with all its advantages!). Luckily, PDF-viewers (including Adobe Acrobat) provide a fullscreen-mode for presentation purposes.

So lets get started!

\documentclass{beamer}

Now that line is straight forward, not much to say about it. Once that’s done, we have to choose a theme. This website gives a visual overview of the most common themes. I like Singapore:

\usetheme{Singapore}

Next, still in the preamble, we prepare the title page, using a similar set of commands as for other document-classes:

\title{Your Presentation Title} \author{The author} \date{February 4, 2011}

A frame may have one or several slides. Since PDFs are static, dynamic “effects” such as adding more content to a frame are achieved by two consecutive slides in the output file.

We use the previously defined title page to create our first (single-slided) frame:

\begin{frame} \titlepage \end{frame}

Similar to articles, sections, subsections, etc. are available and can be used to define an outline, printed with \tableofcontents. For many themes, the outline will be displayed in the header/footer and provides direct access to a certain section of the presentation. Frame-titles are created using \frametitle{Title}.

Most of the time, a frame will show a list of items created through the well known itemize-environment:

\begin{frame} \frametitle{Title of the Frame} \begin{itemize} \item First item \item Second item \item ... \end{itemize} \end{frame}

Now what if you don’t want to show all the items at once, but one after another. The \pause-command will take care of it. Just add it anywhere you want to “pause” and will produce 3 slides. In presentation mode, the next bit of information is only shown after you press a key (usually space or arrow keys). So the above code example now looks as follows:

\begin{frame} \frametitle{Title of the Frame} \begin{itemize} \item First item \pause \item Second item \pause \item ... \end{itemize} \end{frame}

Figures are used similarly as within other document-classes:

 \usepackage{graphicx} ... \begin{figure} \includegraphics[scale=0.5]{img.jpg} \caption{Sample caption.} \end{figure}

Finally, I will show you something a little more advanced. Two columns, with items on the left and figures on the right side. The idea is to show an item along with an image. We want one item after the other to appear, while the image replaces the previous. Let me give you the code first and then explain some of the details:

\begin{frame}{A More Advanced Example} \begin{columns} \begin{column}{5cm} \begin{itemize} \item<1-> Figure 1 \item<2-> Figure 2 \item<3-> Figure 3 \end{itemize} \vspace{2cm} \end{column} \begin{column}{5cm} \includegraphics<1>[scale=0.1]{img1.jpg} \includegraphics<2>[scale=0.1]{img2.jpg} \includegraphics<3>[scale=0.1]{img3.jpg} \end{column} \end{columns} \end{frame}

What’s new here is called overlay specification within an environment (itemize) and lets you display different text/content on different slides or a range of slides.

<1-> indicates that this item will be displayed from slide 1 onwards in this frame. We could also have used <1-3>. Whereas the actual figures will only be displayed on their specific slide, e.g. <1>.

If there is no environment, the set of things to display has to be enclosed by the overprint-environment:  \begin{overprint}...\end{overprint}.

Another thing is the “overlay specification” for commands, e.g. to change the text-color for slides 2 and 3:

\color<2-3>[rgb]{1,0,0} This text is red on slides 2 and 3, otherwise black.

Here, the overlay specification always has to follow the command before any additional arguments. I have to admit, slightly useless, but at least it illustrates the result nicely (example was taken from the user guide page 81).

The following a complete code sample with a few frames containing the various examples described above:

\documentclass{beamer} \usepackage{graphicx} \usetheme{Singapore} \title{Presentation Title} \author{The Author} \date{May 4, 2011} \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{Outline} \tableofcontents \end{frame} \section{List of Items} \begin{frame} \frametitle{List of Items} \begin{itemize} \item First item \pause \item Second item \pause \item ... \end{itemize} \end{frame} \section{Figure Example} \begin{frame} \frametitle{Figure Example} \begin{figure} \includegraphics[scale=0.1]{img1.jpg} \caption{Sample caption.} \end{figure} \end{frame} \section{Overlay Specification} \begin{frame} \frametitle{Overlay Specification} \begin{columns} \begin{column}{5cm} \begin{itemize} \item<1-> Figure 1 \item<2-> Figure 2 \item<3-> Figure 3 \end{itemize} \vspace{3cm} \end{column} \begin{column}{5cm} \includegraphics<1>[scale=0.1]{img1.jpg} \includegraphics<2>[scale=0.1]{img2.jpg} \includegraphics<3>[scale=0.1]{img3.jpg} \end{column} \end{columns} \end{frame} \end{document}

The packages hyperref, xcolor, color are automatically loaded when using the beamer class.

## Generating dummy text/blindtext with Latex for testing

I was often using any of the available “lorem ipsum” generators on the web while testing different things in Latex until I discovered that the Latex distribution provides packages generating blind text, which is definitely more convenient. With just a few lines of code, these packages will generate paragraphes, even whole documents with sections, paragraphs of text, lists, etc.

The first package that I will introduce is the “blindtext” package. First the language option as well as the package have to be loaded. Make sure you get the order right, otherwise your text might appear in latin by default.

\usepackage[english]{babel}
\usepackage{blindtext}

The language options english, (n)german and latin are available. French is also available, but in a preliminary version. Try it out yourself :-).

Now you are ready to create a paragraph or even a whole document with just one line of code.

For few/more paragraphs of normal text:

\blindtext
\Blindtext

For a small/large document:

\blinddocument
\Blinddocument

In an arbitrary number of repetitions, e.g.

\blindtext[5]

Furthermore,

\blindlist{env}[x]

creates a list with “x” being the number of items generated. The environment can be set to itemize, enumerate or description.

A more direct way to generate lists is by using the commands:

\blinditemize
\blindenumerate
\blinddescription

and their extended versions with capital letters are available. Similarly, the number of items is defined through the optional argument, e.g.

\blindenumerate[10]

If you want math within the text, use

\blindmathtrue
\blindmathfalse

respectively.

It is also possible to generate text with math including formulas, using

\blindmathpaper

The “lipsum” package is a more basic package. It generates a certain number of the standard “lorem ipsum” text:

\usepackage{lipsum}
...
\lipsum
\lipsum[3-56]

By default, the package will either generate slightly more than a single page (fist line). Alternatively, it generates an arbitrary number of paragraphs (second line).

For more information, please refer to the package information of the blindtext as well as the lipsum packages.

## Lists: Enumerate, itemize, description and how to change them

Latex distinguishes between three different enumeration/itemization environments. Each of them provide four levels, which means you can have nested lists of up to four levels.

Enumerate:

\begin{enumerate}
\item ...
\end{enumerate}

The enumerate-environment is used to create numbered lists.
If you like to change the appearance of the enumerator, the simplest way to change is to use the enumerate-package, giving you the possibility to optionally choose an enumerator.

\usepackage{enumerate}
...
\begin{enumerate}[I]%for capital roman numbers.
\item
\end{enumerate}

\begin{enumerate}[(a)]%for small alpha-characters within brackets.
\item
\end{enumerate}

Itemize:

\begin{itemize}
\item ...
\end{itemize}

Itemization is probably the mostly used list in Latex. It also provides four levels. The bullets can be changed for each level using the following command:

\renewcommand{\labelitemi}{$\bullet$}
\renewcommand{\labelitemii}{$\cdot$}
\renewcommand{\labelitemiii}{$\diamond$}
\renewcommand{\labelitemiv}{$\ast$}

Amongst the more commonly used ones are $\bullet$ ($\bullet$), $\cdot$ ($\cdot$), $\diamond$ ($\diamond$), $-$ ($-$), $\ast$ ($\ast$) and $\circ$ ($\circ$).

Description:

\begin{description}
\item[] ...
\end{description}

The description list might be the least known. It comes in very handy if you need to explain notations or terms. Its neither numbered nor bulleted.

Example:

\begin{description}
\item[Biology] Study of life.
\item[Physics] Science of matter and its motion.
\item[Psychology] Scientific study of mental processes and behaviour.
\end{description}

And in a PDF it would look like this:

Example of a description list.

Nested lists:

Lists can be nested. In other words, it is possible to have a sub-list for an item of a list. Usage is straight forward, different environments can be mixed (see example) and the maximum depth (number of levels) is 4. Here is an example:

\begin{itemize}
\item First level, itemize, first item
\begin{itemize}
\item Second level, itemize, first item
\item Second level, itemize, second item
\begin{enumerate}
\item Third level, enumerate, first item
\item Third level, enumerate, second item
\end{enumerate}
\end{itemize}
\item First level, itemize, second item
\end{itemize}

Note:

The space between different items can be controlled with the \itemsep command (can only be added just after “begin”):

\begin{itemize}\itemsep2pt
\item
\end{itemize}