0% found this document useful (0 votes)
13 views36 pages

La Te Xcrash Course

Uploaded by

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

La Te Xcrash Course

Uploaded by

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

LaTeX Crash-Course

Absolute Beginner’s Guide to


LATEX Typesetting

Assoc. Prof. Dr.Ing.


Mohammed Ahmed
mnahmed@zu.edu.eg

28.02.2016

Zagazig University — Faculty of Engineering — Computer and Systems Dept.

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 1 / 36


Outline
What will we have today?

1 Introduction to LATEX
history, philosopy

2 Installation of Software and first steps

3 Generate your first document with LATEX

4 Common LaTeX commands


text, math, tables, graphics, BibTeX, ...

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 2 / 36


TEX
In 1978, Donald Knuth1 started creating the TEX typesetting
system.

I after being disappointed with the quality of his acclaimed “The


Art of Programming” series.
TEX is pronounced /tεx/ or /tεk/
I abbreviation of τ χνη (technē), Greek for both “art” and
“craft”2 ,
I it is also the root of the word: technical.
1
one of the most famous and well respected computer scientists
2
Donald E. Knuth, The TeXbook, Ch. 1: The Name of the Game, p. 1.
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 3 / 36
LATEX
In mid–80s, Leslie Lamport3 created a set of macros
I abstracted away many of the complexities
I allowed for a simpler approach for creating documents
I content and style were separate.

This extension became LATEX(pronounced ‘lay-tech’)


3
one of the most famous computer scientist, best known for his seminal work
in distributed systems
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 4 / 36
LATEX

6 =
LaTeX is not latex!

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 5 / 36


What is LaTeX?

LaTeX is a markup, programming language and typesetting


system for document preparation to generate high-quality
documents for press.

essentially a markup language


I analogous to HTML with CSS
Available for just about any computer system
I PC, UNIX, Windows, OsX, Linux, · · ·
Current version: LATEX2ε

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 6 / 36


Who is LaTeX for?

often used for medium-to-large technical, scientific, or


mathematically oriented documents
I can be used for almost any form of publishing
I handouts, reports, letters, theses, articles, books, etc.

widely used in academia.


I recently, as a web standard for displaying mathematics
I e.g., Wikipidia, MathJax, WordPress, Coursera, · · ·

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 7 / 36


Why LaTeX?

portability, lightness
saves time; you focus on content, LaTeX cares about the layout
I actual typesetting, structuring, numbering, referencing and
cross-referencing, indexing and page formatting
with many contributed packages and styles
compile documents in PDF (export to HTML, RTF)
almost all journals and conferences advice using it for
submission.
easier than word processors

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 8 / 36


LaTeX Vs Word

http://www.pinteric.com/miktex.html
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 9 / 36
Installation
MiKTeX
LaTeX typesetting system for Windows.
I comes with easy setup and maintenance program.
I includes all the tools you need (latest ver. 2.9).
get it from: http://www.miktex.org/2.9/setup

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 10 / 36


Installation
Editor

Any text editor will do (even Notepad)


Better, get a dedicated one:
I TeXnicCenter (de facto standard for Windows users)
http://www.texniccenter.org/download
I TeXstudio (my choice) http://texstudio.sourceforge.net
I WinEdt (widely used, not free)
http://www.winedt.com/download.html
I Notepad++ (excellent general purpose text editor)
https://notepad-plus-plus.org

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 11 / 36


Installation
Editor – TEXnicCenter

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 12 / 36


First Document with LaTeX
Skeleton of a Document

1 \ documentclass [ ]{ } 1 \
2 \ usepackage { } 2 \
3 3
4 %b a s i c i n f o 4 %
5 \title{ } 5 \
6 \ author { } 6 \
7 \ date { } 7 \
8 8
9 %s t a r t o f doc 9 %
10 \ b e g i n { document } 10 \
11 \ maketitle 11
12 \ tableofcontents 12
13 \listoffigures 13
14 \listoftables 14
15 15
16 Write s t u f f here 16
17 17
18 \ appendix 18
19 19
20 \ bibliographystyle { ieee } 20
21 \ b i b l i o g r a p h y { myRefFile } 21
22 \ end { document } %h e r i s t h e end 22 \
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 13 / 36
First Document with LaTeX Example
1 \ documentclass { a r t i c l e }
2
3 \ t i t l e { H e l l o , C r u e l World ! }
4 \ a u t h o r { O b e d i e n t Grad S t u d e n t }
5
6 \ b e g i n { document }
7 \ maketitle
8
9 \ section { Introduction }
10 T h i s i s w h e r e you t e l l p e o p l e why t h e y s h o u l d b o t h e r r e a d i n g y o u r
article .
11
12 \ s u b s e c t i o n { L i t e r a t u r e Review }
13 T h i s i s t h e s e c t i o n t h a t i s i n v a r i a b l y much l o n g e r t h a n i t s h o u l d
be , and
14 w h e r e e v e r y o n e t r i e s t o i m p r e s s p e e r s a b o u t how e a s y i t i s t o
locate various
15 references in online databases .
16
17 \ subsubsection { Conclusion }
18 Not much o f a p a p e r , b u t i t ’ s a s t a r t .
19 \ end { document }

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 14 / 36


