% !TEX root = ../manual.tex
% !TEX program = xelatexmk
% !TEX spellcheck = en_GB

\section{\LaTeX\ engines}
\subsection{latexmk}
\label{sec:latexmk}
As has been noted before, you need to run |pdflatex| multiple times. Sometimes mixed with other commands. This is inconvenient, but there is a solution for this: |latexmk|.

|latexmk| checks your files to determine what commands to run and how many times. It makes sure to resolve your references, load your bibliography and generate the required files.

If your editor doesn't have a Latexmk option, the command line is:

\begin{lstlisting}[language=sh,showstringspaces=false]
latexmk -pdflatex="pdflatex -synctex=1 %O %S" -pdf #filename#
\end{lstlisting}

In TeXworks, it can be added (in Settings → Typesetting → Commands) with the following settings:
\begin{lstlisting}[language=]
Program:   latexmk
Arguments: -pdflatex=pdflatex $synctexoption %O %S
           -pdf
           $fullname

[X] View PDF after running
\end{lstlisting}

Latexmk can also do a cleanup of all generatable files:

\begin{lstlisting}[language=sh]
latexmk -C #filename#
\end{lstlisting}

\subsection{\texorpdfstring{\XeLaTeX\ \& \LuaLaTeX}{XeLaTeX & LuaLaTeX}}
\label{sec:latex3engines}
Two alternatives for |pdflatex| are |xelatex| and |lualatex|. Both of these engines are newer and allow you to make use of features that are coming in \LaTeX3. This means you can use several packages and features you cannot use with |pdflatex|. In the next few sections examples are included that only work in these two engines.

Latexmk can be configured to use this engine as follows:
\begin{lstlisting}[language=sh,showstringspaces=false]
	latexmk -pdflatex="xelatex -synctex=1 %O %S" -pdf #filename#
\end{lstlisting}
