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).
Customizing the TOC
\documentclass{book} \setcounter{tocdepth}{3} \begin{document} \tableofcontents \part{First Part} \chapter*{Preface} \addcontentsline{toc}{chapter}{Preface} \chapter{First main chapter} \section{A section} \section{Another section} \subsection{A smaller section} \subsubsection[Deeper level]{This section has an even deeper level} \chapter{Second main chapter} \part{Second part} \chapter{Third main chapter} \appendix \cleardoublepage \addtocontents{toc}{\bigskip} \addcontentsline{toc}{part}{Appendix} \chapter{Glossary} \chapter{Symbols} \end{document}
Figure 8.1
Creating and customizing lists of figures
\documentclass{book} \setcounter{tocdepth}{3} \renewcommand{\figurename}{Diagram} \renewcommand{\listfigurename}{List of Diagrams} \begin{document} \tableofcontents \listoffigures \part{First Part} \chapter*{Preface} \addcontentsline{toc}{chapter}{Preface} \chapter{First main chapter} \section{A section} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Enterprize Organizational Chart} \end{figure} \section{Another section} \subsection{A smaller section} \subsubsection[Deeper level]{This section has an even deeper level} \chapter{Second main chapter} \part{Second part} \chapter{Third main chapter} \addtocontents{lof}{Network Diagrams:} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Network overview} \end{figure} \begin{figure} \centering \fbox{Diagram placeholder} \caption{WLAN Design} \end{figure} \appendix \cleardoublepage \addtocontents{toc}{\bigskip} \addcontentsline{toc}{part}{Appendix} \chapter{Glossary} \chapter{Symbols} \end{document}
Figure 8.2
Generating an index
% !TEX makeindex document \documentclass{book} \usepackage{index} \makeindex \setcounter{tocdepth}{3} \renewcommand{\figurename}{Diagram} \renewcommand{\listfigurename}{List of Diagrams} \begin{document} \tableofcontents \listoffigures \part{First Part} \chapter*{Preface} \addcontentsline{toc}{chapter}{Preface} \chapter{First main chapter} \section{A section} \begin{figure} \centering \fbox{Diagram placeholder} \caption{\index{enterprise}Enterprise Organizational Chart} \end{figure} \section{Another section} \subsection{A smaller section} \subsubsection[Deeper level]{This section has an even deeper level} \chapter{Second main chapter} \part{Second part} \chapter{Third main chapter} \addtocontents{lof}{Network Diagrams:} \index{network} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Network overview} \end{figure} \begin{figure} \centering \fbox{Diagram placeholder} \caption{WLAN Design} \end{figure} \appendix \cleardoublepage \addtocontents{toc}{\bigskip} \addcontentsline{toc}{part}{Appendix} \chapter{Glossary} \chapter{Symbols} \clearpage \addcontentsline{toc}{chapter}{Index} \printindex \end{document}
Figure 8.3
Extending the index
% !TEX makeindex document \documentclass{book} \usepackage{index} \makeindex \setcounter{tocdepth}{3} \renewcommand{\figurename}{Diagram} \renewcommand{\listfigurename}{List of Diagrams} \newcommand{\group}{\TeX\ Users Group} \begin{document} \tableofcontents \listoffigures \part{First Part} \chapter*{Preface} \addcontentsline{toc}{chapter}{Preface} \chapter{First main chapter} \section{A section} \begin{figure} \centering \fbox{Diagram placeholder} \caption{\index{enterprise}Enterprise Organizational Chart} \end{figure} \index{enterprise!organization} \index{enterprise!organization!sales} \index{enterprise!organization!controlling} \index{enterprise!organization!operation} \section{Another section} \subsection{A smaller section} \subsubsection[Deeper level]{This section has an even deeper level} \chapter{Second main chapter} \part{Second part} \chapter{Third main chapter} \index{network|(} \addtocontents{lof}{Network Diagrams:} \index{network} \index{network!overview} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Network overview} \end{figure} \begin{figure} \centering \fbox{Diagram placeholder} \caption{WLAN Design} \end{figure} \clearpage % index commands for testing \index{wireless|see{WLAN}} \index{WLAN|emph} \index{Gamma@$\Gamma$} \index{\group\ sorted wrong} \index{TeX@\group\ sorted correctly} \index{schon@sch\"{o}n} \index{exclamation ("!)!loud} End of network chapter. \index{network|)} \appendix \cleardoublepage \addtocontents{toc}{\bigskip} \addcontentsline{toc}{part}{Appendix} \chapter{Glossary} \chapter{Symbols} \clearpage \addcontentsline{toc}{chapter}{Index} \printindex \end{document}
Figure 8.4
Changing to ISO style
% !TEX makeindex -s iso document \documentclass{book} \usepackage{index} \makeindex \setcounter{tocdepth}{3} \renewcommand{\figurename}{Diagram} \renewcommand{\listfigurename}{List of Diagrams} \newcommand{\group}{\TeX\ Users Group} \begin{document} \tableofcontents \listoffigures \part{First Part} \chapter*{Preface} \addcontentsline{toc}{chapter}{Preface} \chapter{First main chapter} \section{A section} \begin{figure} \centering \fbox{Diagram placeholder} \caption{\index{enterprise}Enterprise Organizational Chart} \end{figure} \index{enterprise!organization} \index{enterprise!organization!sales} \index{enterprise!organization!controlling} \index{enterprise!organization!operation} \section{Another section} \subsection{A smaller section} \subsubsection[Deeper level]{This section has an even deeper level} \chapter{Second main chapter} \part{Second part} \chapter{Third main chapter} \index{network|(} \addtocontents{lof}{Network Diagrams:} \index{network} \index{network!overview} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Network overview} \end{figure} \begin{figure} \centering \fbox{Diagram placeholder} \caption{WLAN Design} \end{figure} \clearpage % index commands for testing \index{wireless|see{WLAN}} \index{WLAN|emph} \index{Gamma@$\Gamma$} \index{\group\ sorted wrong} \index{TeX@\group\ sorted correctly} \index{schon@sch\"{o}n} \index{exclamation ("!)!loud} End of network chapter. \index{network|)} \appendix \cleardoublepage \addtocontents{toc}{\bigskip} \addcontentsline{toc}{part}{Appendix} \chapter{Glossary} \chapter{Symbols} \clearpage \addcontentsline{toc}{chapter}{Index} \printindex \end{document}
Figure 8.5
Creating a bibliography
\documentclass{article} \begin{document} \section*{Recommended texts} To study \TeX\ in depth, see \cite{DK86}. For writing math texts, see \cite{DK89}. \begin{thebibliography}{8} \bibitem{DK86} D.E. Knuth, \emph{The {\TeX}book}, 1986 \bibitem{DK89} D.E. Knuth, \emph{Typesetting Concrete Mathematics}, 1989 \end{thebibliography} \end{document}
Figure 8.6
Using labels
\documentclass{article} \begin{document} \section*{Recommended texts} To study \TeX\ in depth, see \cite{DK86}. For writing math texts, see \cite{DK89}. \begin{thebibliography}{Knuth89} \bibitem[Knuth86]{DK86} D.E. Knuth, \emph{The {\TeX}book}, 1986 \bibitem[Knuth89]{DK89} D.E. Knuth, \emph{Typesetting Concrete Mathematics}, 1989 \end{thebibliography} \end{document}
Figure 8.7
Using a bibliography database – here we use the filecontents environment to generate it
\documentclass{article} \begin{filecontents}[force]{example.bib} @book{DK86, author = "D.E. Knuth", title = "The {\TeX}book", publisher = "Addison Wesley", year = 1986 } @article{DK89, author = "D.E. Knuth", title = "Typesetting Concrete Mathematics", journal = "TUGboat", volume = 10, number = 1, pages = "31--36", month = apr, year = 1989 } \end{filecontents} \begin{document} \section*{Recommended texts} To study \TeX\ in depth, see \cite{DK86}. For writing math texts, see \cite{DK89}. \bibliographystyle{alpha} \bibliography{example} \end{document}
Figure 8.8
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.