2022-02-10: LaTeX escapes

Did you know you can get LaTeX to run a shell command and pipe it into the document‽ I didn’t and I know loads of dirty LaTeX tricks. The syntax is weird and it only works on recent versions of PDFLaTeX if you turn shell escapes on (please don’t) but its still useful.

My data set has: \input{|”wc -l ./dataset.csv”} lines.

The way I’d have done it before is have a Makefile generate a `dataset-length.tex` file by running the command before TeX-ing the main document… but this is way cleaner, though I suppose you limit the conditional building potential? Which might matter if you’re generating whole analysis bits on every LaTeX pass?

Why is the syntax so weird though? I’m guessing that PDFLaTeX has `|` set as a special macro character but jeez. Weird. Very odd.