LaΤeΧ

...and ΤΕΧ, and ConTeXt and XeTeX and TeXleMeElmo

(thanks fun.fnord.eu)

The least worst mathematical typesetting system. One of the better scoured of the filthy pipes in the academic plumbing. De facto standard for mathematicians, especially those who are not so impertinent as to insist in writing in non-English languages, or are not so shallow as deny the simple delight of the painstaking handicraft of manually setting line breaks, or have grad students who will deal with all that shit for free. That is, a tool that meets the needs of the Tenured Academic sufficiently, and that the rest of us survive.

Other alternatives include

1. using MS Word, and
2. stabbing your eyeballs with a pencil

… each of which I regard as similarly undesirable, and, to be clear, both marginally less desirable than LaTeX itself, despite my qualms.

Addendum: Yes, I am aware there are differences due to various different engines, formats, macro systems etc, giving us ConTeXT and LaTeX and TeX and pdftex and xetex and luatex, and that they are all refreshingly different in their choices of pain-points in formatting, interoperation, character set handling, compatibility, and community support. However, standards lock-in being what it is, I believe I can avoid arranging the deckchairs on this sinking boat by waiting for incremental improvements to make a difference. I will discretely wait over here, near the HTML lifeboats, for some amped-up scholarly version of Markdown to come save me and render the entire tiresome situation irrelevant.

History

Eddie Smith, From boiling lead and black art: An essay on the history of mathematical typography; the only thing on this page you might conceivably read for pleasure.

Robert Kosara has an excellent rant:

The tools of the trade for academics and others who write research papers are among the worst software has to offer. Whether it’s writing or citation management, there are countless issues and annoyances. How is it possible that this fairly straightforward category of software is so outdated and awful?

Grad students, Robert. Grad student labour. The same labour undervaluation that keeps slave economies from developing the steam engine.

Here is a more fannish, upbeat and pious take by Graham Douglas, Whats in a name: a guide to the many flavours of Tex.

Documentation I frequently need to find

Defining new operators

“Without Limits”, i.e. limits on the side, $${\mathop{\mathrm sech}\nolimits}^2 x$$

plain style (works everywhere including old mathjax)

\newcommand{\sech}{\mathop{\mathrm sech}\nolimits}


amsmath style: (works in AMSMath environments)

\DeclareMathOperator{\sech}{sech}


“With Limits”, i.e. limits underneath $${\mathop{\rm arg\,max}}_{x\to\infty} x$$

plain style:

\newcommand{\sech}{\mathop{\rm sech}\limits}


amsmath style:

\DeclareMathOperator*{\argmin}{arg\,min}


Include LaTeX in python

Including arbitrary LaTeX in python scripts, jupyter notebooks, Pweave literate documents? Use an ingenious script called using latex_fragment. It was written by that paragon of coding cleanliness, by that tireless crusader for not-dicking-around, me.

from IPython.display import display_latex, display
import latex_fragment
l = latex_fragment.LatexFragment(r'$x=y$')
display(l)


Note also that pandoc markdown already includes LaTeX support.

Make TeX run like a normal unix program

As opposed to the default pointless-error-interaction-mode-that-briefly-thought-that-it-would-be-hip-in-the-80s.

pdflatex -interaction=nonstopmode -halt-on-error


Bloody-minded compile-my-document-at-all-costs-I-don’t-care-how-it-is-broken:

pdflatex -interaction=batchmode


Death-or-define macro

Death-or-define is how I think of the trick to force a macro definition redefinition even if there is no definition to be redefined — handy if you are rendering latex from some tricky source such as jupyter, or where you don’t have control over the overall document outside your section but don’t care about wreaking havoc on your collaborators; some other poor sap can deal with the macro mutation weirdness.

\providecommand{\foo}{}
\renewcommand{\foo}[1]{bar: #1}


Algorithms/pseudocode

Confusing profusion of options.

tl;dr: use

• a hip markup such as

• algorithmicx

• algpseudocode (a nice default syntax that comes with algorithmicx), or
• program

• inside an algorithm float.

\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{algorithms}

\begin{algorithm}
\caption{Euclid’s algorithm}
\label{euclid}
\begin{algorithmic}[1] % The argument is the first line number
\Procedure{Euclid}{$a,b$} \Comment{The g.c.d. of a and b}
\State $r\gets a \bmod b$
\While{$r\not=0$} \Comment{We have the answer if r is 0}
\State $a \gets b$
\State $b \gets r$
\State $r \gets a \bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}


