Upload
awv7t
View
5.729
Download
1
Tags:
Embed Size (px)
DESCRIPTION
This is the second part of a two part tutorial designed to introduce you to LaTeX and show you how to use it.
Citation preview
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
An Intro to Latex Part IIAn introduction to creating a Latex document
Aubry W. Verret
Brown Science and Engineering Library Research Computing Lab
November 11, 2008
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Outline INotes
FootnotesMarginal NotesEndnotes
Mathematics in LaTeXMath EnvironmentMath Symbols
TablesTable FeaturesHow to Create TablesExample of TableTable Resources
GraphicsGraphicx Package
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Outline IIAllowed FormatsIncludegraphics CommandGraphicx ExamplesIncluding Plots
FiguresIncluding and Formatting FiguresCaptionsExample of Figure
Making Presentations in LaTeXPackagesUsing BeamerCreating a SlideHyperlinksOverlays
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Outline IIIAcquiring Beamer
Resources
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Footnotes
You can include footnotes in your document by using the command
\footnote[number]{text}
The footnote is automatically placed at the bottom of the pageand is automatically given a number.
You can override the automatic numbering by using the optional[number] portion of the footnote command.Example:
\footnote[3]{This is the third footnote}
This command produces this footnote. 3
3This is the third footnote
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Footnotes
You can include footnotes in your document by using the command
\footnote[number]{text}
The footnote is automatically placed at the bottom of the pageand is automatically given a number.
You can override the automatic numbering by using the optional[number] portion of the footnote command.Example:
\footnote[3]{This is the third footnote}
This command produces this footnote. 3
3This is the third footnote
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Footnotes
You can include footnotes in your document by using the command
\footnote[number]{text}
The footnote is automatically placed at the bottom of the pageand is automatically given a number.
You can override the automatic numbering by using the optional[number] portion of the footnote command.
Example:
\footnote[3]{This is the third footnote}
This command produces this footnote. 3
3This is the third footnote
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Footnotes
You can include footnotes in your document by using the command
\footnote[number]{text}
The footnote is automatically placed at the bottom of the pageand is automatically given a number.
You can override the automatic numbering by using the optional[number] portion of the footnote command.Example:
\footnote[3]{This is the third footnote}
This command produces this footnote. 3
3This is the third footnote
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Marginal Notes
You can also include margin notes in your document. Use the
\marginpar[left]{righttext} command
If you only specify the required command righttext then the marginnote placement goes as follows:
• On the right for single sided documents
• On the outside margin for doublesided documents
If you use the optional [left] argument then the note will go on theleft. Example:
\marginpar[left]{Here is a margin note.}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Endnotes
Endnotes require the use of the endnote package. Include it in thepreamble of your document with the
\usepackage{endnote} command.
To create an endnote just use the
\endnote{text} command
Finally, include this command at the end of your document whereyou want the endnotes to appear
\theendnotes
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Math Environments
In order to typeset mathematical formulae, you must put LaTeXinto math mode.
There are four different types of math mode:
• Math environment - Short in-line equations
• Displaymath environment - Numbered equations set apart inthe text
• Eqnarray Environment - Sequences of equations or very longequations
• Equation environment - Centered equations
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
You can achieve these modes by using the following commands:
Math environment -
• \begin{math}...\end{math
• \(...\)
• $...$
Displaymath environment -
• \begin{displaymath)...end{displaymath}
• \[...\]
• $$...$$
Eqnarray environment -
• \begin{eqnarray[*]}...\end{eqnarray[*]}
Equation environment -
• \begin{equation}...\end{equation}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
You can achieve these modes by using the following commands:
Math environment -
• \begin{math}...\end{math
• \(...\)
• $...$
Displaymath environment -
• \begin{displaymath)...end{displaymath}
• \[...\]
• $$...$$
Eqnarray environment -
• \begin{eqnarray[*]}...\end{eqnarray[*]}
Equation environment -
• \begin{equation}...\end{equation}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
You can achieve these modes by using the following commands:
Math environment -
• \begin{math}...\end{math
• \(...\)
• $...$
Displaymath environment -
• \begin{displaymath)...end{displaymath}
• \[...\]
• $$...$$
Eqnarray environment -
• \begin{eqnarray[*]}...\end{eqnarray[*]}
Equation environment -
• \begin{equation}...\end{equation}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
You can achieve these modes by using the following commands:
Math environment -
• \begin{math}...\end{math
• \(...\)
• $...$
Displaymath environment -
• \begin{displaymath)...end{displaymath}
• \[...\]
• $$...$$
Eqnarray environment -
• \begin{eqnarray[*]}...\end{eqnarray[*]}
Equation environment -
• \begin{equation}...\end{equation}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Math symbolsThere are many symbols involved in typesetting simple andcomplicated mathematical formulae. LaTeX is equipped to typeseteverything from simple to high level mathematics.
Example (Ampere’s Circuit Law):
∮∂S
B· dl = µo IS + µoεo∂ΦE ,S
∂t
Code:
$$\oint_{\partial S}B\cdotp dl = \mu_o I_S + \mu_o\epsilon_o \frac{\partial \Phi_{E, S}}{\partial t} $$
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example (Matrices):a11 a12 · · · a1n
a21 a22 · · · a2n...
.... . .
...an1 an2 · · · ann
x1
x2...
xn
=
00...0
Code:
$$\left[ \begin{array}{cccc}a_{11} & a_{12} & \cdots & a_{1n} \\a_{21} & a_{22} & \cdots & a_{2n} \\\vdots & \vdots & \ddots & \vdots \\a_{n1} & a_{n2} & \cdots & a_{nn} \end{array} \right]\left[ \begin{array}{c}x_1 \\ x_2 \\ \vdots \\x_n \end{array} \right] = \left[ \begin{array}{c}0 \\ 0 \\ \vdots \\ 0 \end{array} \right]$$
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example (Taylor Series):
∞∑n=0
f n(a)
n!(x − a)n
Code:
$$\sum^{\infty}_{n=0} \frac{f^{n}(a)}{n!}(x - a)^n$$
Example (DeMorgan’s Law):
¬(p ∨ q)⇐⇒ (¬p) ∧ (¬q)
Code:
$$\neg (p \vee q) \Longleftrightarrow (\neg p)\wedge (\neg q) $$
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
More Features
Aside from these examples, LaTeX provides symols for everythingyou need to typeset mathematics including:
• binary operators
• Greek symbols
• logical operators
• set notation
• trig functions
• delimiters
You can look up any mathematical command on google. Thefollowing link is helpful:http://web.ift.uib.no/Fysisk/Teori/KURS/WRK/TeX/symALL.html
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Amsmath Package
If you use mathematics heavily in your documents, you mightconsider using the amsmath package. It provides someenhancements to the normal LaTeX math capabilities which maketypesetting formulas easier and more attractive.Go here for more info:http://www.ams.org/tex/amslatex.html
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Tables
You can use LaTeX to create tables for your document. They arehighly customizable and can be simple or complex.With LaTeX you can:
• Easily format columns and Rows
• Customize the lines that separate columns and rows
• Control table size
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Tables must be created within the Tabular environment.
\begin{tabular[alignment]{columns}...\end{tabular}
Here are examples of parameters for the columns argument:
• l - left justified column
• c - centered column
• r - right justified column
• - vertical line
The [alignment] argument is optional. The options are:
• b - bottom
• c - center
• t - top
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Tables must be created within the Tabular environment.
\begin{tabular[alignment]{columns}...\end{tabular}
Here are examples of parameters for the columns argument:
• l - left justified column
• c - centered column
• r - right justified column
• - vertical line
The [alignment] argument is optional. The options are:
• b - bottom
• c - center
• t - top
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Tables must be created within the Tabular environment.
\begin{tabular[alignment]{columns}...\end{tabular}
Here are examples of parameters for the columns argument:
• l - left justified column
• c - centered column
• r - right justified column
• - vertical line
The [alignment] argument is optional. The options are:
• b - bottom
• c - center
• t - top
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
To form the table, separate each element with a & sign and eachrow with \ \
Example:
a b c de f g hi j k l
m n o p
Code:
\begin{tabular}{|c|c|c|c|}\hlinea & b & c & d \\e & f & g & h \\i & j & k & l \\m & n & o & p \\\hline\end{tabular}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
To form the table, separate each element with a & sign and eachrow with \ \
Example:
a b c de f g hi j k l
m n o p
Code:
\begin{tabular}{|c|c|c|c|}\hlinea & b & c & d \\e & f & g & h \\i & j & k & l \\m & n & o & p \\\hline\end{tabular}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example:
Iteration k of f (xn)
k xk1 xk
2 xk3 remarks
0 -0.3 0.6 0.7 -1 0.47102965 0.04883157 -0.53345964 δ < ε2 0.49988691 0.00228830 -0.52246185 δ < ε3 0.49999976 0.00005380 -0.523656 N4 0.5 0.00000307 -0.52359743...
.... . .
...7 0.5 0.0 -0.52359878 δ < 10−8
Find code here:http://amath.colorado.edu/documentation/LaTeX/reference/tables/
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
You can find a number of other examples plus code here:
http://en.wikibooks.org/wiki/LaTeX/Tableshttp://amath.colorado.edu/documentation/LaTeX/reference/tables/
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Including Graphics
LaTeX is able to manage graphics via an external package calledgraphicx. To use graphicx you must include the package in thepreamble of your document.
\usepackage{graphicx}
The graphicx package allows you too:
• Use several different file formats
• Scale or specify dimensions of the image
• Crop the image
• Rotate the image
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Allowed Formats
If you compile with latex you can only use the EPS image format.
If you compile with pdflatex you can use the following formats:
• JPG
• PNG
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Includegraphics Command
Use this command to include a graphic in your document:
\includegraphics[dimension]{file}
The optional [dimension] argument can include several differentoptions including:
• width and height
• scale
• angle
• trim
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example of Graphicx
\includegraphics[width=6cm, height=4cm]{flower.jpg}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example of Graphicx
\includegraphics[scale = .05]{flower.jpg}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example of Graphicx
\includegraphics[scale=.05, angle=45]{flower.jpg}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Importing Plots
It is also possible to import plots from other programs such asMatlab or Maple into your document. You just need to export theplot as a .eps file, or if you are using pdflatex you can export it asa .jpg. Then include the plot in your document using theincludegraphincs command.
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Including Figures
LaTeX provides a way to include figures in your document. Youmust use the figure environment.
\begin{figure}...\end{figure}
LaTeX will insert the figure into your document wherever it seemsbest, but there are a few optional commands that you can use withthe figure environment:
• h - put figure here
• t - put figure at top of page
• b - put figure at bottom of page
• p - put figure on separate page
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example:
\begin{figure}[h]
You can also include captions with your figures by using thecommand
\caption{text}
LaTeX will automatically number your figures and update a List ofFigures page in the ToC each time you add new figure to yourdocument.
Example:
\begin{figure}\centering\includegraphics{filename}\caption{This is a figure}\end{figure}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Example Figure
\begin{figure}\centering\includegraphics{flower}\caption{Photo of a purple flower}\end{figure}
Figure: Photo of a purple flower
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Slide Presentations in LaTeX
You can use LaTeX to make professional looking presentations.There are several packages for doing so including:
• Beamer
• Prosper
• Ppower4
The Beamer class allows you to easily create professional lookingpresentations that are
• Easily customized
• Capable of displaying sophisticated mathematics
• Capable of containing overlays
• Easily converted to handouts
• Display independent of operating system
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Slide Presentations in LaTeX
You can use LaTeX to make professional looking presentations.There are several packages for doing so including:
• Beamer
• Prosper
• Ppower4
The Beamer class allows you to easily create professional lookingpresentations that are
• Easily customized
• Capable of displaying sophisticated mathematics
• Capable of containing overlays
• Easily converted to handouts
• Display independent of operating system
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Using Beamer
In order to use the Beamer Class you must use it as thedocumentclass option in the preamble:
\documentclass[style]{beamer}
In the optional [style] command you can specify a number ofdifferent styles. If you exclude the command, then Beamer will usea default style.Go here for examples of Beamer styles:http://mike.depalatis.net/beamerthemes/
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Creating a Slide
To create slides using Beamer you must use the frame environment.
\begin{frame}[options]...\end{frame}
The [options] parameter can be used to specify a number offeatures:
• fragile or containsverbatim will allow you to include verbatimtext on the slide using the verbatim pakage
• allowframebreaks will allow Beamer to create extra slides toaccommodate overflow text
• shrink will shrink contents to fit onto one slide
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Creating a Slide
To create slides using Beamer you must use the frame environment.
\begin{frame}[options]...\end{frame}
The [options] parameter can be used to specify a number offeatures:
• fragile or containsverbatim will allow you to include verbatimtext on the slide using the verbatim pakage
• allowframebreaks will allow Beamer to create extra slides toaccommodate overflow text
• shrink will shrink contents to fit onto one slide
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Sample Frame Code
Here is the code for a basic frame:
\section{}\subsection{}\begin{frame}\frametitle{This is the title}Contents...end{frame}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Hyperlinks
Beamer allows you to create links between slides.
For example: Jump to next slide
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Target Frame
This is the target frame.
To create a hyperlink you must include the hyperref package in thepreamble. Then you must use the following code:
\hyperlink{target_label}{\beamergotobutton{text}}
The target label argument specifies the label you have given to thetarget slide and can say anything you want. You must label thetarget slide as follows:
\begin{frame}[label=target_label]
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Target Frame
This is the target frame.
To create a hyperlink you must include the hyperref package in thepreamble. Then you must use the following code:
\hyperlink{target_label}{\beamergotobutton{text}}
The target label argument specifies the label you have given to thetarget slide and can say anything you want. You must label thetarget slide as follows:
\begin{frame}[label=target_label]
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
OverlaysBeamer allows you to create overlays in your slide presentations.The overlays can be simple or intricate.Here is an example of a very simple overlay:
• First item
• Second item
• Third item
You can create this overlay by inserting the pause command aftereach item in the list.Code:
\begin{itemize}\item First item \pause\item Second item \pause\item Third item \pause\end{itemize}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
OverlaysBeamer allows you to create overlays in your slide presentations.The overlays can be simple or intricate.Here is an example of a very simple overlay:
• First item
• Second item
• Third item
You can create this overlay by inserting the pause command aftereach item in the list.Code:
\begin{itemize}\item First item \pause\item Second item \pause\item Third item \pause\end{itemize}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
OverlaysBeamer allows you to create overlays in your slide presentations.The overlays can be simple or intricate.Here is an example of a very simple overlay:
• First item
• Second item
• Third item
You can create this overlay by inserting the pause command aftereach item in the list.Code:
\begin{itemize}\item First item \pause\item Second item \pause\item Third item \pause\end{itemize}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
OverlaysBeamer allows you to create overlays in your slide presentations.The overlays can be simple or intricate.Here is an example of a very simple overlay:
• First item
• Second item
• Third item
You can create this overlay by inserting the pause command aftereach item in the list.Code:
\begin{itemize}\item First item \pause\item Second item \pause\item Third item \pause\end{itemize}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
OverlaysBeamer allows you to create overlays in your slide presentations.The overlays can be simple or intricate.Here is an example of a very simple overlay:
• First item
• Second item
• Third item
You can create this overlay by inserting the pause command aftereach item in the list.Code:
\begin{itemize}\item First item \pause\item Second item \pause\item Third item \pause\end{itemize}
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
More Examples
Example: The following overlay can be created using this code
\only<1>{First}\only<2>{Second}\only<3>{Third}
FirstExample: The following overlay can be created using this code
\alt<5>{I am here}{I am not here}
I am not here
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
More Examples
Example: The following overlay can be created using this code
\only<1>{First}\only<2>{Second}\only<3>{Third}
SecondExample: The following overlay can be created using this code
\alt<5>{I am here}{I am not here}
I am not here
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
More Examples
Example: The following overlay can be created using this code
\only<1>{First}\only<2>{Second}\only<3>{Third}
ThirdExample: The following overlay can be created using this code
\alt<5>{I am here}{I am not here}
I am not here
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
More Examples
Example: The following overlay can be created using this code
\only<1>{First}\only<2>{Second}\only<3>{Third}
Example: The following overlay can be created using this code
\alt<5>{I am here}{I am not here}
I am not here
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
More Examples
Example: The following overlay can be created using this code
\only<1>{First}\only<2>{Second}\only<3>{Third}
Example: The following overlay can be created using this code
\alt<5>{I am here}{I am not here}
I am here
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Acquiring Beamer
In order to use the Beamer class you must first install it. You candownload it here:
http://sourceforge.net/projects/latex-beamer/
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Where to get Help
There are several different resources for learning LaTeXBooks:
• LaTeX Concisely by Adrian Johnstone
• The LaTeX Companion by Michel Goossens
• A Guide to LaTeX by Melmut Kopka
• LaTeX For Scientists and Engineers by David J. Buerger
• The LaTeX Graphics Companion
• The LaTeX Web Companion
Notes Mathematics in LaTeX Tables Graphics Figures Making Presentations in LaTeX Resources
Online: There are numerous online tutorials and user guides forLaTeX, specific commands, packages, etc.
The Research Computing Lab: You can send questions to methrough our ticket systemhttp://www2.lib.virginia.edu/brown/rescomp/help/index.html