Fakultät Informatik Institut für Software- und Multimediatechnik - Lehrstuhl für Softwaretechnologie Academic Skills in Computer Science (ASiCS) II) Text Processing with Latex II.1) Introduction to Latex 30.04.2015
Agenda • LaTeX – Language features and syntax • BibTeX – Bibliographies for LaTeX • LaTeX – Tools and compiler 30.04.2015 2
LITERATURE [1] Sascha Lüdecke: Einführung in LaTeX. http://www.meta-x.de/faq/LaTeX-Einfuehrung.html [2] Sascha Frank: LaTeX Umlaute. http://www.namsu.de/Extra/befehle/Umlaute.html [3] Manuela Jürgens, Thomas Feuerstack: LaTeX – Eine Einführung und ein bisschen mehr… http://www.fernuni-hagen.de/imperia/md/content/zmi_2010/a026_latex_einf.pdf [4] Manuela Jürgens: LaTeX – Fortgeschrittene Anwendungen. Oder: Neues von den Hobbits… http://www.fernuni-hagen.de/imperia/md/content/zmi_2010/a027_latex_fort.pdf 30.04.2015 3
LATEX Language Features and Syntax 30.04.2015 4
Origins • TeX (Tau Epsilon Chi) by Donald E. Knuth, 1978 • Open-Source solution for layout of print media • Including formulas and tables • Available for almost every OS • LaTeX : Frontend for TeX by Leslie Lamport in the 1980s • User responsible for logical document structure only • LaTeX code translated into TeX • Predefined layouts including font sizes, line distances etc. 30.04.2015 5
WYSIWYG? • LaTeX is not a WYSIWYG-Editor (What you see is what you get) • Philosophy : write Content , not Layout • But: many tools provide hot updates today • Quasi-WYSIWYG • Alternatively: WYSIWYM (What you see is what you mean)-Frontends such as Lyx • Advantages • Platform-independent No depedencies to system fonts Output is always the same • Generation of table of contents, bibliography, glossary , … • Output is print-ready (e.g., PDF) 30.04.2015 6
Why LaTeX? • Today LaTeX is the de-facto standard for publications in science (at least in computer science) • Submission of papers almost always as LaTeX files (e.g., Springer, ACM) • Proceedings layout and Styles often as LaTeX styles 30.04.2015 7
Compilation Process Doc.tex Doc.pdf LaTeX2PDF Compiler • Creation of table of contents, bibliography etc. requires up to three iterations for updating references ! 30.04.2015 8
LaTeX Syntax • Commands start with back slash (\) • Following parameters ([]) und content ({}) • Example: • \documentclass[ngerman]{article} 30.04.2015 9
Document Structure 1. Style • Document class (e.g., article, book, beamer (slides ), …) 2. Preamble • Metadata such as title, author • Package and library imports 3. Body • Real content, structured by chapters, sections, slides etc. 30.04.2015 10
Document Structure Style \documentclass{scrartcl} Package Imports: \title{My first Document} Packages exist for almost each Preamble \author{John Doe} requirement. They can be \usepackage[english]{babel} found and browsed here \begin{document} http://www.ctan.org/ \maketitle Body Hello World! Next paragraph. \end{document} [1] 30.04.2015 11
Sections \chapter{A Chapter} % only for scrbook not for scrartcl \section{A Section} \subsection{A Subsection} \subsubsection{Further below} \paragraph{And even further} 1. A Chapter 1.1 A Section Latex2Pdf Compiler 1.1.1 A Subsection Further below And even further 30.04.2015 12
Sections 1. Section \section{A Section} A Section not to be \section*{A Section not to Will also not appear in the numbered be numbered} table of contents. 2. Next Section \section{Next Section} LaTeX2PDF Compiler 30.04.2015 13
Table of Contents \tableofcontents Table of Contents 1. A Chapter .…………………. 1 Latex2Pdf Compiler 1.1 A Section ……………………… 3 1.1.1 A Subsection ………..…………………. 5 30.04.2015 14
Appendix 1. Section \section{A Section} \appendix A. Section in Appendix \section{Section in Appendix} LaTeX2PDF Compiler 30.04.2015 15
References \section{A Section} \label{section1} This is some text with a reference to Section \ref{section1}. 1.1 A Section Latex2Pdf Compiler This is some text with a reference to Section 1.1. 30.04.2015 16
The Tilde • A so-called protected white space • No linebreak allowed at this position. This is some text with a reference to Section \ref{section1}. This is some text with a reference to Section~\ref{section1}. 1.1 A Section This is some text with a reference to Section Latex2Pdf Compiler 1.1. This is some text with a reference to Section 1.1. 30.04.2015 17
References Besides numbers of figures, tables, sections , … you can also refer to page numbers : See figure~\ref{fig:test} on page~\pageref{fig:test}. LaTeX2PDF Compiler See figure 1.2 on page 8. 30.04.2015 18
Hyphenation • Based on automated algorithm • Can be itchy, especially for German compound words . Global rules (in preamble) \hyphenation{Sil-ben-tren-nung Al-go-rith-mus} Local rules Break at this position only \- Staats\-ver\-trag Additional break at this position "- Staats"-vertrag Only for German Additional hyphen "= Karl"=Franzensuniversität documents! Hyphen without break "~ (Haupt"~)Straße 30.04.2015 19
Hyphenation • Sometimes, hyphenation won‘t work at all: Overfull \hbox (305.0842pt too wide) in paragraph at lines 20--22 • Means that somewhere a word is longer than its current line: • % Marks overful lines with black bar. \setlength{\overfullrule}{4pt} 30.04.2015 20
Font Size \tiny \scriptsize \footnotesize \small \normalsize (standard) \large \Large \LARGE → You typically do not alter your \huge font size in points but using \Huge these relative sizes ! 30.04.2015 21
Font Formats \textrm{Roman} Roman Italics \textit{Italics} Bold \textbf{Bold} C APITALS \textsc{Capitals} \texttt{Typewriter} Typewriter Normal \textnormal{Normal} LaTeX2PDF Compiler 30.04.2015 22
Umlauts • Umlauts must be handled especially [2] 1. Markup in text • \ “a, \ “o, \ “u, \ “A, … → ä, ö, ü, Ä, … • \ss → ß 2. Easier solution: package import in preamble • \usepackage[utf8]{inputenc} 30.04.2015 23
Enumerations \begin{itemize} First \item First • Second \item Second • \end{itemize} \begin{enumerate} 1. First \item First 2. Second \item Second III. Third \item[III] Third \end{enumerate} LaTeX2PDF Compiler 30.04.2015 24
Figures \begin{figure}[h] % requires \usepackage{graphicx} \includegraphics[width=\textwidth] {bilder/bild1.pdf} \caption{Caption.} \label{bild1} \end{figure} Reference to Figure~\ref{bild1}. 30.04.2015 25
Figures \begin{figure}[h] \includegraphics[width=\textwidth] Typical formats: {pictures/bild1.pdf} PNG, PDF \caption{Caption.} \label{bild1} \end{figure} Reference to Figure~\ref{bild1}. 30.04.2015 26
Figures \begin{figure}[h] \includegraphics[width=\textwidth] Caption. Must be in front of {bilder/bild1.pdf} the label \caption{Caption.} (otherwhise the label \label{bild1} won‘t work)! \end{figure} Reference to Figure~\ref{bild1}. 30.04.2015 27
Width of figure (optional). Value in cm, px, em. Also use Figures of variables possible: \textwidth, \columnwidth \begin{figure}[h] \includegraphics[width=\textwidth] {bilder/bild1.pdf} \caption{Caption.} \label{bild1} \end{figure} Reference to Figure~\ref{bild1}. 30.04.2015 28
Figures Positioning of figure: h = Here (in text) t = Top (of page) \begin{figure}[h] b = Bottom (of page) \includegraphics[width=\textwidth] p = Page (separate page) {bilder/bild1.pdf} ! + position = force position \caption{Caption.} \label{bild1} \end{figure} Reference to Figure~\ref{bild1}. 30.04.2015 29
Tables \begin{table}[h] \begin{tabular} {|l|r} \hline Column 1 Column 2 Column 1 & Column 2 \\ a b \hline c d a & b \\ c & d \\ LaTeX2PDF Compiler \hline \end{tabular} \caption{Text} \label{table1} \end{table} 30.04.2015 30
Tables Positioning h = here in the text t = Top (of the page) \begin{table}[h] b = Bottom (of the page) \begin{tabular} {|l|r} p = Page (on separate page) \hline ! + position = force position Column 1 Column 2 Column 1 & Column 2 \\ a b \hline c d a & b \\ c & d \\ \hline \end{tabular} \caption{Text} \label{table1} \end{table} 30.04.2015 31
Tables Text Alignment: l = left \begin{table}[h] r = right \begin{tabular} {|l|r} c = centered \hline p{2cm} = justified with column Column 1 Column 2 Column 1 & Column 2 \\ width a b \hline c d a & b \\ c & d \\ \hline \end{tabular} \caption{Text} \label{table1} \end{table} 30.04.2015 32
Tables \begin{table}[h] Vertical lines \begin{tabular} {|l|r} \hline Column 1 Column 2 Column 1 & Column 2 \\ a b \hline c d a & b \\ c & d \\ \hline \end{tabular} \caption{Text} \label{table1} \end{table} 30.04.2015 33
Tables \begin{table}[h] \begin{tabular} {|l|r} \hline Column 1 Column 2 Column 1 & Column 2 \\ a b Horizontal Lines \hline c d a & b \\ c & d \\ \hline \end{tabular} \caption{Text} \label{table1} \end{table} 30.04.2015 34
Recommend
More recommend