Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

AN INTRODUCTION TO LATEX

WORKSHOP 1: BASIC PRINCIPLES


AN INTRODUCTION TO LATEX
CONTACT INFORMATION

Patrick Zieverink
p.m.zieverink@student.utwente.nl
Merit Fernhout
m.m.fernhout@student.utwente.nl
Ashutosh Dilip
ashutoshdilip@student.utwente.nl
Toma Yamashita
t.yamashita@student.utwente.nl
Ilse van der Veen
i.t.vanderveen@student.utwente.nl

2
WHAT IS LATEX?

• LaTeX is a typesetting language, not a program

• Professional, universal programming language


for creating reports, presentations etc..

• Compare with the Office package:


Word/Powerpoint

3
ADVANTAGES OF LATEX
LATEX VS. WORD

• LaTeX is open source

• Well established in academia

• Very useful for creating equations and


maintaining references

• LaTeX automatically creates page layouts


based on predefined styles to generate a
good-looking document

4
Overleaf

• Overleaf is an online Latex editor

• No installation is needed

• Multiple people can work on one document

5
GETTING TO WORK WITH LATEX
COMMANDS AND TEXT

• The \ sign is used for passing commands to the


compiling program

• Commands are used for executing actions, like


placing figures. Text can be input in the code
without commands.

• All input between { } has to be supplied when


inserting commands. Everything between [ ] is
optional.

6
GETTING TO WORK WITH LATEX
DOCUMENT STRUCTURE

← Content of the document gets here

← Every beginning has an end

Output:

7
GETTING TO WORK WITH LATEX
TEXT LAYOUT

• Sections and subsections are defined by commands

\section{…} ← First heading (hoofdstuk)


\subsection{…} ← Sub heading (paragraaf)
\subsubsection{…} ← Sub sub heading (subparagraaf)

• All headings will be automatically numbered


• Numbering can be turned of using an *, for example:

\section*{…}

8
GETTING TO WORK WITH LATEX
TEXT LAYOUT

Output:

9
GETTING TO WORK WITH LATEX
TEXT LAYOUT

• Also for defining font styles, commands are required

\textbf{…} ← bold
\textit{…} ← italic
\underline{…} ← underlined

10
GETTING TO WORK WITH LATEX
TEXT LAYOUT

Output:

11
ASSIGNMENT 1
TEXT LAYOUT AND FONT STYLES

Download the file “Assignment 1.pdf” from Canvas. Recreate this text
in LaTeX (copy-paste the sentences) and add the correct formatting.

Challenge How can you create spacing between lines?


What happens to indentation?

Try using:
- Normal white lines in the code (press enter)
- \newline
- \\

If you are done with Assignment 1, continue to Assignment 2 or 3.


12
FLOATING OBJECTS
FIGURES

• Figures (and tables) can be somewhat less intuitive

• Various commands are required, as there are many options

• Advantage: figures will not jump throughout your document randomly,


as sometimes may happen in Word.

• Advantage: LaTeX finds the best fitting location in your document.

13
FLOATING OBJECTS
FIGURES: PACKAGE “GRAPHICX”

• Packages contain specific code required for executing more complex


tasks, such as inserting figures.

\usepackage{graphicx} ← This command loads the package “graphicx” which is


required for inserting figures

← Packages are loaded before\begin{document}


and after \documentclass
← Figures can now be inserted in the
document environment using code

14
FLOATING OBJECTS
FIGURES

• Figures also use a begin-end structure

\begin{figure}[placement specifier]
\includegraphics[dimension]{picture name}
Additional data (to be discussed later)
\end{figure}

Placement specifiers: Dimension specifiers:


[h] here [scale = …] scales the original image
[t] top size by a factor
[b] bottom
[p] new page [width = …\textwidth] scales the image width to
[H] HERE a fraction of the page width
[*!] override
15
FLOATING OBJECTS
FIGURES: EXAMPLE

← Start and END a figure environment


← Load a figure from the folder containing the .tex
file

Output:

16
FLOATING OBJECTS
TABLES

• Tables are placed similarly to figures


\begin{table} [placement specifier]
\begin{tabular}{table formatting}
Table content
\end{tabular}
Additional data (to be discussed later)
\end{table}
Table formatting:
c centered column
l left aligned column
r right aligned column
| vertical line between columns
17
FLOATING OBJECTS
TABLES: EXAMPLE

Output:

18
FLOATING OBJECT
REFERENCES TO FLOATING OBJECTS

• One of LaTeX’ biggest advantages is automatic numbering of figures/


tables and adding consistent references
• Adding them requires two commands:
\caption{This is the caption of the object}
\label{this is the label name required to refer to the object}

• Within the document, you can refer to the object number by using the
label name:

\ref{put the label name here}

19
FLOATING OBJECTS
REFERENCES TO FLOATING OBJECTS

Output:

20
ITEMIZATIONS
ITEMIZE

• Itemizations are simply implemented using the itemize


command

\begin{itemize}
\item Text for first item here
\item Text for second item here
\end{itemize}

• Overleaf uses a black dot (●) as the itemization symbol


of preference. This is customizable using:

\item[Preferred text or symbol]


21
ITEMIZATIONS
ITEMIZE

Output:

22
ITEMIZATIONS
ENUMERATE

• Enumerate numbers your itemization, instead of using


symbols

• The structure is equal to the one used for an itemize


code

• Subitems can be added to your itemization. This can be


achieved by including a new itemize/enumerate within
the current itemization.
• note the similarities with a nested for-loop as used in MATLAB

23
ITEMIZATIONS
ENUMERATE

Output:

24
EQUATIONS
GENERAL

• For an equation it is required to create an equation-environment,


similar to Microsoft Word.

• Multiple environments can be chosen from, but the two most


common ones are:

$ Your equation $ ← for in-rule equations

\begin{equation}
Your equation ← for numbered equations
\end{equation} in between paragraphs

25
EQUATIONS
MATHEMATHICAL OPERATIONS

26
EQUATIONS
MATHEMATICAL AND GREEK SYMBOLS

• This is just a small selection of all possibilities


• Remember: Google is your friend!

27
EQUATIONS
EXAMPLE CARNOT EFFICIENCY

↖ Label to refer to your equation (not mandatory)

Output:

28
ASSIGNMENT 2&3

From Canvas: download the files for assignment 2&3.

Follow the instructions and good luck!

These assignments should be finished before the next session,


otherwise it will be impossible to completely recreate the given report.

29
NEXT TIME…

Next lecture

Themes that will be discussed::


- Bibliographies
- The next level: compiling a complete report
- Working together with group mates on parts of bigger files

If there are any suggestions for topics to discuss or elaborate on,


please let us know by sending an e-mail prior to the lecture!

30

You might also like