## Tiny leaves for official LaTeX announcements

Seth Godin mentioned in his recent blog post on simple typography that certain fonts remind us of something. I’m not a professional. But for to fun it, I tried to reproduce Seth’s first example using PGF/TikZ.

And here is the result (using LaTeX’s standard font Computer Modern).

Below is the code. Just copy and paste the preamble and officialize pretty much anything!

Preamble

\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings}

\newcounter{leafs}

\tikzset{%
leaf/.style={/utils/exec=\setcounter{leafs}{0},
decorate,decoration={
markings,
mark=at position 0 with {
\draw [bend left=35,fill=black] (0,0) to ++(-0.3,0.02*\sign) to ++(0.3,-0.02*\sign);},
mark=between positions 0.02 and 0.5 step 0.05 with {
\draw [bend right=35,fill=black] (0.01*\sign,0.01*\sign) to ++(-0.2-\mult,0.3*\sign+\mult*\sign) to ++(0.2+\mult,-0.3*\sign-\mult*\sign);
\stepcounter{leafs};},
mark=between positions 0.54 and 0.99 step 0.04875 with {
\draw [bend left=35,fill=black] (-0.01*\sign,0.01*\sign) to ++(0.2+\mult,0.3*\sign+\mult*\sign) to ++(-0.2-\mult,-0.3*\sign-\mult*\sign);},
}
}}