First Document with LATEX
How to get an output

LATEX is just text with typesetting commands.


I commands are preceded by \
I arguments (if any) are usually placed inside curly braces {} .
text in adjacent lines are considered part of the same paragraph.
to start a new line, add \\ to the end of previous line for new
paragraph, insert an extra ←-
many document classes
I article, IEEEtran, proc, report, book, memoir, letter, beamer, ...

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 15 / 36


First Document with LaTeX
How to generate output

Hello, Cruel World!


Obedient Grad Student
February 28, 2016

Contents
1 Introduction 1

1 Save file as “ .tex” 2 Literature Review

1
2.0.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Introduction
1
1

This is where you tell people why they should bother reading your article.

2 Compile code by typing “pdflatex 2 Literature Review


This is the section that is invariably much longer than it should be, and where everyone tries to impress peers about how easy it is to

abc.tex”
locate various references in online databases.

2.0.1 Conclusion
Not much of a paper, but it’s a start.

3 See the output using any pdf viewer This is a line of text. This is more text.
Here comes a new line.
But this is a new paragraph.

(e.g. Acrobat Reader)


with all LaTeX editors, every thing
can be done with a click of a button

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 16 / 36


Basic Commands
Document Structure4

Command Level Comment


\part{Part Title} -1 not in letters

\chapter{Chapter Title} 0 only books and rep

\section{section Title} 1 not in letters


\subsection{Subsectionv Title} 2 not in letters
\subsubsection{Subsubsection Title} 3 not in letters
\paragraph{Paragraph Title} 4 not in letters
\subparagraph{Subparagraph Title} 5 not in letters

4
https://en.wikibooks.org/wiki/LaTeX/Document_Structure
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 17 / 36
Text Commands
Font Styles
Use \textbf{stuff} to make stuff bold
Use \emph{stuff} to italicize stuff
Use \underline{stuff} to underline stuff

Font Sizes
\tiny \scriptsize \footnotesize \small \normalsize
\large \Large \LARGE \huge \Huge

Example
\scriptsize{text goes here} gives: text goes here

These are the different sizes available in order: tiny scriptsize footnotesize
small normalsize large Large LARGE huge Huge
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 18 / 36
Lists

There are many ways to make lists. A few of them are: enumerate,
itemize, description, list
Example
\begin{itemize}
\item here here
\item is is
\item something something
\end{itemize}

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 19 / 36


Lists

There are many ways to make lists. A few of them are: enumerate,
itemize, description, list
Example
\begin{enumerate}
\item here 1 here
\item is 2 is
\item something 3 something
\end{enumerate}

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 20 / 36


Mathematics
The beauty of it!

in LaTeX there are two modes:Text Mode and Math Mode


for Math Mode, we have inline and display
in inline math, mathematical expression is within normal text.
To do math on a line of text, put the mathematical expression
bwtween $’s.

Example

$\int^b_a\frac{k^2_m}{\beta f(x)}dx \in \mathcal{N}$


R b m2
produces a βfk(x) dx ∈ N

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 21 / 36


Mathematics
Math Display

Many environments for this: equation, align, · · ·

Example

\begin{equation}
a_0 = \frac{1}{\pi} \int \limits_{-\pi}^{\pi} f(x)
x^2 \cos(nx) \, dx
\end{equation}


1
a0 = f (x)x 2 cos(nx) dx (1)
π
−π

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 22 / 36


Mathematics
Math Display

Many environments for this: equation, align, · · ·

Example

\begin{align}
a_0 &= f(x) \quad \forall x \in X,\\
y &= \cos(nx)+\phi \quad \exists y \leq \epsilon
\end{align}

a0 = f (x) ∀x ∈ X , (2)
y = cos(nx) + φ ∃y ≤  (3)

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 23 / 36


Mathematics
You can go as fancy as yo imagine

