LaTeX Basics#

LaTeX using Overleaf#

  • Create documents via a cloud-based account

  • Source code or rich text format

  • Collaborating and sharing documents

  • Versioning and track changes

  • Templates for a variety of documents and publishers

  • Link with other tools in your research workflow

  • Pro account with your berkeley.edu address

Example#

Look at the template below to get a sense of how Overleaf works. On the left side, you’ll see the content written in LaTeX. On the right side, the rendered document.

Template_image

Structure of a document#

Term

Description

Example

Command

Control sequence which performs an action

\newpage

Preamble

Block of commands that define the type of document you are writing, the language you are writing in, the packages you would like to use. Comes before \begin{document}

\documentclass{article}

Package

Enable you to create bibliographies, insert images and figures, and write formulas.

\usepackage{amsmath}

Environment

Block of code with specific behavior depending on its type

\begin{} & \end{}

Body

Content of document enclosed inside an environment

\begin{document}

Note

  • Comments: Use % to create a comment. Nothing on the line after the % will be typeset.

  • Restricted Characters: Certain symbols require a backslash to appear, like $, &, #, and %.

Basic Commands#

  • Bold: \textbf{example}

  • Italics: \textit{example}

  • Underline: \underline{example}

Font typefaces: Change in preamble. More information: https://v2.overleaf.com/learn/Font_typefaces

Make Title#

  1. The simplest option for making a title is to use the \maketitle command which draws from the following declarations within the preamble:
    \author
    \date
    \thanks
    \title

  2. OR use the
    \begin{titlepage} ... \end{titlepage}
    environment.

The titlepage environment creates a title page, i.e. a page with no printed page number or heading. It also causes the following page to be numbered page one. Formatting is left to you, but commands like \centering, \vspace, and \vfill are helpful.

Basic Math#

To display math inline with text, place formula or symbol in between $:

$x + y = z$ renders inline: \(x + y = z\)

Display mode \[ x + y = z \] will center the equation on its own line:

\[x + y = z\]

Lists#

Use the \begin{itemize}...\end{itemize} environment to create unnumbered lists.

\begin{itemize}
\item Apples
\item Cherries
\item Oranges
\item Peaches
\item Watermelon
\end{itemize}

This code results in:

  • Apples

  • Cherries

  • Oranges

  • Peaches

  • Watermelon

Use the similar \begin{enumerate}...\end{enumerate} environment to create numbered lists.

Exercise 1#

Objective:
Practice several basic LaTeX commands in a new project.

  1. Open a new project in Overleaf.

  2. Create a title page

    1. Add [title page] to make preamble command \documentclass[titlepage]{article}

    2. After \title, add “VOLT LaTeX Basics Assignment”

    3. After \author, add your name

    4. Confirm that the date is correct or edit if needed

    5. Create Title Page using command \maketitle inserted after \begin{document}

  3. Add a new section labeled “Practice” using the \section* command.

  4. Add the following paragraph under that section using “inline” math commands:


We know the initial pressure \(P_0 = 7.00 \times 10^5 Pa\), the initial temperature \(T_0 = 18.0 ^{\circ}C\), and the final temperature \(T_f = 35.0 ^{\circ}C\).

Question: What is the final pressure \(P_f\)?


Hint

Add the command \usepackage{gensymb} to the preamble in order to use the \degree command.

  1. Add a new section labeled “California Road Trip Destinations”

  2. Make a numbered list of four items, for example:
    Yosemite
    Big Sur
    Lake Tahoe
    Death Valley

Commands needed: \section*{}, \times, $...$, \begin{enumerate}...\end{enumerate}. Degree can be represented several ways such as $^\circ$ or \degree (requires the {gensymb} package). Subscripts and superscripts are written using the symbols _ and ^.

Tip

Questions? Compare your LaTeX code to the solutions to troubleshoot.