\newcommand{\leaves}[1]{%
\setlength{\lineskip}{6pt plus 6pt minus 0pt}\lineskiplimit=\baselineskip
\def\mult{0.03*\theleafs}
\begin{tikzpicture}
\node [align=center] (box) {\uppercase{#1}};
\node [below left=of box] (ll) {};
\node [above left=of box] (ul) {};
\node [below right=of box] (lr) {};
\node [above right=of box] (ur) {};
\def\sign{-1}
\draw [bend right=45, fill=black,postaction=leaf] (ul) to (ll) to ++(0.1,0.1) to [bend left=45] (ul);
\def\sign{1}
\draw [bend left=45, fill=black,postaction=leaf] (ur) to (lr) to ++ (-0.1,0.1) to [bend right=45] (ur);
\end{tikzpicture}
}

Document

\leaves{everything looks\\{\Huge official}\\{\tiny with tiny leaves around it}}

## Cleveref, a clever way to reference in LaTeX

Using standard cross-referencing in LaTeX only produces the label number, a name describing the label such as figure, chapter or equation has to be added manually. The cleveref package overcomes this limitation by automatically producing the label name and number. It further allows cross-referencing ranges of labels and multiple labels of the same or different kinds, including auto-sorting and compression of labels.

##### Basic cross-reference command

Cleveref implements \cref for basic cross-referencing. The command is used in the same way as the standard \ref command. Besides the label number it also produces the reference kind.

Warning: cleverref has to be loaded after hyperref!

Here is an example:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{cleveref}
\begin{document}

\begin{align}
y&=a_1x+b_1\label{eqn:1}
\end{align}

\noindent
Standard equation reference (\textbackslash ref): \ref{eqn:1}\\
Cleveref equation reference (\textbackslash cref): \cref{eqn:1}

\begin{figure}[ht]\centering\rule{0.5\linewidth}{0.1\linewidth}\caption{First figure}\label{fig:1}\end{figure}

\noindent
Standard figure reference (\textbackslash ref): \ref{fig:1}\\
Cleveref figure reference (\textbackslash cref): \cref{fig:1}

\end{document}

##### Multiple labels (sort and compress)

To cross-reference multiple labels of the same or different kinds, the \cref command is used. Labels are separated by commas without white-space (\cref{ref1,ref2,etc.}). For a range of the same label kind, the command \crefrange{first}{last} is available.

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{cleveref}

\begin{document}

\begin{align}
y&=a_1x+b_1\label{eqn:1}\\
y&=a_2x+b_2\label{eqn:2}\\
y&=a_3x+b_3\label{eqn:3}\\
y&=a_4x+b_4\label{eqn:4}
\end{align}

\noindent
Range example: \crefrange{eqn:1}{eqn:4}

\begin{figure}[ht]\centering\rule{0.5\linewidth}{0.1\linewidth}\caption{First figure}\label{fig:1}\end{figure}

\noindent
Mixed references example: \cref{eqn:1,eqn:3,eqn:4,fig:1}

\end{document}

##### Capitalize at beginning of sentence

By default, label names are produced with a small initial letter. To capitalize the first letter at the beginning of a sentence, use \Cref and \Crefrange instead.

For capitalization of all label names throughout the document, load the package with the capitalise option.

\usepackage[capitalise]{cleveref}

##### Full label names

If you prefer to use the full label name rather than abbreviations such as fig. or eq., load the package with the noabbrev option:

\usepackage[noabbrev]{cleveref}

##### Clickable references with hyperref

The cleveref package is fully compatible with hyperref (package manual). It is important to load the cleveref package last, after hyperref.

% Preamble
\usepackage{...} % other packages
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}
...

##### Other features of the package

The cleveref package offers a lot more, including:

• Customization of labels
• Name-only references
• Page number of label
• and more…

See the package documentation for more details.

##### Alternative packages

There are a number of packages implementing similar features. According to the documentation, cleveref is among the most extensive in terms of functionality and flexibility. However, through a recently published post on LaTeX Alive I learnt that the refstyle package is a valid alternative to cleveref and I’ll definitely give it a try.

I wrote a somewhat short post on list of figures and list of tables a few years ago. Nevertheless, it gets quite a bit of traffic, possibly due to the large number of comments. For that reason, I decided to put together another, more informative post on the same topic that includes table of contents.

I use the following common abbreviations throughout the post:

• lof: list of figures
• lot: list of tables

##### Creating content lists, the basic commands

Creating content lists in LaTeX documents is straight forward. Typing these three commands is sufficient to produce a toc, lof, and lot. To produce the lists, the document has to be typeset twice. The first iteration collects all headings and captions and writes them to meta files (*.toc, *.lof, *.lot). The second iteration prints the lists, based on the content of the meta files.

\tableofcontents
\listoffigures
\listoftables

\documentclass[11pt]{article}

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\clearpage

\section{Dummy section 1}
\begin{figure}[ht]
\begin{center}

\caption{Dummy figure 1}
\label{fig:dum1}
\end{center}
\end{figure}

\begin{figure}[ht]
\begin{center}

\caption{Dummy figure 2}
\label{fig:dum2}
\end{center}
\end{figure}

\begin{table}[ht]
\caption{Dummy table 1}
\begin{center}
\begin{tabular}{|c|c|}

\end{tabular}
\end{center}
\label{tab:dum1}
\end{table}

\section{Dummy section 2}

\end{document}

Depending on the document-class employed, page-breaks are added between toc, lof, and lot. Article produces lists without space between them. Report and book insert \clearpage or \cleardoublepage, depending on whether twoside and openright options are set (default for book), to start each list on a blank page. See here for more details on document-class options.

##### Controlling the depth of content added to toc

Depending on the size of your document (length of chapters, sections, etc.), you might want to increase or decrease the level of headings added to toc. To control the depth of content added to toc the counter tocdepth is modified in the preamble as follows:

\setcounter{tocdepth}{level}
%level -1: part, 0: chapter, 1: section, etc.

In the following example all headings are added to toc (level: 5):

\documentclass[11pt]{report}

\setcounter{tocdepth}{5} %shows all levels incl. paragraph
\begin{document}

\tableofcontents

\chapter{Dummy chapter}
\section{Dummy section}
\subsection{Dummy subsection}
\subsubsection{Dummy subsubsection}
\paragraph{Dummy paragraph}

\end{document}

Lists of figures and tables are not automatically added to the table of contents. I will introduce two different approaches here, an automatic and a manual approach.

Automatic approach:

%preamble
\usepackage[nottoc]{tocbibind}

%content
\tableofcontents
\listoffigures
\listoftables

Manual approach:

Lof and lot can be added manually through \addcontentsline. The command takes three arguments: the file (e.g. toc), the level (e.g. chapter), and the text to be added.

%article
\tableofcontents
\listoffigures
\listoftables

%report and book
\tableofcontents
\clearpage %\cleardoublepage %for openright
\listoffigures
\clearpage %\cleardoublepage %for openright
\listoftables
\clearpage %\cleardoublepage %for openright

\listfigurename and \listtablename produce the list headings. This way, toc entries are automatically updated, should the headings be changed for some reason. Adding the lists to toc before the actual command as well as them makes sure the page numbers are set correctly. The document-class option openright (requires twoside in report) always starts chapters on odd pages, which is when \cleardoublepage comes in handy. It adds either one or two page-breaks depending on whether the content ends on an even or odd page.

##### Short captions for lof/lot

Some figures and tables have long captions. It might not always be preferable to reproduce the whole caption in lof/lot. The caption command provides a convenient way to produce a shorter figure/table description in the lof/lot by using its optional argument, without change to the actual figure/table caption.

\caption[short lof/lot caption]{long caption ...}

\documentclass[11pt]{article}
\usepackage{blindtext}
\begin{document}

\tableofcontents
\listoffigures

\section{Dummy section 1}
\begin{figure}[ht]
\begin{center}
\rule{0.5\linewidth}{0.35\linewidth}
\caption[Long caption figure]{\blindtext}
\label{fig:dum1}
\end{center}
\end{figure}

\end{document}

The same works with headings and table of contents. The \chapter and \section commands also take an optional argument which, when used, produce an alternative chapter/section name in toc.

\chapter[Short chapter name]{Long chapter name ...}

##### Linking toc/lof/lot with content using hyperref

Loading hyperref (package documentation) is generally sufficient to link list entries with document content. With some exceptions, the hyperref package usually has to be loaded last. For a better visualisation of links, it is a good idea to change the link font color, e.g. to blue:

\usepackage[colorlinks=true,linkcolor=blue]{hyperref}

##### Further customizations

This earlier post describes 10 ways to customize toc/lof/lot, from basic to more advanced topics.

##### The tocloft package

The tocloft package provides means of controlling the typographic design of table of contents, list of figures and list of tables (copied from its documentation). Introducing the package would go beyond the scope of this article. However, I am happy to help should you have any specific question. Just drop me a comment below.

## Simple Smiley faces with TiKZ in LaTeX

I recently wrote an article on side-by-side figures in LaTeX (TUGboat 34:1), based on a series of posts on this blog. For illustration of the code samples, I created a series of very basic Smileys faces for which I publish the code here. Let me know below if you have suggestions for improvement or ideas for additional emotions. Thank you .

##### Neutral Smiley

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0cm,0cm) circle(1cm);
\draw[thick] (-0.5,-0.6) -- (0.5,-0.6);
\draw [thick, fill=black] (0,-0.2) circle (0.1);
\draw [rotate=90, fill=black] (0.3,0.3) ellipse (0.2 and 0.1);
\draw [rotate=90, fill=black] (0.3,-0.3) ellipse (0.2 and 0.1);
\end{tikzpicture}
\end{document}

