LaTeX is a typesetting system or software to create high-quality printed documents. It dates to the 1970s and predates many word-processing programs like Microsoft Word. LaTeX is also the goto software for people in STEM fields to produce mathematics and high-quality graphs.
The system is more like a programming language language in which there is source code which is compiled into a resulting PDF document.
Once you learn LaTeX, it is a fantastic typesetting system. Another aspect of it is that it is open-source and free. There are a bunch of different systems that you can install/use on a given computer
TeXLive for Macs is a place to grab everything you need to run LaTeX on your Mac. It is a huge download (about 1Gb), so if you decide to do this, get on a good internet connection, get yourself a drink or a meal and sit back and wait.
Note: there is a smaller version of this here. You’ll get a minimal install, but may have to install other packages later.
TeXLive for Windows is similar to the Mac site and has everything you need to get started and is equally big. A direct link to run a program to download and install it is located here.
MikTeX is an alternative LaTeX system with a more user-friendly installer. Click on the Download button above to get started. Note: MikTeX does not provide an editor you will need to do that below.
Since LaTeX is similar to a programming language, the place you write is an editor. As mentioned above, when you download the software, most bundles come with the editor. Here is what to look for:
TeXworks which comes with TeXLive or you can download separately.
TeXShop which is a Mac-only editor, but has the look-and-feel of a Mac software.
Overleaf is just a webpage with a built-in editor which is located at https://www.overleaf.com.
For the most part, these all are similar. There is a place to type in the LaTeX source; a set of buttons, menu items, and keyboard shortcuts to compile the code; and a console area for information about errors.
The following is a basic template for LaTeX:
\documentclass[11pt]{article}
\begin{document}
This is my first latex document.
\end{document}
The important aspects of this are:
the \documentclass
line tells LaTeX the base font size and the type of document. The other font sizes are 10pt and 12pt. Other types of documents are books and letters.
a \begin
/ \end
block is an environment. This is the document where the stuff that you type appears printed out.
any commands about the \begin{document}
is called the preamble.
anything after the \end{document}
is just ignored.
To get the LaTeX into a PDF form:
One main reason for doing LaTeX is the nice mathematical formatting. There are two modes of mathematics:
\[
… \]
. We will also learn later how to add line numbers.Here are some basic ideas of mathematical symbols:
x^2
generates $x^{2}$, but for multiple characters, you’ll need { }. For example, x^{10}
generates $x^{10}$.\frac{top}{bottom}
command. \frac{x^2}{2}
becomes $\frac{x^{2}}{2}$\frac{df}{dx}
becomes\int x^2 dx
generates\int_1^2 x^2 dx
generatesSums and products work like integrals. \sum_{n=1}^{\infty} \frac{1}{n}
generates
$$\sum_{n=1}^{\infty} \frac{1}{n}$$
and \prod_{i=1}^{10} (x-i)
generates
$$ \prod_{i=1}^{10} (x-i)$$
Other: There is a lot of mathematics that is skipped here. Here are some websites with more information:
paragraphs
To get a new paragraph, simply put in a blank line (two returns). For example
This is the first sentence in a paragraph. And this is another one to make this paragraph longer. This is the last sentence of my paragraph.
This is the first sentence of the next paragraph.
Will generate the two paragraphs. Notice that my default paragraphs are not separated by any space and are indented. This behavior can be changed in the geometry package listed below.
* Sections and subsections
Often for a paper, you will have sections and subsections of a paper. To generate a new section, type \section{Section Name}
and you will see a numbered section with a larger bold font. To get a subsection, type \subsection{Subsection name}
. If you don’t want the sections numbered, use \section*{}
or \subsection*{}
. For example
\section{Section One}
\subsection{Subsection name}
bold, italics
To get bold use \textbf{}
and put the bold words in the braces. For example, \textbf{this is in bold}
will show this is in bold. To get italics, use \emph{}
short for empahsis. \emph{this is in italics}
wil show this is in italics.
bulleted lists
To get a bulleted list use the itemize
environment and each bulleted item should start with \item
. For example:
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemze}
will generate
Item 3
enumerated lists
To get an enuerated (numbered) list, use the enumerate
environment. For example:
\begin{enumerate}
\item Item 1
\item Item 2
\item Item 3
\end{enumerate}
will generate
There are various types of bullets and enumeration types. This page gives some additional ideas on lists.
Like other software, additional functionality is located in packages in LaTeX. To load in a package, you will use the \usepackage
command in the preamble (above the \begin{document}
line).
Here are a few common packages
geometry
packageType \usepackage{geometry}
in the preamble. This gives a lot of flexibility on the spacing of margins and paragraphs, etc.
Typically, I will use this package with the following (make sure it is after you have loaded the package):
\usepackage[letterpaper,total={7in,9.5in}]{geometry}
which sets some margins by defining the area to be printed on (the total
option above). The documentation is here
amsmath
packageType \usepackage{amsmath}
in the preamble. This has a lot of helpful mathematical formatting. The amsmath documentation has more information that you probably want. Here’s a few ideas:
align
and align*
environment. This creates aligned, centered equations (either numbered or not—the *
is a non-numbered version).
The following:
\begin{align*}
2x_1 + 3x_2 & = 6, \\
3x_1 + 4x_2 & = 8.
\end{align*}
will generate
$$
\begin{array}{rl}2x_1 + 3x_2 =& 6, \newline
3x_1+4x_2 = & 8.
\end{array}$$
where the two lines line up via the ampersands (&)
bmatrix
, vmatrix
and pmatrix
environments generate matrices with different delimiters. This must be in math mode and typically in display math. I often put them in an align
or align*
environment. Each row of a matrix is ended with a \\
and each column is separated by an &
.
For example,
\begin{align*}
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
\end{align*}
will generate
$$\left[\begin{array}{ccc}
1 & 2 & 3 \newline
4 & 5 & 6 \newline
7 & 8 & 9
\end{array}\right]$$
\begin{align*}
\begin{vmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{vmatrix}
\end{align*}
will generate
$$\left|\begin{array}{ccc}
1 & 2 & 3 \newline
4 & 5 & 6 \newline
7 & 8 & 9
\end{array}\right|$$
\begin{align*}
\begin{pmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{pmatrix}
\end{align*}
will generate
$$\left(\begin{array}{ccc}
1 & 2 & 3 \newline
4 & 5 & 6 \newline
7 & 8 & 9
\end{array}\right)$$
and there are other delimiters available.
graphicx
packageType \usepackage{graphicx}
in the preamble. This package can load in external graphics (image files and other PDFs). Additional documentation can be found here.
If you have an image that is called my_image.png
, then to load it type
\includegraphics[width=2in]{my_image.png}
and you can change the width to another value or use the height
option instead. Note: make sure that the image is in the same directory that your latex source is.
There is a huge number of websites available for latex. Some of the more helpful ones are:
Maple can export mathematics in LaTeX form as well using the latex
command. For example typing latex(
$x^{2}$)
returns
{x}^{2}
which has extra curly braces, but still okay.
However, if you want to latex $\int x^{2} \, dx$, you get
1/3\,{x}^{3}
which is true, but perhaps not what you want. Many standard Maple commands have an inert form which doesn’t do anything. For example, typing
Int(x^2,x)
returns
$$ \int x^{2} \,dx$$
and note that you can get a nicer version of this by typing Int
then hitting escape.
Typing latex(#)
on the line number returns:
\int \!{x}^{2}\,{\rm d}x
There are many other commands with inert forms like limits, derivatives, etc.