Latex Presentation
Latex Presentation
Latex Presentation
Robert Misior
May 5, 2006
Revised: Ben De Winkle
June 15, 2013
A Brief History of TeX
• Pronounced “Tech” because it’s supposed to be the
Greek letters Tau, Epsilon, and Chi.
• TeX is a typesetting program used to produce
documents. It has the same goal as Microsoft
Word, but the method to achieve the end document
is different.
• Word is a WYSIWYG (What You See Is What You
Get) system. This means that what you see on the
screen is approximately what prints out on paper
• TeX is a markup language, similar to HTML, where
the user enters the format for the document as
commands, as well as entering the text of the
document.
A Brief History of LaTeX
LaTeX Example.tex
WYSIWYG versus Markup
\documentclass[options]{class}
preamble { \usepackage[options]{class}
{
\begin{document}
body lines of text
\end{document}
\documentclass[options]{class}
• Strings
– \TeX, \LaTeX, \LaTeX2e display the formatted
text. For example \LaTeX shows
– \today displays the current date
Special Symbols
Symbols Code
\cdots
\ldots
\copyright
`` (two grave accents)
‘‘ (two single quotes)
-
--
---
$-$
\~n
$\sim$
$\,^{\circ}$
Common Body Typesetting Commands
• Line Breaks
– \\ or \newline – starts a new line but not a new
paragraph.
– \\* starts a new line but prohibits a page break at
that location.
– With \linebreak[n] and \nolinebreak[n] LaTeX tries
to position a line break (or not position one) that
looks good based on the value of n
• n can be an integer from 0-4; the higher the number
the stronger the recommendation to LaTeX to
perform the line break.
– In general, LaTeX tries to position new lines so that
the text is evenly spaced.
Common Body Typesetting Commands
• Page Breaks
– \newpage – starts a new page
– Similar to \linebreak[n], with \pagebreak[n] and
\nopagebreak[n] LaTeX tries to even out the
right border of the page based on the value of
n (0-4)
• \sloppy loosens LaTeX’s even positioning; \fussy
restores LaTeX back to it’s normal positioning
Hyphenation
• LaTeX automatically hyphenates words as
necessary to even out the right border.
• \hyphenation{wordlist} – this command goes in
the preamble; it allows the default hyphenating of
LaTeX to be overridden; the words given in
wordlist are hyphenated as specified by the \- in
the words; a lack of \- in a word tells LaTeX not to
hyphenate that word at all.
• In the body of the text, \- can also be used to
suggest where a hyphen should go.
Hyphenation cont…
PDF File:
Mathematical Expressions, cont…
• To insert numbered or multiline expressions, use
the following:
\begin{equation} numbered
expressions
\end{equation}
\begin{align}† numbered, multiline, can
expressions align equations using “&”
\end{align} symbol
\begin{align*}† unnumbered, multiline, can
expressions align equations using “&”
\end{align*} symbol
$\begin{array} an array or matrix
expressions
\end{array}$
• \mathnormal - default
• \mathit – math italic
• \boldmath…\unboldmath – math bold
• \mathbf – boldface
• \mathrm – roman
• \mathsl – slanted roman
• \mathtt – typewriter
• \mathcal – calligraphic (symbols)
• \mathbb – blackboard bold
Mathematical Font Examples
Code: PDF File:
Whitespace in Mathematical
Expressions
• \quad – inserts a blank space the size of the letter
“M”
• \qquad – inserts a blank space twice the size of
\quad
• \, - inserts a thin blank space
• \! – removes a thin blank space
Code: PDF File:
Mathematical Expression Syntax
• Prime:
– $n’$ –
• Superscripts and Subscripts:
– $a^b$ –
– $a_b$ –
– $a^{bc}$ –
– $a_{bc}$ –
– They can be nested as well, like $a_{b_c}$ –
• Fractions:
– $\frac{numerator}{denominator}$ – numerator and
denominator can be mathematical expressions
Mathematical Expression Syntax, cont…
• Square Roots:
– \sqrt[n]{expression}, where n is the degree of the root
• Large Delimiters:
– \left( expression \right), where ( and ) are the delimiters
(these could also be [ ], \{ \}, or | | also)
– \overline{expression} and \underline{expression} create
a line over or under an expression
• Text in an Expression:
– to insert text so its not in math italic, use \mbox{text}
Mathematical Expression Syntax Examples
Code:
PDF File:
Mathematical Expression Symbols:
Lowercase Greek
\prod \bigvee
\coprod \bigwedge
\int \bigodot
\oint \bigotimes
\bigcap \bigoplus
\bigcup \biguplus
Mathematical Expression Operators:
Relations
Display Code Display Code Display Code
\leq * \geq * \equiv *
\prec * \succ * \sim *
\preceq * \succeq * \simeq *
\ll \gg \asymp *
\subset * \supset * \approx *
\subseteq * \supseteq * \cong *
\sqsubseteq * \sqsupseteq * \bowtie
\in \ni \propto
\vdash \dashv \models
\smile \mid \doteq
\frown \parallel \perp
* Can be negated with a \not in front of the command; this
also works with \not<, \not>, and \not=
Mathematical Expression Operators:
Arrows
Display Code Display Code Display Code
\leftarrow \longleftarrow \uparrow *
\Leftarrow \Longleftarrow \Uparrow
\rightarrow \longrightarrow \downarrow *
\Rightarrow \Longrightarrow \Downarrow
\leftrightarrow \longleftrightarrow \updownarrow
\Leftrightarrow \Longleftrightarrow \Updownarrow
\mapsto \longmapsto \nearrow
\hookleftarrow \hookrightarrow \searrow
\leftharpoonup \rightharpoonup \swarrow
\leftharpoondown \rightharpoondown \nwarrow
\rightleftharpoons
Openings Closings
Display Code Display Code
[ \lbrack ] \rbrack
{ \lbrace } \rbrace
\lfloor \rfloor
\langle \rangle
\lciel \rciel
Functions in Mathematical Expressions
PDF File:
Environments
• List Environments:
– enumerate – creates enumerated lists
– itemize – creates simple bulleted lists
– description – format for terms and definitions
• Justification Environments:
– flushleft, center, flushright – justifies text like
the name implies
• abstract – special environment for adding
an abstract to a scientific publication
Listing Environment Examples
Code: PDF File:
Quotation Environments
PDF File:
minimal – Document class
The accents inside tabbing are created by using \a=, \a', \a`
tabbing
\begin{tabular}[pos]{cols}
Or
\begin{tabular*}{width}[pos]{cols}
\begin{tabular}{|l|c|c|r|} \hline
Type & Quality & Color & Price \\ \hline \hline
paper & med. & white &low\\
letter &good & brown & high\\
& & red & \\ \hline
\end{tabular}
tabular example1
\begin{figure}
\centering
\caption{$G_{(4,7)}(u)$}
\begin{tabular}{c c c c c }
& & & $a$ &$a$ \\
& & & $a$ &$a$ \\
& & $b$ & $\diamond$ & \\
& $b$ &$b$ & $b$ & \\
$a$& $\diamond$ & $b$ & & \\
& $\diamond$ & & & \\
\end{tabular}
\end{figure}
tabular example2
\begin{figure}[h]
\centering
\caption{Ordering of $w$}
\begin{tabular}{|c|c|l|l|c|c|} \hline
$k_{0}$ & $p_{0,k_{0}} $ & $v_{0,k_{0}} $ & $v'_{0,k_{0}} $ &
$p_{0,l_{0}}$ & $l_{0}$ \\ \hline
$5$ & & ${\diamond}cbba$ & ${\diamond}cbba$ & & $5$ \\
$4$ & & $a$ & $cbba$ & & $4$ \\
$3$ & & $a{\diamond}cbba$ & $bba$ & & $3$ \\
$2$ & & $ba$ & $ba$ & & $2$ \\
$1$ & & $bba$ & $a$ & & $1$ \\
$0$ & $1$ & $cbba$ & $a{\diamond}cbba$ & & $0$ \\ \hline
\end{tabular}
\end{figure}
tabular example3
Advanced options of tabular:
\begin{figure}[h]
\centering
\caption{Ordering of $w$}
\begin{tabular}{|c|c|l|l|c|@{\hspace{0.2in}}c|} \hline
$k_{0}$ & $p_{0,k_{0}} $ & $v_{0,k_{0}} $ & $v'_{0,k_{0}} $ & $p_{0,l_{0}}$ &
$l_{0}$ \\ \hline
$5$ & & ${\diamond}cbba$ & ${\diamond}cbba$ & & $5$ \\
$4$ & & $a$ & $cbba$ & & $4$ \\
$3$ & & $a{\diamond}cbba$ & $bba$ & & $3$ \\
$2$ & & $ba$ & $ba$ & & $2$ \\
$1$ & & $bba$ & $a$ & & $1$ \\
$0$ & $1$ & $cbba$ & $a{\diamond}cbba$ & & $0$ \\ \hline
\end{tabular}
\end{figure}
The @ parameter can be used to insert text or commands in every field of specified
column.
array example
\begin{figure}[h]
\centering
\caption{Ordering of $w$}
$
\begin{array}{|c|c|l|l|c|c|} \hline
k_{0} & p_{0,k_{0}} & v_{0,k_{0}} & v'_{0,k_{0}} & p_{0,l_{0}} & l_{0} \\ \hline
5 & & \diamond cbba & \diamond cbba & & 5 \\
4 & & a & cbba & & 4 \\
3 & & a{\diamond}cbba & bba & & 3 \\
2 & & ba & ba & & 2 \\
1 & & bba & a & & 1 \\
0 & 1 &cbba &a{\diamond}cbba & & 0 \\ \hline
\end{array}
$
\end{figure}
\begin{figure}[placement]
body of the figure
\caption{figure title}
\end{figure}
table
\begin{table}[placement]
body of the table
\caption{table title}
\end{table}
\begin{minipage}[pos]{width}
text
\end{minipage}
\begin{minipage}[b]{0.5\linewidth}
\setlength{\unitlength}{1mm}
\begin{picture}(50,40)
\put(30,30){\circle{30}}
\put(30,30){\circle*{5}}
\end{picture}\\
Drawing with LaTeX example circle.
\end{minipage}
Side-by-Side Figures
\begin{figure}
\centering
\includegraphics[angle=90,width=0.75\textwidth]{pic.eps}
\caption{A picture, included from pic.eps file.}
\end{figure}
Making graphics with LaTeX
\begin{figure}
\centering
\setlength{\unitlength}{5cm}
\begin{picture}(1,1)
\put(0,0){\vector(0,1){1}}
\put(0,0){\vector(1,1){1}}
\put(0,0){\vector(1,0){1}}
\end{picture}
\begin{caption}
Drawing with LaTeX example $f(x) = y$
\end{caption}
\end{figure}
Drawing circles using picture
\begin{figure}
\centering
\setlength{\unitlength}{1mm}
\begin{picture}(50,40)
\put(30,30){\circle{30}}
\put(30,30){\circle*{5}}
\end{picture}
\caption{Drawing with LaTeX example 3 circle.}
\end{figure}
Adding new commands
\newcommand{name}[num][opt]{def}
\documentclass{article}
\newcommand{\uncg}{University of North
Carolina at Greensboro}
\begin{document}
I’m a graduate student at the \uncg.
\end{document}
renewcommand & providecommand
\documentclass{article}
\renewcommand{\^} {{\diamond}}
\begin{document}
$u=abaab\^ ba$
\end{document}
Did that break ^ ? NO!
\documentclass{article}
\renewcommand{\^} {{\diamond}}
\begin{document}
$u=abaab\^ ba$ \\
$a^u$ and $u^\^$ \\
Still works !
\end{document}
DeclareMathOperator
• \DeclareMathOperator{\name1}{name2} will
create the new command \name1 which will
typeset the text “name2” like a mathematical
operator (like sin or lim)
• Requires amsmath package.
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\re}{Re}
\begin{document}
If $z = a + bi$, then $\re z = \re(a + bi) = a$.
\end{document}
Creating your own newenvironment
\newenvironment{name}[args][opt]{begdef}{enddef}
\renewenvironment{name}[args][opt]{begdef}{enddef}
name – the name of your environment.
args – optional the number of arguments.
opt – optional the number of arguments required that are listed
in args.
begdef The text substituted for every occurrence of
\begin{name}; a parameter of the form #n in begdef is
replaced by the text of the nth argument when this
substitution takes place.
enddef The text substituted for every occurrence of
\end{name}. It may not contain any argument parameters.
Creating your own package
\ProvidesPackage{name} command