LaTeX Tips and Tricks
Once you have the basics down, these techniques will make your LaTeX workflow significantly faster, your documents look better, and your source files easier to maintain. These are the habits that experienced LaTeX users develop over years — now collected in one place.
1. Define Custom Commands with \newcommand
If you find yourself typing the same thing repeatedly, create a shorthand command. This is one of the highest-leverage LaTeX habits you can develop.
% In the preamble:
% Simple abbreviation
\newcommand{\eg}{e.g.,\xspace}
\newcommand{\ie}{i.e.,\xspace}
% Command with 1 argument
\newcommand{\term}[1]{\textit{#1}}
% Command with 2 arguments
\newcommand{\vect}[2]{\mathbf{#1}_{#2}}
% Renew an existing command (change \emph to use colour)
\renewcommand{\emph}[1]{\textcolor{blue}{#1}}
% In the document:
This is a \term{technical term}.
The vector $\vect{x}{i}$ represents the input.Custom commands also let you change formatting globally. If you define \term and later decide terms should be bold instead of italic, you change it in one place rather than searching your whole document.
2. Use microtype for Better Typography
The microtype package enables character protrusion and font expansion — subtle adjustments that make your text look noticeably more professional and dramatically reduce overfull hbox warnings.
\usepackage{microtype} % add this — it just works
% Optional: fine-grained control
\usepackage[
protrusion=true,
expansion=true,
tracking=true
]{microtype}3. Cross-References and Labels
Always use \label and \ref instead of typing numbers manually. The numbers update automatically when you add or remove sections, figures, or tables.
% Naming convention: type:name
\section{Introduction} \label{sec:intro}
\begin{figure}... \label{fig:architecture}
\begin{table}... \label{tab:results}
\begin{equation}... \label{eq:loss}
% Reference them:
As discussed in Section~\ref{sec:intro},
Figure~\ref{fig:architecture} shows the system,
and Table~\ref{tab:results} lists the results.
For numbered equations, use \eqref{eq:loss}.The ~ (non-breaking space) before \ref prevents LaTeX from breaking the line between “Figure” and its number.
4. Useful Packages You Should Know
cleverefSmart cross-references. \cref{fig:arch} automatically outputs 'Fig. 1', \Cref{} for sentence-start capitalisation. Works with multiple references: \cref{fig:a,fig:b} → 'Figs. 1 and 2'.
booktabsProfessional-quality tables. Provides \toprule, \midrule, \bottomrule — never use \hline in a published document.
siunitxConsistent number and unit formatting. \SI{9.8}{m/s^2} typesets as '9.8 m s⁻²'. Aligns decimal points in table columns automatically.
xcolorNamed colours and custom colour definitions. \textcolor{red}{text}, \colorbox{yellow}{text}, \definecolor{myblue}{HTML}{3B82F6}.
todonotesComment annotations during writing. \todo{Check this citation} adds a visible margin note. \listoftodos at the end shows all pending items. Remove the draft option to hide them.
mintedSyntax-highlighted code blocks. Requires Python's Pygments package and the --shell-escape compile flag. Better than lstlistings for displaying code.
pgfplotsCreate publication-quality plots from data directly in LaTeX. No need for external plot images — the graphs render in the PDF at vector quality.
algorithm2eFormat algorithms and pseudocode with proper line numbering, keyword highlighting, and caption support.
5. Version Control Your LaTeX Source
LaTeX source files are plain text — this makes them ideal for Git version control. You get a full history of every change, easy collaboration, and the ability to roll back to earlier versions.
# .gitignore for a LaTeX project *.aux *.log *.out *.toc *.bbl *.blg *.fls *.fdb_latexmk *.synctex.gz *.pdf # optional: exclude compiled PDF from repo # Keep in git: # *.tex, *.bib, *.sty, figures/
Write one sentence per line in your .tex files. This makes git diff output readable at the sentence level instead of showing whole-paragraph diffs.
6. Typography Dos and Don'ts
| Instead of | Use |
|---|---|
| "quoted text" | ``quoted text'' — proper LaTeX opening and closing quotes |
| 1990-2020 | 1990--2020 — en-dash for ranges |
| however - this is wrong | however --- this is wrong — em-dash for parenthetical |
| 3.14 × 10^6 | $3.14 \times 10^6$ — mathematical multiplication in math mode |
| Section 3 | Section~\ref{sec:name} — auto-numbered reference |
| \hline in tables | \toprule / \midrule / \bottomrule from booktabs |
| figure sizes in cm | \columnwidth, \textwidth, 0.8\linewidth — relative sizes |
7. Splitting Large Documents
For theses, books, or long reports, split the document into chapter files using \input or \include.
% main.tex
\documentclass{book}
\usepackage{amsmath}
% ...
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\include{chapters/introduction} % chapters/introduction.tex
\include{chapters/methodology}
\include{chapters/results}
\include{chapters/conclusion}
\backmatter
\bibliographystyle{plain}
\bibliography{references}
\end{document}
% Tip: \include adds page breaks; \input does not
% Tip: use \includeonly{chapter1,chapter3} to compile
% only specific chapters, keeping cross-reference
% numbers correctTry these techniques in the editor
Open Skozin's editor and experiment with any of the tips above — no installation required.
Start Writing