LaTeX Workshop

fhLUG

Linux User Group FH Hagenberg

Poincaré diagrams

Agenda

Reasons for LaTeX

A rendered LaTeX document

Reasons for WYSIWYG

History

  • Donald E. Knuth unsatisfied with typesetting of his book
  • Starts working on TeX in 1977
  • Takes him 10 years to finish
  • Version number approaches π (current release: 3.14159265, January 2014)
  • Knuth wishes the version to be set to π after his death
Donald Knuth at a reception for the Open Content Alliance

History

  • Leslie Lamport starts writing lots of macros for the TeX system
  • Names it LaTeX (Lamport-TeX)
  • Current version LaTeX 2ε Issue 32 (Oktober 2020)
Leslie Lamport

Installing LaTeX

root@kn:/# apt install texlive

Try it online

Document structure

\documentclass[10pt,a4paper]{scrartcl}

\usepackage[naustrian]{babel}
\usepackage[utf8]{inputenc}

\begin{document}
\tableofcontents

Here comes the document's content.

This is a second paragraph.
\end{document}

Compiling to PDF

fhlug@kn:~$ pdflatex filename

Proper punctuation

``English `quotation' marks.'' (“English ‘quotation’ marks.”)

"`Mit \glq naustrian\grq{} sieht das so aus"'. („Mit ‚naustrian‘ sieht das so aus“.)

Simple markup

\section{Markup}
Short sentence with \emph{markup}.

\subsection{Emphasize}
\emph{Markup can \emph{also} be nested}.

Lists

\begin{enumerate}
	\item First item
\end{enumerate}

\begin{itemize}
	\item Bulleted item
\end{itemize}

\begin{description}
	\item[Term] Description
\end{description}

Including images

\usepackage{graphicx}
\DeclareGraphicsExtensions{.png,.gif,.jpg}

\includegraphics[width=\textwidth]{path/to/image}

Source code listings

\usepackage{listings}
\lstset{%
	basicstyle=\footnotesize,%
	showspaces=false,showstringspaces=true,%
	numbers=left,tabsize=2,breaklines,%
	keywordstyle=…,commentstyle=…,stringstyle=…,identifierstyle=…
}

\lstinputlisting[language=C++,caption={Source code included from file}]{path/to/file.cpp} \begin{lstlisting}[language=Java,caption={Source code in tex file}] String s = "Code can be marked up without including it from a file."; \end{lstlisting} Short source code snippets can even be inlined: \lstinline{++i;}

Tables

\begin{tabular}{l|ll}
header1 & header2  & header 3 \\
\hline
cell 1  & cell 2   & cell 3   \\
cell 4  & cell 5   & cell 6
\end{tabular}

Figures

\begin{figure}
	\centering
	\includegraphics{path/to/file}
	\caption{This is a sample figure}
	\label{fig:sample}
\end{figure}

\begin{table}
	\caption{This is a sample table}
	\label{tab:sample}
	\begin{tabular}{}
	% table content
	\end{tabular}
\end{table}

Cross-Referencing

\usepackage[colorlinks]{hyperref}

\begin{document} \renewcommand{\figureautorefname}{Abbildung} \renewcommand{\tableautorefname}{Tabelle} \label{fig:abc} See \autoref{fig:abc} for more information. \end{document}

List of *

\listoffigures
\listoftables
\lstlistoflistings

Bibliography management

@book{bibtexkey,
	title={LaTeX for dummies},
	author={First Author and Second Author},
	year={2012},
	publisher={O'Reilly}
}
\cite[displaytext]{bibtexkey}

\bibliographystyle{plain} \bibliography{bibfile}

Headers & footers

\usepackage{fancyhdr}

\fancyhf{} % clear default header style
\lhead{Daniel Knittl-Frank}
\rhead{Campus Hagenberg}
\cfoot{\thepage}
\pagestyle{fancy}
\usepackage[headsepline]{scrlayer-scrpage}

\clearpairofpagestyles
\ihead{Daniel Knittl-Frank}
\ohead{Campus Hagenberg}
\cfoot{\pagemark}

\renewcommand*\pagemark{{\usekomafont{pagenumber}\thepage}}
\addtokomafont{pageheadfoot}{\upshape}

Math formulas

\[
\sum_{i=1}^{n} = \frac{n}{2} (n+1) = \frac{n^2 + n}{2}
\]
$$\sum_{i=1}^{n} = \frac{n}{2} (n+1) = \frac{n^2 + n}{2}$$

More cool stuff

Rastrigin function plot