##### Happy Smiley

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0cm,0cm) circle(1cm);
\draw[thick] plot [smooth,tension=1.5] coordinates{(-0.5,-0.5) (0,-0.8) (0.5,-0.5)};
\draw [thick, fill=black] (0,-0.2) circle (0.1);
\draw[thick] plot [smooth,tension=1.5] coordinates{(-0.4,0.4) (-0.3,0.5) (-0.2,0.4)};
\draw[thick] plot [smooth,tension=1.5] coordinates{(0.4,0.4) (0.3,0.5) (0.2,0.4)};
\end{tikzpicture}
\end{document}

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0cm,0cm) circle(1cm);
\draw[thick] plot [smooth,tension=1.5] coordinates{(-0.5,-0.6) (0,-0.4) (0.5,-0.6)};
\draw [thick, fill=black] (0,-0.2) circle (0.1);
\draw [rotate=90, fill=black] (0.3,0.3) ellipse (0.2 and 0.1);
\draw [rotate=90, fill=black] (0.3,-0.3) ellipse (0.2 and 0.1);
\draw[thick] plot [smooth,tension=1.5] coordinates{(0.3,0.0) (0.4,-0.2) (0.2,-0.2) (0.3,0.0)};
\end{tikzpicture}
\end{document}

##### Sleepy Smiley

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0cm,0cm) circle(1cm);
\draw[thick] (-0.4,0.3) -- (-0.2,0.3);
\draw[thick] (0.4,0.3) -- (0.2,0.3);
\draw [thick, fill=black] (0,-0.2) circle (0.1);
\draw [thick, fill=white] (0,-0.4) circle (0.2);
\end{tikzpicture}
\end{document}

