The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

Intro to LaTeX Sarah Hamilton June 1, 2010 1 Getting Started LaTeX is a fabulous tool for anyone that wants to make their work look more professional.

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by , 2016-02-22 20:39:02

Intro to LaTeX - Colorado State University

Intro to LaTeX Sarah Hamilton June 1, 2010 1 Getting Started LaTeX is a fabulous tool for anyone that wants to make their work look more professional.

Intro to LaTeX

Sarah Hamilton
June 1, 2010

1 Getting Started

LaTeX is a fabulous tool for anyone that wants to make their work look more professional. You
may recognize the style from many of your math textbooks.

To use LaTeX on your personal computer you first download MikTeX 2.8 or whatever version
it is currently on. I strongly suggest downloading the ENTIRE version, not the light
version as this will save you countless headaches. Then you can either run the code in a
way that reminds me of MS-DOS, or download a shell like TeXnicCenter (free) or WinEdt (one
time payment of around $30). The shell provides you with a GUI that makes learning LaTeX a
whole world easier!

1.1 Basic shell

\documentclass[12pt]{article} % Other options include report, book, etc.

%-------Packages to load------------
\usepackage{verbatim} % prints exactly the characters you type
\usepackage{enumerate} % gives you more options for creating lists
\usepackage{graphicx} % needed for figures
\usepackage[dvips]{color} % needed for figures
\usepackage{amsmath, amsthm, amssymb} % needed for math stuff
\usepackage{latexsym} % needed for math stuff
\usepackage{color} % fun if you want to change the color of text or equations

\title{Intro to LaTeX}
\author{Sarah Hamilton}
\date{June 1, 2010}
% If you do not specify a date the date printed will be the date you last compiled

\begin{document} % Starts the document
\maketitle % Makes the title, date etc.

BODY OF DOCUMENT

\end{document}

1

1.2 Compiling

To “compile” or “build” your file you have a few options. In TeXnicCenter from the drop down
menu on the top/middle of the page first select LaTeX => PS => PDF, then click the stack of papers
to the right to build the file. If you have a bibliography that you need to compile you need to
click Build, then Current File, then BibTeX. Then the stack of papers again. Then the stack
of papers with the magnifying class

1.3 Basic Formatting

1.3.1 Spacing

When you skip a line (leave one blank) the text will automatically be indented and begin on the
following line. If you want your document to have a visible blank line you need to use the command
\vspace{1em} to give a vertical space the height of one character. For example to produce:

The quick brown fox

jumps over the fence.

you will use the following:

The quick brown fox

\vspace{1em}
jumps over the fence.

You can set your paper to be single, one-half, or double-spacing in the preamble to the document
by loading the \setspace package:

\usepackage{setspace}
\singlespacing %-Uncomment whichever you want
%%\onehalfspacing
%%\doublespacing

To manually set the margins of your paper you can declare them in the preamble directly under
the \documentclass declaration like this:

\documentclass[12pt]{article} % Other options include report, book, etc.
\usepackage[left=2cm,top=2cm,right=2cm,bottom=2cm,nohead,nofoot]{geometry}
%-set specific margins if desired

To avoid indenting at the start of a new line, use the \noindent command followed by your
text.

1.3.2 Date

You can manually set the date you want to be printed on your document using the \date command
after the title as follows:

%\title{Intro to LaTeX} 2
%\author{Sarah Jane Hamilton}
%\date{June 1, 2010}

the benefit of this is that you know the last time that you worked on the file. This is helpful for
keeping track of versions of a paper.

Another option is not to include the \date command at all. This results in printing the current
date that you compile the file on which could also be beneficial.

1.3.3 Font Style Options
You have some flexibility in what font LaTeX compiles your work. The default is rather nice but
if you really want a change just Google it and I’m sure you can find lots of options.
Sometimes changing the color of your text can be fun and a great way to emphasize a specific part of
your paper or presentation. To change the color above I used: \textcolor{red}{color of your text}.
You can manually change the size of the font for portions of the paper using the following com-
mands:

1. \tiny
2. \scriptsize
3. \footnotesize
4. \small
5. \normalsize
6. \large
7. \Large
8. \LARGE
9. \huge
10. \Huge
and therefore the following code:
Here is some normal sized font
\tiny
Look how small the text is now!
\normalsize And now it’s back to normal!
produces:
Here is some normal sized font Look how small the text is now! And now it’s back to normal!

3

1.3.4 Creating Your Own Shortcut Commands

Creating shortcut commands can save you a lot of typing. Here are a couple of ways to do it:

\DeclareMathOperator{\by}{\times}
This command needs to be declared in the preamble (before the \begin{document} command).
It says that when I’m in math-mode and type \by it will produce the × symbol. This can be
especially helpful when you are using derivative operators frequently.

\def\su{Sylvester and Uhlmann}

This command comes after the \begin{document} command and can save you time so that every
time in regular (or math) mode you type \su it produces Sylvester and Uhlmann.

2 Math Mode

To type math within your sentences or paragraphs you want to surround your math with dollar
signs $ like this: $5x+9y$ produces: 5x + 9y.

2.1 Separate Line Equations

This is all good and wonderful but sometimes you want to write your equations on their own lines.
You have many options.

2.1.1 equation

If you want to number you equations this is the best option. Typing,

\begin{equation}\label{eq-example1}
\frac{1}{3}x+9=y.
\end{equation}

produces:

1 (2.1)
x + 9 = y.

3

If you would prefer not to number you equations you can either use the symbol

\begin{equation*}
\frac{1}{3}x+9=y.
\end{equation*}

which produces: 1
or use backslash brackets, x + 9 = y.

3

\[ \frac{1}{3}x+9=y. \]

which produces:

1
x + 9 = y.

3

since there is no equation number to reference we need not bother with labels.
4

2.1.2 eqnarray

The \eqnarray command is very helpful if you have a system of equations that you want to have
properly aligned. The commands:

\begin{eqnarray}
\frac{df}{dx} &=& 13y+\sin(3x)\label{eq-dfdx}\\
\frac{df}{dy} &=& 12y^2+9e^{3y}\label{eq-dfdy}
\end{eqnarray}

produce:

df (2.2)
= 13y + sin(3x) (2.3)

dx
df = 12y2 + 9e3y
dy

Notice that the & symbol is used to distinguish between the three parts of the equation namely
the left hand side, the equality symbol, and the right hand side. Using the & allows LaTeX to
know how you want it to align the equations. Notice that they both match up at the equality
symbol so they look nice.

2.1.3 cases
If you have a piecewise defined function sometimes you’ll want to use

\[f(x)=\begin{cases}
3x-9 & x>0\\
\frac{1}{2}x & x\leq0\\
\end{cases}\]

{

f (x) = 3x − 9 x > 0

1 x x≤0
2

2.2 Matrices

You can input matrices using the array command. To create the following 3 × 4 matrix A

12 3 4

A= 5 6 7 8 
9 10 11 12

use the following code:

\[A=\left[\begin{array}{cccc}
1 & 2 & 3 & 4\\
5 & 6 & 7 & 8\\
9 & 10 & 11 & 12\\
\end{array}\right]\]

5

The \left[ and \right[ commands put the super large brackets on the left and right sides of
the matrix. Basically they say, “put brackets around (as large as necessary) everything between
us!”. You can also use \left( and \right) for the round brackets if you prefer. Lots of options!

The {cccc} indicates that you will have 4 columns and in each column you want the character
to be centered. If you prefer left or right aligned just use l and r. For example {clr} would mean
you want 3 columns where the first column is center-aligned, the second is left-aligned, and the
third is right-aligned.

You need to use & to separate the separate entries in each row of the matrix. They are called
‘alignment characters’. At the end of each row you end it with a \\

2.3 Greek Letters and Other Symbols

To type Greek letters, which you will no doubt inevitably have to do, you just type $\sigma$ to
produce σ. Basically you just type a backslash then spell out the Greek letter. If you want it
uppercase, then just capitalize the first letter i.e. $\Sigma$ produces Σ.

The GUI for the LaTeX shell you are working in (TeXnicCenter or WinEdt) will have a list of
other random symbols that you might need with pictures of the symbol for you to click on.

To write the trigonometric functions sin, cos, etc. simply type for example $\sin$. The
backslash makes calls the predefined operator for the sine function and therefore the letters are
not italicized as they would be if you just typed $sin$ which produces: sin.

2.4 Sub/Superscripts

You will also need to use both sub- and super-scripts.

To create a super-script in math mode you need to use the ˆ. If the super-script you are using
is longer than one character you need to put it in curly brackets { and } like $x^{13}$ produces:
x13.

To create a sub-script in math mode you need to use the . Similarly if the sub-script you
are using is longer than one character you need to put it in curly brackets { and } like $x_{13}$
produces: x13.

Here is an example with both sub- and super-scripts as well as a Greek letter:

\[x^{20}+2y^{7}-\beta_{16}=29\]

produces:

x20 + 2y7 − β16 = 29

3 Figures and Tables

3.1 Figures

You have two main options when adding figures such as pictures or graphs. Very often .eps
(Encapsulated PostScript files are used. To insert the picture
with file name cobweb example.eps use the following code:

\begin{figure}[h] % The [h] means put the figure HERE
% Requires \usepackage{graphicx}
\centering % To center the figure horiz6ontally

xt+1

xt

Figure 1: Cobwebbing Example for M155

\includegraphics[width=4in]{cobweb_example}\\
\caption{Cobwebbing Example for M155}\label{fig-cobweb}
\end{figure}

3.2 Tables

Tables can be very pretty in LaTeX. Here is some example code:

\begin{table}[h]
\caption{Experimental Voltage Differences for Centered Targets in mV \cite{Fuks91}}
\begin{center}\small
\begin{tabular}{| c | c | c | c | c | c |} % l for left, r for right, or c for center for each column

\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
Target Size & PVC (43 mm) & Al (43 mm) & Cu$^*$ (41 mm) & Cu (41 mm) & Human Fist\\
\hline
$\Delta V$ Real & 75 & 80 & 70 & 70 & 20\\
$\Delta V$ Imaginary & 1 & 15 & 7 & $<2$ & 125\\
\hline
\end{tabular}
\end{center}
\end{table}

that produces the following table.

4 Closing Remarks

A course on LaTeX could last a very very long time. And I would be shocked if anyone ever thinks
they have mastered it all. The ideas here are just a starting point, the internet will be a great
resource.

7

Table 1: Experimental Voltage Differences for Centered Targets in mV [FCI+91]

Target Size PVC (43 mm) Al (43 mm) Cu∗ (41 mm) Cu (41 mm) Human Fist

∆V Real 75 80 70 70 20

∆V Imaginary 1 15 7 < 2 125

The book [Gra00] is a great source for getting started and learning more about what the
commands in the preamble actually do.

An absolutely fabulous resource is http://detexify.kirelabs.org/classify.html which
allows you to draw the symbol you want to write in LaTeX and then the website provides you with
the LaTeX command.

References

[FCI+91] Felipe Fuks, Margaret Cheney, David Isaacson, David G. Gisser, and J.C. Newell. De-
tection and imaging of electric conductivity and permittivity at low frequency. IEEE
Transactions on Biomedical Engineering, 38(11):1106–1110, November 1991.

[Gra00] George Gratzer. Math Into LaTeX. Springer, New York, third edition edition, 2000.

8


Click to View FlipBook Version