difftex is a shell script wrapper around
latexdiff that can be used to
compare changes in .tex files between two different git commits (e.g., to
compare the changes between HEAD~1 and HEAD). It shares a similar purpose as
Git Latexdiff but it is
likely narrower in scope. difftex is build for macOS and other Unix-based
operating systems.
difftex can be installed by running:
curl https://raw.githubusercontent.com/mihaiconstantin/difftex/main/install.sh | sudo bashThe command above will perform the following steps:
- Clone the
mihaiconstantin/difftexrepository into a temporary directory. - Copy
difftex.shto/usr/local/bin/difftex. - Adjust permissions and make
difftexexecutable. - Remove the temporary directory.
To uninstall difftex simply remove the script as:
sudo rm /usr/local/bin/difftexTo update difftex just re-run installation command above which will replace
the current /usr/local/bin/difftex with the newest one from the GitHub
repository.
The script takes four arguments:
$1(required): The name of the main.texfile to compare between commits.$2: The older commit or reference to a commit. The default isHEAD~1.$3: The newer commit or reference to a commit. The default isHEAD.$4: The path or directory name where to produce and store the output. The default is./tmp
Example of how to use the script:
difftex file.tex
difftex file.tex HEAD~1 HEAD tmp
difftex file.tex branch-one branch-two tmp
difftex file.tex tag-one tag-two tmpThe annotated .pdf document can be found in the output folder (i.e., ./tmp
or the one specified).
In more advances cases, users may want to customize what kind of markup is
generated. To achieve this,
latexdiff offers a wide range of
options (i.e., see latexdiff --help). To maximize compatibility across
projects, difftex runs the latexdiff command with more or less the default
options, i.e.,:
latexdiff \
--type=UNDERLINE \
--append-textcmd="enquote" \
--allow-spaces \
--math-markup=3 \
--flatten \
# Reminder of the 'latexdiff' command.
...If a specific project requires running latexdiff with different or more
options, one can edit the file /usr/local/bin/difftex to adjust the
latexdiff command call accordingly. For example, adding the following (i.e.,
see below) will instruct latexdiff to include markup for changes in the
Abstract section of a manuscript.
--append-context2cmd="abstract" \If one is interested in ignoring changes for entire environments (e.g., the
figure environment), the following trick can be used (i.e., see this
answer for more information):
--config="PICTUREENV=(?:picture|DIFnomarkup|figure)[\w\d*@]*" \In the example above, the addition |figure instructs latexdiff to also
ignore the figure environment. This trick can be further extended to an
arbitrary number of environments (e.g., sidewaysfigure).
For a full overview of the capabilities of latexdiff make sure to check the
documentation by running latexdiff --help.
Note. To enable changes in .bib files please check this
answer.
See the CHANGELOG file.
Any contributions, suggestions, or bug reports are welcome and greatly appreciated.
difftex is licensed under the MIT license.