##### Angry Smiley

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0cm,0cm) circle(1cm);
\draw[thick] plot [smooth,tension=1.5] coordinates{(-0.3,-0.7) (-0.2,-0.6) (0.3,-0.6)};
\draw[thick] (-0.4,0.5) -- (-0.2,0.4);
\draw[thick] (0.4,0.6) -- (0.2,0.5);
\draw [thick, fill=black] (0,-0.2) circle (0.1);
\draw [rotate=90, fill=black] (0.3,0.3) ellipse (0.05 and 0.1);
\draw [rotate=90, fill=black] (0.3,-0.3) ellipse (0.05 and 0.1);
\end{tikzpicture}
\end{document}

##### Blush Smiley

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) circle (1);
\draw[thick] plot [smooth,tension=1.5] coordinates{(-0.3,-0.5) (0,-0.7) (0.3,-0.5)};\draw [thick, fill=black] (0,-0.2) circle (0.1);
\node[circle,minimum width=0.1, inner color=black] at (-0.6,-0.2) {};
\node[circle,minimum width=0.1, inner color=black] at (0.6,-0.2) {};
\draw [rotate=90, fill=black] (0.3,0.3) ellipse (0.2 and 0.1);
\draw [rotate=90, fill=black] (0.3,-0.3) ellipse (0.2 and 0.1);
\end{tikzpicture}
\end{document}

## Hidden text with LaTeX colored multi-row tables

When multirow cells in LaTeX tables are colored, the text is partially hidden as illustrated by the example below. This happens because the color of the second row is added after typesetting the text of the first row.

\documentclass[12pt]{article}
\usepackage{colortbl}
\usepackage[table]{xcolor}
\usepackage{multirow}

\definecolor{lightgray}{gray}{0.9}
\rowcolors{2}{white}{lightgray}
\begin{document}

\begin{table}[ht]
\caption{Colored multirow table}
\begin{center}
\begin{tabular}{cc}
\hline
\multirow{2}{*}{Multi-row}&Single-row\\
&Single-row\\
Single-row&Single-row\\
\hline
\end{tabular}
\end{center}
\label{default}
\end{table}%

\end{document}

##### Solution:

There is a simple solution to this problem. If the multirow command is placed in the last possible row and its first argument is made negative, the text is added only after the color and becomes fully visible.

\documentclass[12pt]{article}
\usepackage{colortbl}
\usepackage[table]{xcolor}
\usepackage{multirow}

\definecolor{lightgray}{gray}{0.9}
\rowcolors{2}{white}{lightgray}
\begin{document}

\begin{table}[ht]
\caption{Colored multirow table}
\begin{center}
\begin{tabular}{cc}
\hline
&Single-row\\
\multirow{-2}{*}{Multi-row}&Single-row\\
Single-row&Single-row\\
\hline
\end{tabular}
\end{center}
\label{default}
\end{table}%

\end{document}

## Reverse numbering for chapters, sections, etc.

I was recently asked if there is a way to reverse the numbering of chapters in a report from n to 1. I didn’t find an easy way to do it which is why I decided to write a short post.

Here is the minimal example used to produce the above output. I will explain the details further below.

\documentclass[10pt]{report}
\usepackage{totcount}
\usepackage{blindtext}
\regtotcounter{chapter}
\makeatletter
\renewcommand{\thechapter}{\number\numexpr\c@chapter@totc-\c@chapter+1\relax}
\makeatother

\begin{document}
\tableofcontents
\chapter{First Chapter}
\Blindtext
\chapter{Second Chapter}
\Blindtext
\chapter{Third Chapter}
\Blindtext
\chapter{Fourth Chapter}
\Blindtext
\end{document}

The code has to be typeset at least twice to get the numbers right.

##### Explanations of the code

First, the totcount package is loaded. It provides macros to print or use the total number (final value) of different counters. For some examples on how to use the package see here.

\usepackage{totcount}

Next, we need to tell the package which counter we want to use by registering it in the preamble.

\regtotcounter{chapter}

And finally we do the big math. We redefine the \thechapter macro, setting it to total number of chapters minus current chapter number plus 1. To evaluate the numerical expression we use \numexpr\relax.

\renewcommand{\thechapter}{\number\numexpr\c@chapter@totc-\c@chapter+1\relax}

##### Modifications for section

With a few minor changes, the code works for sections:

\documentclass[10pt]{article}
\usepackage{totcount}
\regtotcounter{section}
\makeatletter
\renewcommand{\thesection}{\number\numexpr\c@section@totc-\c@section+1\relax}
\makeatother
\begin{document}
...

##### Reverse numbering for lists

For enumerate there exists a package, etaremune, providing macros to reverse the numbering. See this post for some examples.

## Menukeys: typesetting menu sequences, directory path names and keyboard shortcuts in LaTeX

I recently came across the menukeys package and found it very useful for software documentation and description of workflows. The output it creates is quite neat. Therefore, I will briefly introduce the main features and give some examples here.

##### An example at the beginning

\documentclass{article}
\usepackage[T1]{fontenc}

\begin{document}
\noindent For saving a file to the desktop, go to \menu[,]{File, Save As...} and navigate to \directory{Users/Username/Desktop}. Alternatively, use the following keyboard shortcuts: \keys{\cmd+\shift+S} and \keys{\cmd+D}.
\end{document}

##### Getting the package

The package comes with the texlive distribution. Alternatively, you can download it from CTAN or the author’s GitHub repository.

As for any package, menukeys is loaded in the document preamble:

\usepackage{menukeys}

##### Package options

The package implements several options. They handle the differences in keys or key modifiers between different operating systems and are therefore only required when typesetting keyboard shortcuts.

%Windows

%Mac OS X (symbols)

%Mac OS X (text)
\usepackage[os=mac, mackeys=text]{menukeys}

A full list of special keys is given below.

Typesetting menu sequences becomes useful for documenting a software’s graphical user interface or to keep track of a series of actions in a complex analysis workflow. The command is straight forward:

\documentclass{article}

\begin{document}
\menu[,]{Item 1, Item 2, Item 3, ...}
\end{document}

The optional argument [,] changes the default separator to comma (,). Due to a conflict with HTML, I can’t use the package’s default separator, the greater than symbol (>), in the code here on my blog.

##### Directory path names

The default separator for directory path names is the forward slash (/), which is converted to a small arrow-head in the output.

\documentclass{article}

\begin{document}
\directory{Item 1 / Item 2 / Item 3 / ...}
\end{document}

##### Keyboard shortcuts

Keyboard shortcuts describe combinations of keys to be pressed for a certain action. The default separator used between keys is the plus symbol (+).

\documentclass{article}

\begin{document}
\keys{Item 1 + Item 2 + Item 3 + ...}
\end{document}

Below a list of key macros copied from the package documentation.

Here is an example of how to describe the keyboard shortcut to create a custom-size screen grab on Mac OS X using Mac keyboard symbols:

\documentclass{article}
\usepackage[T1]{fontenc} % required for Mac command key rendering

\begin{document}
\keys{\cmd + \shift + 4}
\end{document}

##### Changing the style

The package comes with a set of styles. Some styles change the look only subtly, others more drastically. See chapter 4.2 of the package documentation for a complete list of styles available. To change the style, the package provides the following macro:

\renewmenumacro{list}[separator]{style}

A few examples:

\renewmenumacro{\menu}{roundedmenus} % default: menus
\renewmenumacro{\keys}{shadowedroundedkeys} % default: roundedkeys

##### Changing the default separator

Each command has its specific default separator, as described earlier. Simply use the optional argument to change the default separator. This will not, however, change the way the output looks, only the way a command is typed. E.g. the following command changes the key default separator locally to comma.

\keys[,]{\cmd, \shift, 4}

To change the separator globally (preamble) or from a certain position onwards, use the same macro as for changing the style. Here is an example:

\documentclass{article}
\parindent=0pt

\begin{document}
\directory{Item 1 / Item 2 / Item 3 / ...} % default separator

\directory{Item 1, Item 2, Item 3, ...} % comma as separator
\end{document}

The output is exactly the same.

Final note: Spaces added before or after the separator will be ignored by the package, i.e. a + b, a+ b, and a+b produce exactly the same result.

See the package documentation for a complete list of separators available.

## On paragraphs in TeX/LaTeX

When writing documents in TeX/LaTeX, it is important to understand how the TeX engine “thinks”. A paragraph is the basic text unit in a document and many TeX/LaTeX commands, when used properly, affect the current paragraph only. TeX provides a set of basic commands controlling the way a paragraphs are typeset. The following article explains the most commonly used commands and illustrates them with examples.

Any piece of text in TeX/LaTeX is a paragraph and follows predefined specifications. Single line-breaks will be ignored by the engine. To end a paragraph, leave a blank line between the end of the current and the beginning of the new paragraph.

...end of the current paragraph.

Beginning of a new paragraph...

The second, indented line marks the beginning of a new paragraph.

Alternatively, \par might be used to end a paragraph.

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

##### Paragraph width

In plain TeX, \hsize controls the paragraph width, set to 6.5in by default. The example below shows how to change the paragraph width for a single paragraph.

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

\hsize 4in
\blindtext
\end{document}

The \leftskip and \rightskip commands provide a alternative, reducing the paragraph size from left and right respectively.

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

\leftskip=1.5in
\blindtext

\leftskip=0in \rightskip=1.5in
\blindtext
\end{document}

LaTeX knows at least two macros to control the paragraph width, the minipage environment and the \parbox command.

%Parbox macro
\parbox{4in}{...}

%Minipage environment
\begin{minipage}{4in}
...
\end{minipage}

Within a paragraph, the width is changed through the \hangindent and \hangafter commands. \hangindent controls the amount of indentation from left (positive value) or right (negative value). \hangafter, on the other hand, controls the number of full-width lines before changing the indent (\hangindent). A positive number produces full-width lines at the beginning, whereas a negative number produces them at the end.

Here is an example reducing the paragraph width by 2in from the right after the fifth line.

\documentclass[11pt]{article}
\usepackage{blindtext}
\begin{document}
\hangindent=-2in
\hangafter=5
\blindtext

\blindtext
\end{document}

##### Paragraph indentation

By default, TeX indents the first line of each paragraphs by 20pt. The \parindent command controls the indentation of paragraphs. To change the indentation document-wide, set \parindent in the document preamble to the desired value. To disable the indentation for a single paragraph, use \noindent at the beginning of the paragraph.

\documentclass{article}
\usepackage{blindtext}
\parindent=0pt % disables indentation
\begin{document}
\blindtext

\blindtext
\end{document}

##### Vertical space between paragraphs

TeX leaves no vertical space between paragraphs by default (\parskip=0pt). Similar to \parindent, setting \parskip in the document preamble controls the vertical space between paragraphs document-wide.

\documentclass{article}
\usepackage{blindtext}
\parskip=12pt % adds vertical space between paragraphs
\begin{document}
\blindtext

\blindtext
\end{document}

##### Vertical space between lines

While using the default font size (10pt), the line distance is 12pt. A ratio of 1.2 (line height to font size) leaves enough space between lines for a good reading experience and gives a harmonious look. The line height can be changed through \baselineskip.

More on font size in LaTeX.

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

\baselineskip=20pt
\blindtext
\end{document}

A gentle introduction to TeX, a relatively short, but well written introduction to TeX by Michael Doob.

## LaTeX documentclass options illustrated

The three most commonly used standard document-classes in LaTeX include: article, report and book. A number of global options allows customization of certain elements of the document by the author. Different document-classes might have different default settings. The following post illustrates available options with figures, provides alternatives and highlights the default option for each document-class.

To change the default behavior, the option is provided as an optional parameter to the documentclass command.

\documentclass[option1, option2, etc.]{article}

• Font size (10pt, 11pt, 12pt)
• Paper size and format (a4paper, letterpaper, etc.)
• Draft mode (draft)
• Multiple columns (onecolumn, twocolumn)
• Formula-specific options (fleqn and leqno)
• Landscape print mode (landscape)
• Single- and double-sided documents (onepage, twopage)
• Titlepage behavior (notitlepage, titlepage)
• Chapter opening page (openright, openany)
•

##### Font size

LaTeX knows three standard font sizes:

• 10pt (default)
• 11pt
• 12pt

Other global and local font sizes are available through various packages.

The following example sets the global document font size to 12pt. The picture below compares the three LaTeX standard font sizes.

\documentclass[12pt]{article}
\usepackage{blindtext}
\begin{document}
\blindtext
\end{document}

##### Paper size and format

Different regions of the world use different standard physical paper sizes. Available are:

• a4paper (default)
• letterpaper (default in some distributions)
• a5paper
• b5paper
• executivepaper
• legalpaper

The following example compares (from left to right): legal, A4, Letter and A5.

\documentclass[a4paper]{article}
\usepackage{showframe}
\begin{document}
\begin{center}{\Huge A4 paper}\end{center}
\end{document}

The geometry package provides similar options and additional flexibility for paper size and margins.

##### Draft mode

Setting the draft option will speed up typesetting, because figures are not loaded, just indicated by a frame. LaTeX will also display hyphenation (Overfull hbox warning) and justification problems with a small black square. Delete the draft option or replace it with final in the final document version.

##### Multiple columns
• onecolumn (default)
• twocolumn

By default, text is typeset in a single column (onecolumn). LaTeX provides an easy way to switch to two columns through the document-class option twocolumn.

The multicol package allows creating more than two columns globally as well as locally.

##### Formula-specific options
• fleqn: left-alignment of formulas
• leqno: labels formulas on the left-hand side instead of right

These are two independent options manipulating the alignment and label position of formulas.

The top figure illustrates the default case with neither option set. The bottom figure shows how formulas are typeset when both options, fleqn and leqno, are set.

##### Landscape print mode

The landscape option changes the page layout to landscape mode. This, however, does not change the page margins accordingly (first page in figure), which is why for landscape documents with landscape content the pdflscape or geometry packages (second page in figure and code) are more suitable.

\documentclass[a4paper]{article}
\usepackage{blindtext, showframe}
\usepackage[landscape]{geometry}
\begin{document}
\blindtext
\end{document}

##### Single- and double-sided documents
• oneside (default for article and report)
• twoside (default for book)

In single-sided documents (oneside), the left and right margins are symmetric and headers are exactly the same on every page. In other words, the document does not distinguish between inner and outer margin. Twoside, on the other hand, generates double-sided content. The outer margin (even page: left; odd page: right) is wider by default (see figure below). It might appear that the header “switches” sides, but that because they are placed with respect to the margins. The twoside option is usually set for bound texts such as theses or books.

\documentclass[twoside]{report}
\usepackage{blindtext, showframe, fancyhdr}
\pagestyle{fancy}
\begin{document}
\chapter{First chapter}
\section{First section}
\blindtext
\clearpage
\Blindtext
\end{document}

##### Titlepage behavior
• notitlepage (default for article)
• titlepage (default for report and book)

The option titlepage ends the page after \maketitle and restarts on the next page. In article, the content starts right after \maketitle. The titlepage option is quivalent to:

\maketitle
\clearpage

The example below illustrates the default behavior of article.

\documentclass{article}
\usepackage{blindtext}
\title{This is an article}
\begin{document}
\maketitle
\begin{abstract}
\blindtext
\end{abstract}
\end{document}

##### Chapter opening page
• openany (default for report)
• openright (default for book)

Finally, the option openright always starts a chapter on the right (odd pages), leaving one page blank in case the last paragraph of the previous chapter ended on an odd page. It only works and makes sense with the twoside option set. The openany option starts the chapter on the next page (even or odd).

The openany, openright options are not available in article as it does not support \chapter!

\documentclass[twoside, openright]{report}
\usepackage{blindtext}
\begin{document}
\chapter{First chapter}
\blindtext
\chapter{Second chapter}
\blindtext
\end{document}

## 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:
\end{document}