Are you running minimalist TeX? You’ll need

tlmgr install algorithmicx algorithms


or you can do without algorithms if you do

\usepackage{float}
\newfloat{algorithm}{t}{lop}


Minimalist TeX

MacTeX wastes your hard disk space if you install the whole gigantic thing. 5Gb for a 1980s typesetting system is cheeky, especially from people who delight in claiming that Microsoft Word is over-engineered, and that they are keeping it serious with their svelte, elegant, professional alternative. But LaTex is not “serious typesetting”, except in the sense that driving a panzer to work is “serious commuting”. (In this metaphor, Microsoft Word is some kind of polka-dotted clown car, as far as mathematics is concerned.)

However! You can install what you need via the package manager tlmgr using the minimal distribution, basictex. Which is still hundreds of megabytes, but we are going to have to take what breaks we can here. Then you take the bare bones setup and install the extra things you need.

For example, to render jupyter notebooks, you’ll need:

tlmgr install \
collectbox \
collection-fontsrecommended \
enumitem \
logreq \
ucs \
xstring


To handle fancier jupyter notebook via ipypublish, we also need

tlmgr install \
latexmk \
translations


To handle biblatex:

tlmgr install biblatex


To handle modern referencing:

tlmgr install placeins \
todonotes \
chngcntr \
doi \
mdframed \
needspace \
cleveref

tlmgr install amsfonts \
amsmath \
lm \
unicode-math \
ifxetex \
ifluatex \
listings  \  # (if the --listings option is used)
fancyvrb \
longtable \
booktabs \
graphicx \
grffile \
xstring \
logreq \
biblatex \  # if biblatex is used
biber \  # if biber is used
fontspec \  # if xelatex or luatex
polyglossia  \  # if xelatex
xecjk \  # if xelatex
bidi   # if xelatex


To handle Anki flashcard rendering:

tlmgr install bbm-macros \
dvipng


To handle latex_fragment:

tlmgr install standalone \
preview


To handle .eps files.

tlmgr install epstopdf


To handle Tom Pollard’s markdown thesis:

tlmgr install truncate \
tocloft \
wallpaper \
morefloats \
sectsty \
siunitx \
threeparttable \
l3packages \
l3kernel \
l3experimental


You keep it up to date in a the obvious way:

tlmgr update --self
tlmgr update --all


The non-obvious thing is that this works for approximately one year, then you are cut off from updates, and have to do a crazy tedious procedure to get another year’s life out of TeX.

No TeX at all

You just want equations? You don’t need TeX-the-software, just TeX-the-markup. Lots of things can render TeX math.

• Mathjax allows you to put LaTeX equations online easily without bothering with the rest of that bullshit.

• Mathjax LaTeX manual

• Carol Burns’ Exhaustive MathJax Page I find more useful, though, since it shows and tells you at the same time.

• Katex is a faster competitor to Mathjax, but is not as widely supported. Additional pain point was that you couldn’t define macros inline which was tedious because macros are ubiquitous in real mathematics work. Katex supports macros since 0.10.rc1, although you need to use the abnormal syntax \gdef to get real LaTeX-like behaviour, since \renewcommand exists but doesn’t persist between equations AFAICT, which makes it pointless as far as mimicking LaTeX. OTOH the \gdef thing seems to persist between documents which is also not ideal. Diffusion of this feature into popular packages is slow, e.g. it doesn’t work in vs code markdown+math.

• jupyter can use mathjax out of the box.

Editors

• Mathematica can export mathematics to TeX and is a good, if colossally overengineered, editor

• TeXStudio has image drag-n-drop support

• latex-workshop is the VS Code LaTeX extension. It’s slick, although overeager to try and typeset every document you open.

• atom-latex and the atom latex package both bring LaTeX support to the Atom editor though I haven’t yet worked out the difference. The latter supports literate coding so is morally superior.

• texshop is the open-source stalwart editor on e.g. OSX.

• TeXmacs - if you want to integrate a beautiful but obscure and poorly maintained notebook-style interface with your typesetting. Many do. I’d rather use knitr etc for integrating my diagrams and keep the GUIs separate, but this is personal preference.

Posters

a0poster is popular, as expounded by Morales de Luna, but I secretly feel that it sounds like a nightmare of legacy postscript nonsense and doesn’t even look good. sciposter is a popular a0poster variant.

tikzposter and beamerposter are both highlighted on sharelatex and are truly fugly. Why would anyone who claims to care about design inflict this on the world?