Here are the Code examples of this chapter. You can compile them online right on this web page by pressing the Typeset / Compile button. You can also edit them for testing, and compile again.
For a better view with the online compiler, I sometimes use \documentclass[border=10pt]{standalone} instead of \documentclass{article}. Instead of having a big letter/A4 page, the standalone class crops the paper to see just the visible text without an empty rest of a page.
Any question about a code example? Post it on LaTeX.org, I will answer. As forum admin I read every single question there. (profile link).
Creating a bulleted list
\documentclass{article} \begin{document} \section*{Useful packages} LaTeX provides several packages for designing the layout: \begin{itemize} \item geometry \item typearea \item fancyhdr \item scrpage-scrlayer \item setspace \end{itemize} \end{document}
Figure 4.1
A bulleted list with two levels
\documentclass{article} \begin{document} \section*{Useful packages} LaTeX provides several packages for designing the layout: \begin{itemize} \item Page layout \begin{itemize} \item geometry \item typearea \end{itemize} \item Headers and footers \begin{itemize} \item fancyhdr \item scrpage-scrlayer \end{itemize} \item Line spacing \begin{itemize} \item setspace \end{itemize} \end{itemize} \end{document}
Figure 4.2
Building an enumerated list
\documentclass{article} \begin{document} \begin{enumerate} \item State the paper size by an option to the document class \item Determine the margin dimensions using one of these packages: \begin{itemize} \item geometry \item typearea \end{itemize} \item Customize header and footer by one of these packages: \begin{itemize} \item fancyhdr \item scrpage-scrlayer \end{itemize} \item Adjust the line spacing for the whole document \begin{itemize} \item by using the setspace package \item or by the command \verb|\linespread{factor}| \end{itemize} \end{enumerate} \end{document}
Figure 4.3
Producing a definition list
\documentclass{article} \begin{document} \begin{description} \item[paralist] provides compact lists and list versions that can be used within paragraphs, helps to customize labels and layout. \item[enumitem] gives control over labels and lenghts in all kind of lists. \item[mdwlist] is useful to customize description lists, it even allows multi-line labels. It features compact lists and the capability to suspend and resume. \item[desclist] offers more flexibility in definition list. \item[multenum] produces vertical enumeration in multiple columns. \end{description} \end{document}
Figure 4.4
Getting compact lists
\documentclass{article} \usepackage{paralist} \begin{document} \begin{compactenum} \item State the paper size by an option to the document class \item Determine the margin dimensions using one of these packages: \begin{compactitem} \item geometry \item typearea \end{compactitem} \item Customize header and footer by one of these packages: \begin{compactitem} \item fancyhdr \item scrpage-scrlayer \end{compactitem} \item Adjust the line spacing for the whole document \begin{compactitem} \item by using the setspace package \item or by the command \verb|\linespread{factor}| \end{compactitem} \end{compactenum} \end{document}
Figure 4.5
A list within a paragraph
\documentclass{article} \usepackage{paralist} \begin{document} \begin{compactenum} \item State the paper size by an option to the document class \item Determine the margin dimensions using one of these packages: \begin{compactitem} \item geometry \item typearea \end{compactitem} \item Customize header and footer by one of these packages: \begin{compactitem} \item fancyhdr \item scrpage-scrlayer \end{compactitem} \item Adjust the line spacing for the whole document \begin{compactitem} \item by using the setspace package and one of its options: \begin{inparaenum} \item singlespacing \item onehalfspacing \item double spacing \end{inparaenum} \item or by the command \verb|\linespread{factor}| \end{compactitem} \end{compactenum} \end{document}
Figure 4.6
Choosing bullets and numbering format
\documentclass{article} \usepackage{enumitem} \setlist{nosep} \setitemize[1]{label=---} \setenumerate[1]{label=\textcircled{\scriptsize\Alph*}, font=\sffamily} \begin{document} \begin{enumerate} \item State the paper size by an option to the document class \item Determine the margin dimensions using one of these packages: \begin{itemize} \item geometry \item typearea \end{itemize} \item Customize header and footer by one of these packages: \begin{itemize} \item fancyhdr \item scrpage-scrheader \end{itemize} \item Adjust the line spacing for the whole document \begin{itemize} \item by using the setspace package \item or by the command \verb|\linespread{factor}| \end{itemize} \end{enumerate} \end{document}
Figure 4.7
Resuming a list
\documentclass{article} \usepackage{enumitem} \setlist{nosep} \setitemize[1]{label=---} \setenumerate[1]{label=\textcircled{\scriptsize\Alph*}, font=\sffamily} \begin{document} \begin{enumerate} \item State the paper size by an option to the document class \item Determine the margin dimensions using one of these packages: \begin{itemize} \item geometry \item typearea \end{itemize} \item Customize header and footer by one of these packages: \begin{itemize} \item fancyhdr \item scrpage-scrheader \end{itemize} \end{enumerate} \noindent\textbf{Tweaking the line spacing:} \begin{enumerate}[resume*] \item Adjust the line spacing for the whole document \begin{itemize} \item by using the setspace package \item or by the command \verb|\linespread{factor}| \end{itemize} \end{enumerate} \end{document}
Figure 4.8
Layout of lists
\documentclass[12pt]{article} \usepackage{layouts} \begin{document} \listdiagram \end{document}
Figure 4.9
This code is available on Github. It is licensed under the MIT License, a short and simple permissive license with conditions only requiring preservation of copyright and license notices.
Go to next chapter.