Skip to content

Instantly share code, notes, and snippets.

@fareskalaboud
Last active April 3, 2019 21:56
Show Gist options
  • Save fareskalaboud/1f2d715b6e0e1a2b2c22fcc330811984 to your computer and use it in GitHub Desktop.
Save fareskalaboud/1f2d715b6e0e1a2b2c22fcc330811984 to your computer and use it in GitHub Desktop.

LaTeX Cheat Sheet

This has some FAQs and quick shortcuts but you should look at this documentation starting from this page.

Sectioning

How do I add a section? Use \section{Section Name} and/or \subsection{Subsection Name} in its own line. For example:

\section{Context}
    
\subsection{Personalised Medicine}
	
One of the largest problems in healthcare is the incorrect consumption of medication...

How do I add a page break?

Use \pagebreak in its own line, and anything after it will move to a new page.

How do I add a table of contents?

Copy the lines below wherever you want your table of contents to be. Remember to add a page break before and after these lines.

\setcounter{page}{1}
\thispagestyle{empty}
\tableofcontents
\listoffigures
\pagebreak
\setcounter{page}{1}

How do I add an appendix?

Use \appendix just before the part that's supposed to be your appendix.

Bold, italics, and others?

Basic formatting See this link.

Code Use the code below.

\begin{verbatim}
  food = "pizza"
  print("I want " + str(food))
\end{verbatim}

Tables Use this link and just copy the LaTeX. It's not the best, but it does the job.

Piece of advice when using tables: put them in a separate file (e.g. results_table.tex) and in your main.tex file just add the line \include{file_name} (in our example, it would be \include{results_table}) wherever you want it added.

Lists Use the code below.

\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}

Images

Some advice Usually, it is best to add vector graphics (i.e. if you're making a graph or chart, use something like PowerPoint and convert to PDF; that works 99% of the time) in making sure your graphics are vector.

If you only have PNGs or JPGs, they work too but they have to have really good resolution

Adding images Use the code below.

\begin{figure}[t]
    \centering
    \includegraphics{path/to/image.pdf}
    \caption{Caption goes here}
\end{figure}

You can also change the size of images. For example, the [scale=0.5] below as an argument will halve the size of the image.

\begin{figure}[t]
    \centering
    \includegraphics[scale=0.5]{path/to/image.pdf}
    \caption{Caption goes here}
\end{figure}

References

Which citation scheme should I follow?

APA, but you should be given a file to do this. You should have two files in the root folder (same folder as main.tex) called theapa.bst and theapa.sty.

Where do I store my citations?

In a .bib file. I usually call it bibliography.bib. Check out this link to see how the bibliography file looks like.

Where you want to add your bibliography, just paste the two lines below and it will follow the bibliography.

\bibliographystyle{theapa}
\bibliography{bibliography}

How do I add in-line references?

\cite{citation_id}, where citation_id exists in your bibliography file.

For example, if one of your citations is

@inproceedings{alaboud18,
	author = {Alaboud, Fares K. and Coles, Andrew},
	year = {2018},
	month = {06},
	booktitle = {Proceedings of the Scheduling and Planning Applications woRKshop (SPARK) at the 28th International Conference on Automated Planning and Scheduling (ICAPS)},
	title = {Personalised Medication Planning using PDDL+},
    url = "https://kclpure.kcl.ac.uk/portal/en/publications/personalised-medication-planning-using-pddl(2aefb56a-b4c7-423e-bffb-ab1b6ecbde9f).html"
}

then your citation is \cite{alaboud18}. I usually use the author name plus the two digit year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment