0% found this document useful (0 votes)
21 views

Latex Intro Slides II

The document provides an overview of LaTeX skills that were covered previously and skills that will be covered in the upcoming session. It discusses the preamble, useful LaTeX packages, defining new commands, inserting figures and tables, and citing references. The preamble allows calling packages, setting document properties, and defining commands. Useful packages include those for mathematics, figures, and page formatting. New commands can simplify repetitive elements. Figures and tables can be placed and formatted in the document. References are cited using BibTeX files and formatted automatically.

Uploaded by

Ricky Liuna
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)
21 views

Latex Intro Slides II

The document provides an overview of LaTeX skills that were covered previously and skills that will be covered in the upcoming session. It discusses the preamble, useful LaTeX packages, defining new commands, inserting figures and tables, and citing references. The preamble allows calling packages, setting document properties, and defining commands. Useful packages include those for mathematics, figures, and page formatting. New commands can simplify repetitive elements. Figures and tables can be placed and formatted in the document. References are cited using BibTeX files and formatted automatically.

Uploaded by

Ricky Liuna
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/ 19

What do you already know?

Last week, we learned the basics:


• What LATEX does.
• How to create a document.
• How to use labels and cross-references.
• How to typeset text.
• How to write equations.
What will you know in a bit less than an hour?

• Calling packages.
• Defining new commands.
• How to include figures (easy) and tables (less easy).
• How to use and track references.

After that, you’re on your own.


The Preamble

We’ve talked a lot about the body of a LATEX document, but very
little about the preamble.
The preamble allows you to call packages, set up your document,
and define new commands. A nice preamble for this session is as
follows:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}

The geometry package makes it easy to adjust the layout of your


document. The amsmath package includes a lot of mathematical
symbols you may find helpful.
The Preamble
There are thousands of packages. Here are some useful ones:

Mathematical Typesetting:
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}

Drawing Figures:
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{pstricks}

Page formatting:
\usepackage{color}
\usepackage{subfig}
\usepackage[footnotesize,hang]{caption}
\usepackage{showkeys}

When you have some spare time, teach yourself to draw pictures
with the tikz package. This is a useful skill to have.
The Preamble

Another thing you can in the preamble is define new commands.


This can be a symbol or structure that you use a lot, and don’t
want to type out every time. Here are some nice commands that I
like to define in a preamble:

