LaTeX

Definitions on the margin

Writes the term being defined on the margin.
\documentclass{article}

% Emphasize argument and also write it on the margin.
\newcommand{\defi}[1]{\marginpar{\tiny#1}\emph{#1}}

\begin{document}
A positive integer is \defi{prime} if\ldots
\end{document}

Would you rather keep using \emph? You may extend its definition. First, copy the \emph command in \oldemph, and then redefine \emph.

\documentclass{article}

\let\oldemph\emph % Save emph in oldemph

% Redefine \emph: definition also appears on the margin.
\renewcommand{\emph}[1]{\marginpar{\tiny#1}\oldemph{#1}}

\begin{document}
A positive integer is \emph{prime} if\ldots
\end{document}

Time of compilation

Use \today to obtain the current date (works on article, amsart and memoir). To have the time of compilation as well, use the package datetime, and the command \currenttime.

\documentclass{article}

\usepackage{datetime}

\begin{document}
Compiled \today, at \currenttime.
\end{document}

Show labels

The showkeys package the argument argument of each \label command at the margin of the page.

\documentclass{article}

% notref, notcite: showkeys won't redefine \ref and \cite
\usepackage[notref,notcite]{showkeys}

% Customize labels
\renewcommand*\showkeyslabelformat[1]{\tiny#1}

\begin{document}
\section{Adding up}\label{s:adding}

\begin{equation}\label{e:sq-sum}
1^3 + 2^3 + \cdots + n^3 = (1 + \cdots + n)^2
\end{equation}

\end{document}

Master bibliography file

This tip is for GNU/Linux users. If /home/joe/research/ contains the file masterbib.bib containing all my bibiography, I can run

$ pdflatex myarticle.tex
$ TEXBIB="/home/joe/research/" bibtex myarticle
$ pdflatex myarticle.tex
$ pdflatex myarticle.tex

Instead of typing the second line above again and again you can add the following to your ~/.bashrc file.

bibtex='TEXBIB="/home/joe/research/" bibtex'

And then you can simply run:

$ pdflatex myarticle.tex
$ bibtex myarticle
$ pdflatex myarticle.tex
$ pdflatex myarticle.tex

Images in separate folders

Here is a document with a picture.

\documentclass{article}

\usepackage{graphicx}
\graphicspath{{~/img/}{local-imgs/}}

\begin{document}
\includegraphics{river}
\end{document}

The command \graphicspath informs LaTeX to also look for images in the folders local-imgs/ (inside of the current directory) and ~/img/.

Color all math

\documentclass{article}
\usepackage{tikz}      % For color names
\usepackage{everysel}  % \everymath, \everydisplay

\everymath{\color{red}}     % Color inline math
\everydisplay{\color{blue}} % Color displayed equations

\begin{document}
All instances of $m+a+t+h$ and \(m-a-t-h\) will be highlighted,
\[
E -q -u -a -t -i -o -n -s = (a s) w + e + l + l.
\]
\end{document}

Last updated: 28 Dez 2017.