LaTeX Hacks

#LaTeX #Typesetting

Table of Contents

Recommended Editors

  1. Overleaf - online editor, free and paid plans. Good for collaborative work or if you are working from multiple devices. If you are a student, some universities will have paid plans available for free for students - so check with your course provider.
  2. TexStudio - local editor, free. Clear interface and will install missing packages for you (if you give it permission).

Figures

Float Package

Using the float package will cause the image to be rendered in the same place on the PDF as in the code. Add this to the preamble:

\usepackage{float}

Then…

\begin{figure}[H]

 \centering

   \includegraphics[width=1\linewidth]{path/to/image}

 \caption{Image Caption}

\end{figure}

 

Two Figures (or More!) in Parallel

\begin{figure}

 \centering

  \begin{subfigure}[b]{0.3\textwidth}

   \includegraphics[scale=0.2]{image}

   \caption{Text A}

   \label{fig:desc}

  \end{subfigure} %

  \begin{subfigure}[b]{0.3\textwidth}

   \includegraphics[scale=0.2]{image}

   \caption{Text B}

   \label{fig:desc}

   \end{subfigure} %

 \\

  \begin{subfigure}[b]{0.3\textwidth}

   \includegraphics[scale=0.2]{image}

   \caption{Text C}

   \label{fig:desc}

  \end{subfigure} %

  \begin{subfigure}[b]{0.3\textwidth}

   \includegraphics[scale=0.2]{image}

   \caption{Text D}

   \label{fig:desc}

  \end{subfigure} %

\end{figure}

Tables

Tables in LaTeX can be tricky.

You can use the tabular package.

\begin{center}

\begin{tabular}{|l | l | l | l | l |}

\hline

one & two & three & four & five \\

\hline

\end{center}

This will create a centered table with five cells. Duplicate the hline for more rows.

Bibtex

This is your best friend for writing a good bibliography.

This guide is excellent:

https://www.overleaf.com/learn/latex/Bibliography_management_with_bibtex

Codeblocks

You can use the lstlistings package to add code snippets to your paper. Add this to your preamble:

\usepackage{listings}

Then…

\begin{lstlisting}

~your code here~

\end{lstlisting}