\newcommand{\grad}{\boldsymbol{\nabla}}
\newcommand{\diff}[2]{\frac{\mathrm{d} #1}{\mathrm{d} #2}}
\newcommand{\pdiff}[2]{\frac{\partial #1}{\partial #2}}
\renewcommand{\vec}[1]{\boldsymbol{#1}}

New commands can take any number of arguments, or none at all.


The last definition uses \renewcommand, as it is overwrites an
existing command. Use this power sparingly.
The Preamble

Let’s see what our new commands look like

\grad = \vec{i} \pdiff{}{x} + \vec{j} \pdiff{}{y} + \vec{k} \pdiff{}{z}.

\diff{(\vec{u} \cdot \vec{v})}{t} =


\diff{\vec{u}}{t} \cdot \vec{v} + \vec{u} \cdot diff{\vec{v}}{t}.

Our new commands give:

∂ ∂ ∂
∇=i +j +k .
∂x ∂y ∂z

d(u · v ) du dv
= ·v +u· .
dt dt dt
Pictures

Pictures can be placed directly into the document, or within the


figure environment.

\begin{center}
\includegraphics[width=0.25\textwidth]{dice.png}
\end{center}

You can use most image formats, but .png and .pdf work best.
Pictures

The figure environment allows for cross-referencing, captioning and


layout adjustment.

\begin{figure}[hb]
\includegraphics[height=5cm]{dice.png}
\caption{This is a picture of dice.}
\label{dicepic}
\end{figure}

The [hb] argument tells the document to place the figure at the
current point (“here”) or at the bottom of a page. You can also
use t for the top of a page, and p to give the figure a page to itself.

LATEX often has a mind of its own when it comes to placing figures.
Pictures

Figure: This is a picture of dice.


Tables

Presenting information in table form is very flexible, but more


fiddly than a typesetting program.

\begin{center}
\begin{tabular}{|l||c|r}\hline
A & B & C \\ \hline \hline
Monday & Tuesday & Wednesday \\
$\alpha$ & $\beta$ & $\gamma + 7 = 12$ \\ \hline
\end{tabular}
\end{center}

The argument of tabular tells the table what vertical lines to use,
and what alignment to use in each column (left, centre, right).

The \hline command inserts a horizontal line. The & moves to a


new column. The \\ command moves to a new row.
Tables

Presenting information in table form is very flexible, but more


fiddly than a typesetting program.

A B C
Monday Tuesday Wednesday
α β γ + 7 = 12

The argument of tabular tells the table what vertical lines to use,
and what alignment to use in each column (left, centre, right).

The \hline command inserts a horizontal line. The & moves to a


new column. The \\ command moves to a new row.
Citations

When you write a report, you often have to include citations. This
could be a long (and very dull) lecture on its own.

Information about citations is saved in a BibTeX file, with the


extension .bib. It should be kept in the same folder as your .tex file.

Your BibTeX file is plaintext, and can be edited in the same editor
you use for your .tex files.

You can have individual BibTeX files for different documents, or a


master BibTeX file that contains all of your citations of interest.
This allows it to function as a rudimentary citation management
system.
Citations

Citations come in a wide variety of classes. The two most common


are the article class and the book class.

When you include a citation, some information is required, and


some is optional:

Articles:
Required: author, title, journal, year, pages.
Optional: volume, number, publisher, language.

Books:
Required: author (or editor), title, publisher, year.
Optional: edition, volume, number, series, address, language.
Citations

To include an article in your BibTeX file, you should include the


citation information in the following format:

@article{lustri2018nanoptera,
title={Nanoptera in a period-2 {T}oda chain},
author={Lustri, C. J. and Porter, M. A.},
journal={SIAM Journal on Applied Dynamical Systems},
volume={17},
number={2},
pages={1182--1212},
year={2018}
}

The first argument is the label that you’ll use to cite the article.
Try to be descriptive and consistent.
Citations

To include a book in your BibTeX file, you should include the


citation information in the following format:

@book{boas2006mathematical,
author={Boas, Mary L.},
publisher={John Wiley & Sons},
title={Mathematical methods in the physical sciences},
year={2006}
}

The order you include this information doesn’t matter, as long as


the required information is present.
Citations

To get your citation to show up, type the following at the end of
your document:

\bibliographystyle{plain}
\bibliography{citationlist.bib}

There are lots of styles available, but plain is normally a good


option. LATEX will handle all the formatting and ordering of
citations. If you need to add or remove a citation, you don’t have
to worry about reindexing everything: LATEX will take care of that
for you.

In case it isn’t obvious, citationlist.bib should be replaced


with the name of your BibTeX file.
Citations

The citation list won’t contain every single article, book, or other
document listed in the BibTeX file. It will only include documents
that are mentioned in the text:

Previous work on travelling waves in discrete systems, such as


\cite{lustri2018nanoptera}, used methods from classical applied
mathematics \cite{boas2006mathematical} to determine the wave speed.

\bibliographystyle{plain}
\bibliography{citationlist.bib}

To get this to work, compile the LaTeX, to tell the compiler which
citations to look for. Then compile to BibTeX, which puts the
bibliography in place. Then compile the LaTeX again to get the
cross-referencing right. Then compile once more for luck.
Citations

Previous work on travelling waves in discrete systems, such as [2],


used methods from classical applied mathematics [1] to determine
the wave speed.
Mary L. Boas.
Mathematical methods in the physical sciences.
John Wiley & Sons, 2006.
C. J. Lustri and M. A. Porter.
Nanoptera in a period-2 Toda chain.
SIAM Journal on Applied Dynamical Systems,
17(2):1182–1212, 2018.
You’re done!

You now know enough to write basic mathematical reports in


LATEX. But there are a huge number of other things you can do!
• Create presentations.
• Include videos.
• Create and edit document templates.
• Annotate and mark up existing documents

LATEX is extremely versatile, and I’m still learning new things all the
time. Get used to looking for solutions online, because the answer
to any question you might ask is out there somewhere.

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