m complex number
e x − 1 [ ba ] X e x z }| {
lim = = |{z}
x +i y , ∀x ∈ R, ∃y ≤ 
x→0 2x H
x→0
2 |{z}
real imaginary
 
1 X12 X13
 1 X22 X23 
 
1  . 
min x = a0 + + 
β̂∈R 1  . 
a1 +
 
1
 . 
a2 + 1 XT 2 XT 3
1
a3 +
a4

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 24 / 36


Tables

to typeset tables with optional horizontal and vertical lines:

\begin{tabular}[pos]{column specs}
element & element & ... \\ \hline
\end{tabular}

column specs takes (any): l, c, r, p{ }, |


pos : b, c, t
cells are separated by &
\hline is used to draw lines between rows.

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 25 / 36


Tables
Example

\begin{tabular}{ | l || c ||| r }
\hline
\textbf{a} & \textbf{b} & \textbf{c}\\
\hline a b c
1 & 2 & 3 \\ 1 2 3
4 & 5 & 6 \\ 4 5 6
\hline
\hline 7 8 9
7 & 8 & 9 \\
\hline
\end{tabular}

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 26 / 36


Graphics

many different ways to include graphics in LATEX.


I There is literally an entire manual of just graphics.
the most common (and easiest) way to include graphics:
\includegraphics[options]{/path/to/image/picName}

\usepackage{graphicx} must be loaded (in the preamble) for


\includegraphics to work.
supported image types: .pdf, .png, .jpg, (.eps)
options: width , height , scale , angle , page ,
resolution , trim , clip , keepaspectratio

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 27 / 36


Graphics
Example
\includegraphics[width=0.8\linewidth]{figures/scExp182}

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 28 / 36


Graphics
Example
\includegraphics[angle=30,width=0.5\linewidth]
{figures/scExp182}

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 29 / 36


Floats

Floats are containers for things in a document that cannot be


broken over a page.
separate entities (e.g. figures and tables), positioned in a part of
page
enable captions, and cross-reference

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 30 / 36


Floats
Figure

\begin{figure}[placementSpecifier]
\includegraphics[...]{...}
\caption{text}
\label{key}
\end{figure}

placementSpecifier is a combination of: h, t, b, p, !


label key is (unique) text used when referencing this figure.
item¡4-¿ The same can be applied for tables

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 31 / 36


Floats
Figure Example
\begin{figure}[placementSpecifier]
\includegraphics[width=0.2\linewidth]{figures/zuLogo}
\caption{This is our university logo.}
\label{fig:zuLogo}
\end{figure}

Figure: This is our university logo.

Now in text you can reference this figure using \ref{fig:zuLogo} ,


as shown in Fig.1
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 32 / 36
Floats
Table Example
\begin{table}
\begin{tabular}{l|c||r}
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
\end{tabular}
\caption{The same logic can be applied to tables.}
\label{tbl:test}
\end{table}

1 2 3
4 5 6
Table: The same logic can be applied to tables.

you can reference this table using


Mohammed Ahmed (Assoc. Prof. Dr.Ing.) \ref{tbl:test} ,
LATEX Crash–Course 28.02.2016 33 / 36
Floats
Table Example

1 2 3
4 5 6
Table: The same logic can be applied to tables.

you can reference this table using \ref{tbl:test} ,


As shown in Table.2 (note: I still remember Fig.1)

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 34 / 36


Additional Resources

I highly recommend you to have the free Tobias Ötiker’s, Not


So Short Introduction to LaTeX. www.ctan.org/
tex-archive/info/lshort/english/lshort.pdf.
If you are going to use LaTeX seriously, you will want to get a
book. The LaTeX Companion and the Guide to LaTeX are
standards.
Wikipedia has very useful guide (Wikibook) to LaTeX with very
easy to follow instructions and many examples.
https://en.wikibooks.org/wiki/LaTeX
And if you have any other questions, ask me:
mnahmed@zu.edu.eg

Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 35 / 36


Thanks ...
Questions?
Assoc. Prof. Dr.Ing.
Mohammed Ahmed
mnahmed@zu.edu.eg
Zagazig University — Faculty of Engineering — Computer and Systems Dept.

5
5
Copyright c 2016 Dr.Ing. Mohammed Nour Abdelgwad Ahmed as part of his course work and teaching material. All
Rights Reserved. Where otherwise noted, this work is licensed under the Creative Commons Attribution-NonCommercial 4.0
International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/
Mohammed Ahmed (Assoc. Prof. Dr.Ing.) LATEX Crash–Course 28.02.2016 36 / 36

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy