0% found this document useful (0 votes)
69 views6 pages

LaTeX File Structure Overview

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views6 pages

LaTeX File Structure Overview

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Structure of a LaTeX File

LaTeX Commands:
 \<commandname>[<optional argument>]{<required argument>}
o Commands start with a backslash.
o There are commands that do not have any arguments.
(Some commands have multiple optional and/or required arguments, each
of them given in its own pair of brackets.)

o Commands are used to change the format of text, start new


sections, insert images, load LaTeX libraries, specify the document
layout and font, …
\documentclass[<options>] The special begin and end
{<class>} commands define environments: }
<document preamble>
\begin{document}
<document body>
\end{document}

 \documentclass command:
o Always the first command.
o Specifies the type of document you are working with
 Common documentclasses:
o article: For articles in scientific journals, presentations, short
reports, program documentation, etc.
o report: For longer reports of several chapters, small books,
theses.
o book
o letter
o beamer: For presentations
 <document preamble>:
o optional area, can be empty
o include additional packages
 Packages are LaTeX libraries that offer additional commands or
change the layout of your document
 A package is loaded into your document via the following command:
\usepackage[<optional arguments>]{<package name>}
 Compiling a Basic Latex Document
[Link] Contains information for following compilations
[Link]  Contains a log of the building process
 Shows errors and warnings
[Link] Resulting PDF file
[Link] Original tex file

 Compiling a Document with References


\documentclass{article}
\begin{document}
Add a section called „Cool Section“ in our
\section{Cool Section}
document
Set a label with the name „sec:cool“ which can
\label{sec:cool} be used to reference the previous item (here:
the section „Cool Section“)
Hello! This is “~” prints a space that does not allow for a line
Section~\ break
Add a reference to the item belonging to the
ref{sec:cool}.
label with name „sec:cool“, i.e., „Cool Section“.
\end{document}

 Compiling a Document with BiBTeX Citations


[Link] This file contains the literature that we
@book{s2011, want to cite, i.e., it is a bibliography
title={Erfolgreich database which contains format-
studieren}, independent information about our
sources.
author={Spoun, Sascha},
year={2011},
publisher={Pearson
Deutschland GmbH}
}

Structuring a Document
 Section: \section{<Section Name>}
 Subsection: \subsection{<Section Name>}
 Subsubsection: \subsubsection{<Section Name>}
 Paragraph: \paragraph{<Paragraph Name>}

\tableofcontents - Automatically adds a table of contents to the document

Formatting Content
 Formatting Text

\textbf{…} for bold text


\textit{…} for italic text
\emph{…} to highlight text
Exmpty line start a new
paragraph
\smallskip
add empty vertical
\medskip
space
\bigskip

 Lists: Itemize, Enumeration, Description

You can list items with the following environments:


o Itemize: Bullet point list (\begin{itemize})
o Enumerate: List with numeration
o Description: List without any extras

 Formulas and Equations


Recommended packages that provide many math related commands and
symbols: amsmath, amssymb, amstext, amsthm
 Inline equations: Enter and exit math mode with $
 Math environment
o \begin{math} and \end{math}
o Line break: \newline or \\
 Align and equation environments
o \begin{align} and \end{align}
o Line break: \newline or \\
o Every Line will be numbered and can be labeled
o Use align* instead of align to remove numeration
o Use “&” to align multiple lines at a certain point

Floats, Images, Tables, Algorithms


 Floats
Floating environments (floats) are containers for arbitrary content

\begin{figure}[htp] Optional: Specify a list of locations


that are considered for placement
o h: here
o t: top of page
o b: bottom of page
o p: separate page
o !: Lift some internal restrictions
on placement that might
otherwise prevent a certain
location
<arbitrary things inside the Optional command \caption: puts a
container> name and a description/text below the
\caption{This is text under the floating environment
figure}
\label{fig:myLabel} Optional: add a label for referencing
\end{figure} the floating environment. Must be
put after \caption

 Images

\documentclass{article} The package graphicx


\usepackage{graphicx} provides the \
\begin{document} includegraphics
command to load
images into your
document
\begin{figure}[h!] Use a float to
automatically place the
picture in a good
location and allow for
referencing it later
\centering Center the following
content of the float
\includegraphics[width=0.5\textwidth] File name/path of the
{[Link]} image
\caption{My very cool figure}
\label{fig:thumbsup}
\end{figure}
\end{document}

 Tables

\documentclass{article}
\begin{document}
\begin{table}[h!]
\centering
„tabular“ is the actual table
list of columns
\begin{tabular}{c|lr}  c/r/l: align column
center/right/left
 |: show line between columns
Color & Coolness Factor & Example \\: end of row
Item \\ \hline \hline Horizontal line between rows
Yellow & $314$ & Banana \\ \hline
Black & $-3$ & Night \\ \hline &: end of column within a row
Blue & $12$ & Ocean \\ \hline
\end{tabular}
\caption{My Fancy Color Table}
\label{tab:colors}
\end{table}
\end{document}

 Algorithms

The algpseudocode and listings packages provide environments for source


code and algorithms

\documentclass{article} i← 1 0
\ if i≥ 5 then
usepackage{algpseudoc i← i−1
ode} else
if i≤ 3 then
\begin{document} i← i+2
end if
\begin{figure} end if

\
begin{algorithmic
}
\State $i \gets
10$
\If{$i\geq 5$}
\State $i \gets i-
1$
\Else
\If{$i\leq 3$}
\State $i \gets
i+2$
\EndIf
\EndIf
\
end{algorithmic}

\end{figure}
\end{document}

 TIKZ

TIKZ is a library for drawing graphs, lists, trees, and many more

 LaTeX Presentations: Beamer

\documentclass{beamer} use beamer class for presentations


\begin{document}
\begin{frame} each frame environment creates
one slide
\frametitle{First Slide} /frametitle sets slide title
This is the first slide.
\end{frame}

\begin{frame}
\frametitle{Second Slide}
This is the second slide.
\end{frame}
\end{document}

You might also like