Tag Archives: item

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.


Reverse enumerate or etaremune

I stumbled across this package recently thanks to a comment by ofer.

Basically, the etaremune package inverses the enumerate counter, making the indices decreasing rather than increasing.

Basic example:

\documentclass{article}
\usepackage{etaremune}
\begin{document}
\begin{etaremune}
	\item Third item
	\item Second item
	\item First item
\end{etaremune}
\end{document}

basic_etaremune

Basic etaremune example.

Furthermore, to make the package more flexible, it offers different customizations.

Starting number:

The start option, lets you begin with an arbitrary number. In case the starting number is smaller than the number of items, the counter won’t further decrease once it reaches zero.

\usepackage{etaremune}[start=7]

Nesting (with enumerate):

Normal lists can be nested and so can etaremune lists. The lists can also be mixed with normal, enumerate lists. The documentation has a very nice example which I will just reuse here:

\renewcommand{\labelenumi}{\theenumi)}
\renewcommand{\theenumii}{\roman{enumii}}
\begin{enumerate}
	\item First.
	\begin{etaremune}
		\item third.\label{notice}
		\item second.
		\item first.
	\end{etaremune}
	\item Second.
	\item Third.
\end{enumerate}
Notice item~\ref{notice}.

Controlling the style:

Finally, the package allows the usage of some options for both, global and local style control.

Global options:

\usepackage[<options>]{etaremune}

Local options:
\begin{etaremune}[<options>]

Available options:

Vertical lengths control:
\topsep, \partopsep, \itemsep and \parsep.

Horizontal lengths control:
\leftmargin, \rightmargin, \listparindent, \itemindent, \labelwidth and \labelsep.

Here is the example from above slightly extended with the options itemsep and parsep set to zero. The first reduces the space between items of the same level to a minimum, whereas the latter between levels.

\documentclass{article}
\usepackage{etaremune}
\begin{document}
\renewcommand{\labelenumi}{\theenumi)}
\renewcommand{\theenumii}{\roman{enumii}}
\renewcommand{\theenumiii}{\Alph{enumiii}}
\begin{enumerate}
	\item First
	\item Second
	\begin{etaremune}[itemsep=0pt,parsep=0pt]
		\item third.\label{notice}
		\item second.
		\begin{etaremune}
			\item subsecond
			\item subfirst
		\end{etaremune}
		\item first.
	\end{etaremune}
	\item Third
\end{enumerate}
Notice item~\ref{notice}.
\end{document}

etaremune example

etaremune example


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.

A comprehensive user guide can be downloaded from CTAN.


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.

Example of a description list.

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}


Follow

Get every new post delivered to your Inbox.

Join 316 other followers