Skip to main content

General/Documents #

Debugging #

In system shell #

Find out the current version of LaTeX: (credit)

pdflatex --version

When \xdef\@fontenc@load@list{\@fontenc@load@list undefined control sequence happens: (credit)

fmtutil-sys --all

Pass options to already loaded packages #

When ! LaTeX Error: Option clash for package ... (credit)


% before

Find mirrors #

In CTAN list of mirrors, adding


after the https links will get you the link that TeX Live Utility needs.

Outdated TeX Live #

Ref: texlive - Historic TeX Live distributions: HTTPS/SFTP mirror - TeX - LaTeX Stack Exchange

If you are on, for example, TeX Live 2022, and all the available mirrors have already upgraded to 2023 (marked by a 0-byte TEXLIVE_2023 file in the tlnet root), then you need the historic repository. A list of the mirrors is available at Historic archive - TeX Users Group, and adding


(or with any other year that you need) after the https://ftp. links will get you to the TeX Live Utility link.

Build & file structures #

Compile two versions at one pass #

pdftex - 2 PDF Outputs at once with 2 different styles - TeX - LaTeX Stack Exchange

Or: Arara (?)

File control/subfiles #

Also see: Management in a large project - Overleaf, Online LaTeX Editor

At least in TeXstudio, as long as %!TEX root is set properly, build can be triggered in any sub-file.

However, after updating any BibLaTeX file, only rebuilding the root file will trigger the

This is an extensive example with both custom class, separate preamble file and bibstyle. There is no need to use everything.

├── main.tex
├── myclass.cls
├── mypreamble.tex
├── slides.tex
├── ref.bib
├── chapters
│   ├── intro.tex
│   ├── sections.tex
│   ├── model.tex
│   └── appendix.tex
└── styles
    ├── aernobold.bst
    └── aernobold.sty

In main.tex:





In mypreamble.tex:


In chapters/**.tex (first line of file):

%!TEX root = ../main.tex

Prevent page breaks around subfiles #

Way 1: use \input (credit)


Way 2: use \include (credit)

This method breaks all cleveref references pointing to labels inside the subfiles. Don’t know about normal references.


Citation in section title #

Ref: tableofcontents - Latex: Citations in section headings put into table of contents first - Stack Overflow

\section[Section title for running heading]{Section title with citation \cite{key}}

Cross-referencing #

Bookmarks #

Section numbers in PDF bookmarks: (one of them will work depending on your styles, bookmark is better)



Manually add bookmarks: (ref)

% if using numbered bookmarks

% note: don't use, will mess with appendix bookmark levels:
% \bookmark[level=0,named=Bibliography]{Bibliography}

% if using unnumbered bookmarks

Equations & sections #

Ref: Cross-reference packages: which to use, which conflict? - TeX - LaTeX Stack Exchange

TL;DR: use cleveref.

LaTeX/Labels and Cross-referencing - Wikibooks, open books for an open world

Code display #

listings package #


  \lstinline|hello, world|

  # help i'm in latex hell

minting package #


Colour #

Ref: better default colors for hyperref links - TeX - LaTeX Stack Exchange

% by default markdown introduces hyperref


Formatting text #

Highlight #

% or

% can be used with various colours
% or even custom colours (also with xcolor)

  \hl{Good words.}

  % Cleveref requires a warping mbox
  \hl{Not so good words with \mbox{\cref{tab:a-table}}.}

Strike through #

With package soul:

% or


With package ulem:


  \sout{Bad words.}

Lists #

Unordered #

  \item ...
  \item ...
  \item ...

Ordered with numbers #

  \item ...
  \item ...
  \item ...

Ordered with alphabet #


\begin{enumerate}[label=\alph*)] % \Alph* for upper case
  \item ...
  \item ...
  \item ...

Quick pseudo list #

Ref: spacing - How can I force a \hspace at the beginning of a line? - TeX - LaTeX Stack Exchange

\hspace*{0.5ex}\hspace{3ex}a) ...

\hspace*{0.5ex}\hspace{3ex}b) ...

\hspace*{0.5ex}\hspace{3ex}c) ...

Checklist #

Ref: enumerate - How to create checkbox todo list? - TeX - LaTeX Stack Exchange

LaTeX checklist

  My ToDo list

    \item[\done] Frame the problem
    \item Write solution
    \item[\wontfix] profit


Maths #

Too much space around display math #

Ref: line spacing - Spaces around display math when using setspace - TeX - LaTeX Stack Exchange



Page number #

Reset page number at appendix #

Ref: Restart page numbering for memoir appendix - TeX - LaTeX Stack Exchange

% Words.

% \setcounter{page}{0}

% Less important words.

Page margin #

Change margin for a few pages #

Ref: Latex - Change margins of only a few pages - Stack Overflow


% words

\newgeometry{top=0.5cm, bottom=0.5cm}


Plots/Images #

Full image #

If want to control width:

  \caption{A good picture.}

Horizontal subplots #

For alignment inside subcaption figures, see this answer.


    \caption{A good picture.}
    \end{subfigure}% no empty line here!!
      \caption{A splendid picture.}
  \caption{Two great pictures.}

Vertical subplots #


    \caption{A good picture.}
      \caption{A splendid picture.}
  \caption{Two great pictures.}

Better environments/defaults #

List with larger line height #

Ref: How to adjust list spacing | The TeX FAQ

Note: works in Beamer, but does not work with [<+->] overlay (see Beamer #Bugs & quirks)


More permissible slash and hyphen #

Make LaTeX more willing to break line (Ref)

\renewcommand{\slash}{/\penalty\z@\hskip\z@skip }
\newcommand{\hyphen}{-\penalty\z@\hskip\z@skip }

Packages #

Cleveref #


% use abbreviation everywhere

\Cref{fig:1} is capitalised, and \cref{fig:1} is not capitalised.

siunitx #

Thousands separator:

  group-separator = {,},
  group-minimum-digits = 4,

\SI{15663}{}    % The empty braces are necessary for correct spacing
                % Gives: 15,663

Readings #