intro.tex 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. %% intro.tex
  2. %% Copyright (C) 2014-2020 by Thomas Auzinger <thomas@auzinger.name>
  3. %
  4. % This work may be distributed and/or modified under the
  5. % conditions of the LaTeX Project Public License, either version 1.3
  6. % of this license or (at your option) any later version.
  7. % The latest version of this license is in
  8. % http://www.latex-project.org/lppl.txt
  9. % and version 1.3 or later is part of all distributions of LaTeX
  10. % version 2005/12/01 or later.
  11. %
  12. % This work has the LPPL maintenance status `maintained'.
  13. %
  14. % The Current Maintainer of this work is Thomas Auzinger.
  15. %
  16. % This work consists of the files vutinfth.dtx and vutinfth.ins
  17. % and the derived file vutinfth.cls.
  18. % This work also consists of the file intro.tex.
  19. \newacronym{ctan}{CTAN}{Comprehensive TeX Archive Network}
  20. \newacronym{faq}{FAQ}{Frequently Asked Questions}
  21. \newacronym{pdf}{PDF}{Portable Document Format}
  22. \newacronym{svn}{SVN}{Subversion}
  23. \newacronym{wysiwyg}{WYSIWYG}{What You See Is What You Get}
  24. \newglossaryentry{texteditor}
  25. {
  26. name={editor},
  27. description={A text editor is a type of program used for editing plain text files.}
  28. }
  29. \chapter{Introduction to \LaTeX}
  30. Since \LaTeX\ is widely used in academia and industry, there exists a plethora of freely accessible introductions to the language.
  31. Reading through the guide at \url{https://en.wikibooks.org/wiki/LaTeX} serves as a comprehensive overview for most of the functionality and is highly recommended before starting with a thesis in \LaTeX.
  32. \section{Installation}
  33. A full \LaTeX\ distribution\index{distribution} consists not only of the binaries that convert the source files to the typeset documents, but also of a wide range of packages and their documentation.
  34. Depending on the operating system, different implementations are available as shown in Table~\ref{tab:distrib}.
  35. \textbf{Due to the large amount of packages that are in everyday use and due to their high interdependence, it is paramount to keep the installed distribution\index{distribution} up to date.}
  36. Otherwise, obscure errors and tedious debugging ensue.
  37. \begin{table}
  38. \centering
  39. \begin{tabular}{cccc}
  40. \toprule
  41. Distribution & Unix & Windows & MacOS \\
  42. \midrule
  43. TeX Live & \textbf{yes} & yes & (yes) \\
  44. MacTeX & no & no & \textbf{yes} \\
  45. MikTeX & (yes) & \textbf{yes} & yes \\
  46. \bottomrule
  47. \end{tabular}
  48. \caption{\TeX/\LaTeX\ distributions for different operating systems. Recomended choice in \textbf{bold}.}
  49. \label{tab:distrib} % \label has to be placed AFTER \caption to produce correct cross-references.
  50. \end{table}
  51. \section{Editors}
  52. A multitude of \TeX\ \glspl{texteditor} are available differing in their editing models, their supported operating systems and their feature sets.
  53. A comprehensive overview of \glspl{texteditor} can be found at the Wikipedia page \url{https://en.wikipedia.org/wiki/Comparison_of_TeX_editors}.
  54. TeXstudio (\url{http://texstudio.sourceforge.net/}) is recommended.
  55. Most editors support a synchronization of the generated document and the \LaTeX\ source by \verb|Ctrl| clicking either on the source document or the generated document.
  56. \section{Compilation}
  57. Modern editors usually provide the compilation programs to generate \gls{pdf} documents and for most \LaTeX\ source files, this is sufficient.
  58. More advanced \LaTeX\ functionality, such as glossaries and bibliographies, needs additional compilation steps, however.
  59. It is also possible that errors in the compilation process invalidate intermediate files and force subsequent compilation runs to fail.
  60. It is advisable to delete intermediate files (\verb|.aux|, \verb|.bbl|, etc.), if errors occur and persist.
  61. All files that are not generated by the user are automatically regenerated.
  62. To compile the current document, the steps as shown in Table~\ref{tab:compile} have to be taken.
  63. \begin{table}
  64. \centering
  65. \begin{tabular}{rl}
  66. \toprule
  67. & Description \\
  68. \midrule
  69. 1 & Scan for refs, toc/lof/lot/loa items and cites \\
  70. 2 & Build the bibliography \\
  71. 3 & Link refs and build the toc/lof/lot/loa \\
  72. 4 & Link the bibliography \\
  73. 5 & Build the glossary \\
  74. 6 & Build the acronyms \\
  75. 7 & Build the index \\
  76. 8 & Link the glossary, acronyms, and the index \\
  77. 9 & Link the bookmarks \\
  78. \midrule
  79. & Command \\
  80. \midrule
  81. 1 & \verb|pdflatex.exe example| \\
  82. 2 & \verb|bibtex.exe example| \\
  83. 3 & \verb|pdflatex.exe example| \\
  84. 4 & \verb|pdflatex.exe example| \\
  85. 5 & \verb|makeindex.exe -t example.glg -s example.ist| \\
  86. & \verb| -o example.gls example.glo| \\
  87. 6 & \verb|makeindex.exe -t example.alg -s example.ist| \\
  88. & \verb| -o example.acr example.acn| \\
  89. 7 & \verb|makeindex.exe -t example.ilg -o example.ind example.idx| \\
  90. 8 & \verb|pdflatex.exe example| \\
  91. 9 & \verb|pdflatex.exe example| \\
  92. \bottomrule
  93. \end{tabular}
  94. \caption{Compilation steps for this document. The following abbreviations were used: table of contents (toc), list of figures (lof), list of tables (lot), list of algorithms (loa).}
  95. \label{tab:compile} % \label has to be placed AFTER \caption to produce correct cross-references.
  96. \end{table}
  97. \section{Basic Functionality}
  98. In this section, various examples are given of the fundamental building blocks used in a thesis.
  99. Many \LaTeX\ commands have a rich set of options that can be supplied as optional arguments.
  100. The documentation of each command should be consulted to get an impression of the full spectrum of its functionality.
  101. \subsection{Floats}
  102. Two main categories of page elements can be differentiated in the usual \LaTeX\ workflow: \textit{(i)} the main stream of text and \textit{(ii)} floating containers that are positioned at convenient positions throughout the document.
  103. In most cases, tables, plots, and images are put into such containers since they are usually positioned at the top or bottom of pages.
  104. These are realized by the two environments \verb|figure| and \verb|table|, which also provide functionality for cross-referencing (see Table~\ref{tab:intro} and Figure~\ref{fig:intro}) and the generation of corresponding entries in the list of figures and the list of tables.
  105. Note that these environments solely act as containers and can be assigned arbitrary content.
  106. \subsection{Tables}
  107. A table in \LaTeX\ is created by using a \verb|tabular| environment or any of its extensions, e.g., \verb|tabularx|.
  108. The commands \verb|\multirow| and \verb|\multicolumn| allow table elements to span multiple rows and columns.
  109. \begin{table}[h] % placement specifier
  110. \centering
  111. \begin{tabular}{lll}
  112. \toprule
  113. \multicolumn{2}{c}{Position} \\
  114. \cmidrule{1-2} % partial horizontal rule
  115. Group & Abbrev & Name \\
  116. \midrule
  117. Goalkeeper & GK & Paul Robinson \\
  118. \midrule
  119. \multirow{4}{*}{Defenders} & LB & Lucus Radebe \\
  120. & DC & Michael Duburry \\
  121. & DC & Dominic Matteo \\
  122. & RB & Didier Domi \\
  123. \midrule
  124. \multirow{3}{*}{Midfielders} & MC & David Batty \\
  125. & MC & Eirik Bakke \\
  126. & MC & Jody Morris \\
  127. \midrule
  128. Forward & FW & Jamie McMaster \\
  129. \midrule
  130. \multirow{2}{*}{Strikers} & ST & Alan Smith \\
  131. & ST & Mark Viduka \\
  132. \bottomrule
  133. \end{tabular}
  134. \caption{Adapted example from the \LaTeX guide at \url{https://en.wikibooks.org/wiki/LaTeX/Tables}. This example uses rules specific to the \texttt{booktabs} package and employs the multi-row functionality of the \texttt{multirow} package.}
  135. \label{tab:intro} % \label has to be placed AFTER \caption to produce correct cross-references.
  136. \end{table}
  137. \subsection{Images}
  138. An image is added to a document via the \verb|\includegraphics| command as shown in Figure~\ref{fig:intro}.
  139. The \verb|\subcaption| command can be used to reference subfigures, such as Figure~\ref{fig:intro:full width} and~\ref{fig:intro:half width}.
  140. \begin{figure}[h]
  141. \centering
  142. \begin{subfigure}[b]{0.45\columnwidth}
  143. \centering
  144. \includegraphics[width=\textwidth]{Logo-schwarz.pdf}
  145. \subcaption{The header logo at text width.}
  146. \label{fig:intro:full width}
  147. \end{subfigure}
  148. \begin{subfigure}[b]{0.45\columnwidth}
  149. \centering
  150. \includegraphics[width=0.5\textwidth]{Logo-schwarz.pdf}
  151. \subcaption{The header logo at half the text width.}
  152. \label{fig:intro:half width}
  153. \end{subfigure}
  154. \caption[Optional caption for the figure list (often used to abbreviate long captions)]{The header logo at different sizes.} % Remove the [...] argument if the original caption should be used in the figure list.
  155. \label{fig:intro} % \label has to be placed AFTER \caption (or \subcaption) to produce correct cross-references.
  156. \end{figure}
  157. \subsection{Mathematical Expressions}
  158. One of the original motivation to create the \TeX\ system was the need for mathematical typesetting.
  159. To this day, \LaTeX\ is the preferred system to write math-heavy documents and a wide variety of functions aids the author in this task.
  160. A mathematical expression can be inserted inline as $\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$ outside of the text stream as \[ \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} \] or as numbered equation with
  161. \begin{equation}
  162. \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}.
  163. \end{equation}
  164. \subsection{Pseudo Code}
  165. The presentation of algorithms can be achieved with various packages; the most popular are \verb|algorithmic|, \verb|algorithm2e|, \verb|algorithmicx|, or \verb|algpseudocode|.
  166. An overview is given at \url{https://tex.stackexchange.com/questions/229355}.
  167. An example of the use of the \verb|alogrithm2e| package is given with Algorithm~\ref{alg:gauss-seidel}.
  168. \begin{algorithm}
  169. \SetKw{BreakFor}{break for}
  170. \KwIn{A scalar~$\epsilon$, a matrix $\mathbf{A} = (a_{ij})$, a vector $\vec{b}$, and an initial vector $\vec{x}^{(0)}$}
  171. \KwOut{$\vec{x}^{(n)}$ with $\mathbf{A} \vec{x}^{(n)} \approx \vec{b}$}
  172. \For{$k\leftarrow 1$ \KwTo maximum iterations}
  173. {
  174. \For{$i\leftarrow 1$ \KwTo $n$}
  175. {
  176. $x_i^{(k)} = \frac{1}{a_{ii}} \left(b_i-\sum_{j<i} a_{ij} x_j^{(k)} - \sum_{j>i} a_{ij} x_j^{(k-1)} \right)$\;
  177. }
  178. \If{$\lvert\vec{x}^{(k)}-\vec{x}^{(k-1)}\rvert < \epsilon$}
  179. {\BreakFor\;}
  180. }
  181. \Return{$\vec{x}^{(k)}$\;}
  182. \caption{Gauss-Seidel}
  183. \label{alg:gauss-seidel} % \label has to be placed AFTER \caption to produce correct cross-references.
  184. \end{algorithm}
  185. \section{Bibliography}
  186. The referencing of prior work is a fundamental requirement of academic writing and well supported by \LaTeX.
  187. The \textsc{Bib}\TeX\ reference management software is the most commonly used system for this purpose.
  188. Using the \verb|\cite| command, it is possible to reference entries in a \verb|.bib| file out of the text stream, e.g., as~\cite{Turing1936}.
  189. The generation of the formatted bibliography needs a separate execution of \verb|bibtex.exe| (see Table~\ref{tab:compile}).
  190. \section{Table of Contents}
  191. The table of contents is automatically built by successive runs of the compilation, e.g., of \verb|pdflatex.exe|.
  192. The command \verb|\setsecnumdepth| allows the specification of the depth of the table of contents and additional entries can be added to the table of contents using \verb|\addcontentsline|.
  193. The starred versions of the sectioning commands, i.e., \verb|\chapter*|, \verb|\section*|, etc., remove the corresponding entry from the table of contents.
  194. \section{Acronyms / Glossary / Index}
  195. The list of acronyms, the glossary, and the index need to be built with a separate execution of \verb|makeindex| (see Table~\ref{tab:compile}).
  196. Acronyms have to be specified with \verb|\newacronym| while glossary entries use \verb|\newglossaryentry|.
  197. Both are then used in the document content with one of the variants of \verb|\gls|, such as \verb|\Gls|, \verb|\glspl|, or \verb|\Glspl|.
  198. Index items are simply generated by placing \verb|\index|\marg{entry} next to all the words that correspond to the index entry \meta{entry}.
  199. Note that many enhancements exist for these functionalities and the documentation of the \verb|makeindex| and the \verb|glossaries| packages should be consulted.
  200. \section{Tips}
  201. Since \TeX\ and its successors do not employ a \gls{wysiwyg} editing scheme, several guidelines improve the readability of the source content:
  202. \begin{itemize}
  203. \item Each sentence in the source text should start with a new line.
  204. This helps not only the user navigation through the text, but also enables revision control systems (e.g. \gls{svn}, Git) to show the exact changes authored by different users.
  205. Paragraphs are separated by one (or more) empty lines.
  206. \item Environments, which are defined by a matching pair of \verb|\begin{name}| and \verb|\end{name}|, can be indented by whitespace to show their hierarchical structure.
  207. \item In most cases, the explicit use of whitespace (e.g. by adding \verb|\hspace{4em}| or \verb|\vspace{1.5cm}|) violates typographic guidelines and rules.
  208. Explicit formatting should only be employed as a last resort and, most likely, better ways to achieve the desired layout can be found by a quick web search.
  209. \item The use of bold or italic text is generally not supported by typographic considerations and the semantically meaningful \verb|\emph{|\texttt{$\dots$}\verb|}| should be used.
  210. \end{itemize}
  211. The predominant application of the \LaTeX\ system is the generation of \gls{pdf} files via the \textsc{Pdf}\LaTeX\ binaries.
  212. In the current version of \textsc{Pdf}\LaTeX, it is possible that absolute file paths and user account names are embedded in the final \gls{pdf} document.
  213. While this poses only a minor security issue for all documents, it is highly problematic for double blind reviews.
  214. The process shown in Table~\ref{tab:ps2pdf} can be employed to strip all private information from the final \gls{pdf} document.
  215. \begin{table}[h]
  216. \centering
  217. \begin{tabular}{rl}
  218. \toprule
  219. & Command \\
  220. \midrule
  221. 1 & Rename the \gls{pdf} document \verb|final.pdf| to \verb|final.ps|. \\
  222. 2 & Execute the following command: \\
  223. & \verb|ps2pdf -dPDFSETTINGS#/prepress ^| \\
  224. & \verb| -dCompatibilityLevel#1.4 ^| \\
  225. & \verb| -dAutoFilterColorImages#false ^| \\
  226. & \verb| -dAutoFilterGrayImages#false ^| \\
  227. & \verb| -dColorImageFilter#/FlateEncode ^| \\
  228. & \verb| -dGrayImageFilter#/FlateEncode ^| \\
  229. & \verb| -dMonoImageFilter#/FlateEncode ^| \\
  230. & \verb| -dDownsampleColorImages#false ^| \\
  231. & \verb| -dDownsampleGrayImages#false ^| \\
  232. & \verb| final.ps final.pdf| \\
  233. \bottomrule
  234. \end{tabular}
  235. On Unix-based systems, replace \verb|#| with \verb|=| and \verb|^| with \verb|\|.
  236. \caption{Anonymization of \gls{pdf} documents.}
  237. \label{tab:ps2pdf}
  238. \end{table}
  239. \section{Resources}
  240. \subsection{Useful Links}
  241. In the following, a listing of useful web resources is given.
  242. \begin{description}
  243. \item[\url{https://en.wikibooks.org/wiki/LaTeX}] An extensive wiki-based guide to \LaTeX.
  244. \item[\url{http://www.tex.ac.uk/faq}] A (huge) set of \gls{faq} about \TeX\ and \LaTeX.
  245. \item[\url{https://tex.stackexchange.com/}] The definitive user forum for non-trivial \LaTeX-related questions and answers.
  246. \end{description}
  247. \subsection[Comprehensive TeX Archive Network]{\gls{ctan}}
  248. The \gls{ctan} is the official repository for all \TeX\ related material.
  249. It can be accessed via \url{https://www.ctan.org/} and hosts (among other things) a huge variety of packages that provide extended functionality for \TeX\ and its successors.
  250. Note that most packages contain \gls{pdf} documentation that can be directly accessed via \gls{ctan}.
  251. In the following, a short, non-exhaustive list of relevant \gls{ctan}-hosted packages is given together with their relative path.
  252. \begin{description}[itemsep=0ex]
  253. \item[\href{https://www.ctan.org/pkg/algorithm2e}{algorithm2e}] Functionality for writing pseudo code.
  254. \item[\href{https://www.ctan.org/pkg/amsmath}{amsmath}] Enhanced functionality for typesetting mathematical expressions.
  255. \item[\href{https://www.ctan.org/pkg/amsfonts}{amssymb}] Provides a multitude of mathematical symbols.
  256. \item[\href{https://www.ctan.org/pkg/booktabs}{booktabs}] Improved typesetting of tables.
  257. \item[\href{https://www.ctan.org/pkg/enumitem}{enumitem}] Control over the layout of lists (\verb|itemize|, \verb|enumerate|, \verb|description|).
  258. \item[\href{https://www.ctan.org/pkg/fontenc}{fontenc}] Determines font encoding of the output.
  259. \item[\href{https://www.ctan.org/pkg/glossaries}{glossaries}] Create glossaries and list of acronyms.
  260. \item[\href{https://www.ctan.org/pkg/graphicx}{graphicx}] Insert images into the document.
  261. \item[\href{https://www.ctan.org/pkg/inputenc}{inputenc}] Determines encoding of the input.
  262. \item[\href{https://www.ctan.org/pkg/l2tabu}{l2tabu}] A description of bad practices when using \LaTeX.
  263. \item[\href{https://www.ctan.org/pkg/mathtools}{mathtools}] Further extension of mathematical typesetting.
  264. \item[\href{https://www.ctan.org/pkg/memoir}{memoir}] The document class on upon which the \verb|vutinfth| document class is based.
  265. \item[\href{https://www.ctan.org/pkg/multirow}{multirow}] Allows table elements to span several rows.
  266. \item[\href{https://www.ctan.org/pkg/pgfplots}{pgfplots}] Function plot drawings.
  267. \item[\href{https://www.ctan.org/pkg/pgf}{pgf/TikZ}] Creating graphics inside \LaTeX\ documents.
  268. \item[\href{https://www.ctan.org/pkg/subcaption}{subcaption}] Allows the use of subfigures and enables their referencing.
  269. \item[\href{https://www.ctan.org/tex-archive/info/symbols/comprehensive/}{symbols/comprehensive}] A listing of around 5000 symbols that can be used with \LaTeX.
  270. \item[\href{https://www.ctan.org/pkg/voss-mathmode}{voss-mathmode}] A comprehensive overview of typesetting mathematics in \LaTeX.
  271. \item[\href{https://www.ctan.org/pkg/xcolor}{xcolor}] Allows the definition and use of colors.
  272. \end{description}