latex tips and tricks
view markdownContains simple instructions for common issues with writing in latex
diffing complex latex files
Pipeline for finding the differences between 2 versions of complex latex projects.
Note: this assumes that style files for the two do not change (only changes to .tex files).
-
Download all files for the original version and the new version into folders
- “Flatten” the tex files by replacing
\input{fname.tex}
with the contents of the filefname.tex
- simple python code to do this here
- installing (locally):
git clone git@github.com:johnjosephhorton/flatex.git cd flatex pip install --editable .
- running:
flatex --include_bbl inputfile.tex outputfile.tex
-
Copy the non-tex files (.cls, .bib, .sty, .bst, figs) you want to use to a new directory
- From this directory run latexdiff on the flattened files - this should produce the desired diff!
- running:
latexdiff file1_flattened.tex file2_flattened.tex > diff.tex
- running:
toggling documents with a simple boolean
a simple way to use booleans in latex without needing to import any packages
defining a boolean:
\newif\ifanonymize % define a boolean named `anonymize`
\anonymizefalse % set it to false
% \anonymizetrue % set it to true
use it in an if-statement
\ifanonymize
...
\else
...
\fi
create a helper command named \anonfinal
which takes two arguments and will print only one of them based on the boolean
\ifanonymize
\newcommand{\anonfinal}[2]{#1}
\else
\newcommand{\anonfinal}[2]{#2}
\fi
making figures
- figures should be saved as pdf unless they have a ton of points
some useful links
- https://github.com/Wookai/paper-tips-and-tricks