LaTeX

This page contains a variety of useful links and notes on the document preparation software LaTeX.


Reading List/Resources

Manuals

Explanations

Instructional Guides/Tips

Tools

Fonts

Design Inspiration

Layout Templates

Images/figures

Plain image with defined width

The [H] parameter requires \usepackage{float}.

\begin{figure}[H]
  \centering
  \includegraphics[width=16cm]{Car Trial Data Tables.png}
  \caption{The two datatables.}
  \label{fig:Datatables}
\end{figure}

Two side-by-side figures with captions & a label

\begin{figure}[h] % the 'h' places it "here"
  \centering
  \subfloat[\centering Unweighted trials]{{\includegraphics[width=3.1in]{(Unweighted) x̄ Distance Travelled vs. Height.png} }}
  \subfloat[\centering Weighted trials]{{\includegraphics[width=3.1in]{(Weighted) x̄ Distance Travelled vs. Height.png} }}
  \caption{My two scatterplots.}
  \label{fig:example}
\end{figure}

Customizing image export from orgmode

  • #+ATTR_LATEX: :height 4in :width 2in

Equations

Standard equation (with text)

\begin{equation}
  \text{KE}_1 + \text{PE}_1 + \text{W}_\text{NC} = \text{KE}_2 + \text{PE}_2
\end{equation}

Multi-line equation aligned on =

\begin{equation}\setlength{\jot}{5pt}
  \begin{split}
    \text{KE}_1 + \text{PE}_1 - \text{W}_\text{friction} & = \text{KE}_2 + \text{PE}_2 \\
    \frac{1}{2}mv^2_1 + mgy_1 + \text{F}_\text{fr}d \cdot \cos\theta & = \frac{1}{2}mv^2_2 + mgy_2 \\
    \frac{1}{2}m \cdot 0 + mg\cdot h + \text{F}_\text{fr}d \cdot \cos 180^\circ & =  \frac{1}{2}mv^2_2 + mg \cdot 0 \\
    mgh - \text{F}_\text{fr}d & = \frac{1}{2}mv^2_2
  \end{split}
\end{equation}

Side-by-side equation with minipage

Uses a minipage.

\noindent\begin{minipage}{.2\linewidth}

  \begin{equation}\notag\setlength{\jot}{5pt}
    \begin{split}
      \large{\textbf{G:}} &\; g=9.81 m/s^2; m=0.0031\text{kg}; \textbf{h=0.57\text{m}}; d=0.504\text{m}\\
      \large{\textbf{U:}} &\; \text{F}_\text{fr} \\
      \large{\textbf{E:}} &\; mgh = 2\ffr \\
      \large{\textbf{S:}} &\; 0.0031\text{kg} \cdot 9.81m/s^2 \cdot 0.57\text{m} = 0.504\text{m} \cdot 2 \cdot \ffr \\ 
      \large{\textbf{S:}} &\; 0.01733 = 1.008 \cdot \ffr = \boxed{0.017\text{N}}
    \end{split}
  \end{equation}

\end{minipage}%
\begin{minipage}{1.2\linewidth}

  \begin{equation}\notag\setlength{\jot}{5pt}
    \begin{split}
      \large{\textbf{G:}} &\; g=9.81 m/s^2; m=0.0031\text{kg}; \textbf{h=0.20\text{m}}; d=0.168\text{m}\\
      \large{\textbf{U:}} &\; \text{F}_\text{fr} \\
      \large{\textbf{E:}} &\; mgh = 2\ffr \\
      \large{\textbf{S:}} &\; 0.0031\text{kg} \cdot 9.81m/s^2 \cdot 0.20\text{m} = 0.168\text{m} \cdot 2 \cdot \ffr \\ 
      \large{\textbf{S:}} &\; 0.0061 = 0.336 \cdot \ffr = \boxed{0.0181\text{N}}
    \end{split}
  \end{equation}

\end{minipage}

The & designates where to align. The \; serves as a space (I think it is the width of a space character, or slightly bigger).

Lists

XeLaTeX

  • \symbol{<code number>}

Alternative font simple

https://www.overleaf.com/learn/latex/XeLaTeX#Setting_fonts_for_different_LaTeX_elements

\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Public Sans}
\setmonofont[Color={0019D4}]{Courier New}

Alternative font complex

\usepackage{fontspec}
% Fonts - fontspec
\setromanfont[
BoldFont=EB Garamond Bold,
ItalicFont=EB Garamond Italic,
BoldItalicFont=EB Garamond Bold Italic,
]{EB Garamond Regular}

\setsansfont[
BoldFont=Public Sans Bold,
ItalicFont=Public Sans Italic,
BoldItalicFont=Public Sans Bold Italic
]{Public Sans Regular}

Misc

  • Where to put .sty files on Mac: ~/Library/texmf/tex/latex