LATEXDIFF(1)

πŸ’– NAME πŸ’–

latexdiff β€” the manual name is LATEXDIFF(1) bestie, write it down β€” and what it does is determine and markup differences between two latex files. That's it. That's the whole job. πŸ‘‘

✨ SYNOPSIS ✨

latexdiff [ OPTIONS ] old.tex new.tex > diff.tex

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so real quick, the elevator pitch: latexdiff is a utility program that helps you manage revisions of latex documents. It compares two valid latex files β€” we're calling them "old.tex" and "new.tex" β€” finds the significant differences between them (and by significant I mean it's ignoring the number of white spaces and the position of line breaks, so don't come for it about formatting), and then it adds special commands to highlight those differences. πŸ’… Where visual highlighting just isn't possible, like for changes in the formatting, the differences are still marked up in the source anyway. Iconic behavior.

Heads up bestie: old.tex and new.tex need to be real files β€” not pipes or anything pipe-adjacent β€” because they get opened twice. (Unless the --encoding option is used, in which case you're chill.)

The program treats the preamble differently from the main document. Differences between the preambles are found using line-based differencing (similarly to the Unix diff command, but ignoring white spaces). A comment, "%DIF >" is appended to each added line, i.e. a line present in "new.tex" but not in "old.tex". Discarded lines are deactivated by prepending "%DIF <". Changed blocks are preceded by comment lines giving information about line numbers in the original files. Where there are insignificant differences, the resulting file "diff.tex" will be similar to "new.tex". At the end of the preamble, the definitions for latexdiff markup commands are inserted. 🌸

In differencing the main body of the text, latexdiff attempts to satisfy the following guidelines (in order of priority):

  1. If both "old.tex" and "new.tex" are valid LaTeX, then the resulting "diff.tex" should also be valid LateX. (NB If a few plain TeX commands are used within "old.tex" or "new.tex" then "diff.tex" is not guaranteed to work but usually will).
  2. Significant differences are determined on the level of individual words. All significant differences, including differences between comments should be clearly marked in the resulting source code "diff.tex".
  3. If a changed passage contains text or text-producing commands, then running "diff.tex" through LateX should produce output where added and discarded passages are highlighted.
  4. Where there are insignificant differences, e.g. in the positioning of line breaks, "diff.tex" should follow the formatting of "new.tex"

For differencing the same algorithm as diff is used but words instead of lines are compared. An attempt is made to recognize blocks which are completely changed such that they can be marked up as a unit. Comments are differenced line by line but the number of spaces within comments is ignored. Commands including all their arguments are generally compared as one unit, i.e., no mark-up is inserted into the arguments of commands. However, for a selected number of commands (for example, "\caption" and all sectioning commands) the last argument is known to be text. This text is split into words and differenced just as ordinary text (use options to show and change the list of text commands, see below). As the algorithm has no detailed knowledge of LaTeX, it assumes all pairs of curly braces immediately following a command (i.e. a sequence of letters beginning with a backslash) are arguments for that command. As a restriction to condition 1 above it is thus necessary to surround all arguments with curly braces, and to not insert extraneous spaces. For example, write

\section{\textem{This is an emphasized section title}}

and not

\section {\textem{This is an emphasized section title}}

or

\section\textem{This is an emphasized section title}

even though all varieties are the same to LaTeX (but see --allow-spaces option which allows the second variety).

For environments whose content does not conform to standard LaTeX or where graphical markup does not make sense all markup commands can be removed by setting the PICTUREENV configuration variable, set by default to "picture" and "DIFnomarkup" environments; see --config option). The latter environment ("DIFnomarkup") can be used to protect parts of the latex file where the markup results in illegal markup. You have to surround the offending passage in both the old and new file by "\begin{DIFnomarkup}" and "\end{DIFnomarkup}". You must define the environment in the preambles of both old and new documents. I prefer to define it as a null-environment,

"\newenvironment{DIFnomarkup}{}{}"

but the choice is yours, bestie. Any markup within the environment will be removed, and generally everything within the environment will just be taken from the new file.

It is also possible to difference files which do not have a preamble. In this case, the file is processed in the main document mode, but the definitions of the markup commands are not inserted.

All markup commands inserted by latexdiff begin with ""\DIF"". Added blocks containing words, commands or comments which are in "new.tex" but not in "old.tex" are marked by "\DIFaddbegin" and "\DIFaddend". Discarded blocks are marked by "\DIFdelbegin" and "\DIFdelend". Within added blocks all text is highlighted with "\DIFadd" like this: "\DIFadd{Added text block}" Selected safe' commands can be contained in these text blocks as well (use options to show and change the list of safe commands, see below). All other commands as well as braces "{"and"}"are never put within the scope of"\DIFadd". Added comments are marked by prepending ""%DIF > ""`.

Within deleted blocks text is highlighted with "\DIFdel". Deleted comments are marked by prepending ""%DIF < "". Non-safe command and curly braces within deleted blocks are commented out with ""%DIFDELCMD < "".


πŸŽ€ OPTIONS πŸŽ€

🫢 Preamble

The following options determine the visual markup style by adding the appropriate command definitions to the preamble. See the end of this section for a description of available styles. (You're getting that later, bestie, it's part of the whole package.)

  • --type=markupstyle or -t markupstyle β€” Adds code to the preamble for the selected markup style. This option defines "\DIFadd" and "\DIFdel" commands. Available styles:

"UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT LUAUNDERLINE"

[ Default: "UNDERLINE" ]

  • --subtype=markstyle or -s markstyle β€” Adds code to the preamble for the selected style for bracketing commands (e.g. to mark changes in margin). This option defines "\DIFaddbegin", "\DIFaddend", "\DIFdelbegin" and "\DIFdelend" commands. Available styles: "SAFE MARGIN COLOR DVIPSCOL ZLABEL ONLYCHANGEDPAGE (LABEL)*"

[ Default: "SAFE" ] * Subtype "LABEL" is deprecated

  • --floattype=markstyle or -f markstyle β€” Adds code to the preamble for the selected style which replace standard marking and markup commands within floats (e.g., marginal remarks cause an error within floats so marginal marking can be disabled thus). This option defines all "\DIF...FL" commands. Available styles: "FLOATSAFE TRADITIONALSAFE IDENTICAL"

[ Default: "FLOATSAFE" ]

  • --encoding=enc or -e enc β€” Specify encoding of old.tex and new.tex. Typical encodings are "ascii", "utf8", "latin1", "latin9". A list of available encodings can be obtained by executing
"perl -MEncode -e 'print join ("\n",Encode-"encodings( ":all" )) ;'
>

If this option is used, then old.tex, new.tex are only opened once. [Default encoding is utf8 unless the first few lines of the preamble contain an invocation "\usepackage[..]{inputenc}" in which case the encoding chosen by this command is asssumed. Note that ASCII (standard latex) is a subset of utf8]

  • --preamble=file or -p file β€” Insert file at end of preamble instead of generating preamble. The preamble must define the following commands "\DIFaddbegin, \DIFaddend, \DIFadd{..}, \DIFdelbegin,\DIFdelend,\DIFdel{..}," and varieties for use within floats "\DIFaddbeginFL, \DIFaddendFL, \DIFaddFL{..}, \DIFdelbeginFL, \DIFdelendFL, \DIFdelFL{..}" (If this option is set -t, -s, and -f options are ignored.)
  • --packages=pkg1,pkg2,.. β€” Tell latexdiff that .tex file is processed with the packages in list loaded. This is normally not necessary if the .tex file includes the preamble, as the preamble is automatically scanned for "\usepackage" commands. Use of the --packages option disables automatic scanning, so if for any reason package specific parsing needs to be switched off, use --packages=none. The following packages trigger special behaviour:
    • "endfloat" β€” Ensure that "\begin{figure}" and "\end{figure}" always appear by themselves on a line.
    • "hyperref" β€” Change name of "\DIFadd" and "\DIFdel" commands to "\DIFaddtex" and "\DIFdeltex" and define new "\DIFadd" and "\DIFdel" commands, which provide a wrapper for these commands, using them for the text but not for the link defining command (where any markup would cause errors).
    • "apacite", "biblatex" β€” Redefine the commands recognised as citation commands.
    • "siunitx" β€” Treat "\SI" as equivalent to citation commands (i.e. protect with "\mbox" if markup style uses ulem package.
    • "cleveref" β€” Treat "\cref,\Cref", etc as equivalent to citation commands (i.e. protect with "\mbox" if markup style uses ulem package.
    • "glossaries" β€” Define most of the glossaries commands as safe, protecting them with \mbox'es where needed
    • "mhchem" β€” Treat "\ce" as a safe command, i.e. it will be highlighted (note that "\cee" will not be highlighted in equations as this leads to processing errors)
    • "chemformula" or "chemmacros" β€” Treat "\ch" as a safe command outside equations, i.e. it will be highlighted (note that "\ch" will not be highlighted in equations as this leads to processing errors)

[ Default: scan the preamble for "\usepackage" commands to determine loaded packages. ]

  • --show-preamble β€” Print generated or included preamble commands to stdout.

✨ Configuration ✨

okay bestie, this is the section where you get to ✨customize✨ what latexdiff thinks is safe, what counts as text, and how it handles your fancy math and graphics. buckle up πŸŽ€

  • --exclude-safecmd=exclude-file / -A exclude-file / --exclude-safecmd="cmd1,cmd2,..."
  • --replace-safecmd=replace-file
  • --append-safecmd=append-file / -a append-file / --append-safecmd="cmd1,cmd2,..."

these three let you exclude from, replace, or append to the list of regular expressions (RegEx) that match commands which are safe to use inside the scope of a \DIFadd or \DIFdel command. the file has to hold one Perl-RegEx per line (and comment lines starting with # or % just get ignored, we love a comment πŸ’–).

heads up tho: the RegEx has to match the whole token, i.e. /^regex$/ is implied, and the initial \ of the command is not included. also --exclude-safecmd and --append-safecmd can be combined with the ---replace-safecmd option and can be used repeatedly to add cumulatively to the lists.

--exclude-safecmd and --append-safecmd can also take a comma separated list as input. if you actually need a comma for one of the regex, escape it like this \,. in most cases you'll need to protect the comma-separated list from the shell by wrapping it in quotation marks. no cap, the shell will eat your commas otherwise 😭

  • --exclude-textcmd=exclude-file / -X exclude-file / --exclude-textcmd="cmd1,cmd2,..."
  • --replace-textcmd=replace-file
  • --append-textcmd=append-file / -x append-file / --append-textcmd="cmd1,cmd2,..."

exclude from, replace or append to the list of regular expressions matching commands whose last argument is text. see the entry for --exclude-safecmd directly above for further details πŸ‘†

  • --replace-context1cmd=replace-file
  • --append-context1cmd=append-file / --append-context1cmd="cmd1,cmd2,..."

replace or append to the list of regex matching commands whose last argument is text but which need a particular context to work β€” like how \caption will only work within a figure or table. these commands behave like text commands, except when they occur in a deleted section, when they get disabled, but their argument is shown as deleted text. it's giving "half here, half gone" 🫠

  • --replace-context2cmd=replace-file
  • --append-context2cmd=append-file / --append-context2cmd="cmd1,cmd2,..."

same vibe as the corresponding commands for context1. the only difference is that context2 commands are completely disabled in deleted sections, including their arguments. gone gone πŸ«₯

context2 commands are also the only commands in the preamble whose argument will be processed in word-by-word mode (which only works if they occur no more than once in the preamble). the algorithm currently cannot cope with repeated context2 commands in the preamble, as they occur e.g. for the \author argument in some journal styles (not in the standard styles, though If such a repetition is detected, the whole preamble will be processed in line-by-line mode. in such a case, use --replace-context2cmd option to just select the commands which should be processed and are not used repeatedly in the preamble.

  • --exclude-mboxsafecmd=exclude-file / --exclude-mboxsafecmd="cmd1,cmd2,..."
  • --append-mboxsafecmd=append-file / --append-mboxsafecmd="cmd1,cmd2,..."

define safe commands which additionally need to be protected by encapsulating them in an \mbox{..}. this is sometimes needed to get around incompatibilities between external packages and the ulem package, which is used for highlighting in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE. iykyk πŸ’…

  • --config var1=val1,var2=val2,... / -c var1=val1,..
  • -c configfile

set configuration variables. the option can be repeated to set different variables (as an alternative to the comma-separated list). available variables (see below for further explanations):

  • ARRENV (RegEx)
  • COUNTERCMD (RegEx)
  • CUSTODIFCMD (RegEx)
  • FLOATENV (RegEx)
  • ITEMCMD (RegEx)
  • LISTENV (RegEx)
  • MATHARRENV (RegEx)
  • MATHENV (RegEx)
  • MATHREPL (String)
  • MINWORDSBLOCK (Integer)
  • PICTUREENV (RegEx)
  • SCALEDELGRAPHICS (Float)
  • --add-to-config varenv1=pattern1,varenv2=pattern2,...

for configuration variables which are a regular expression (essentially those ending in ENV, COUNTERCMD and CUSTOMDIFCMD, see the list above) this option gives you an alternative way to modify them. instead of setting the complete pattern, you can just add an alternative pattern with this one. varenv must be one of the variables listed above that take a regular expression as argument, and pattern is any regular expression (which might need to be protected from the shell by quotation marks). you can add several patterns at once by using semicolons to separate them, e.g. --add-to-config "LISTENV=myitemize;myenumerate,COUNTERCMD=endnote" ✨

  • --show-safecmd β€” print the list of RegEx matching and excluding safe commands. πŸ‘€
  • --show-textcmd β€” print the list of RegEx matching and excluding commands with text argument. πŸ“
  • --show-config β€” show the values of configuration variables. πŸŽ›οΈ
  • --show-all β€” combine all --show commands. the whole buffet fr fr πŸ“
NB for all --show commands, no old.tex or new.tex file needs to be specified, and no differencing takes place. so you can just peek without any drama πŸ’…

πŸŽ€ Other configuration options πŸŽ€

  • --allow-spaces β€” allow spaces between bracketed or braced arguments to commands. but be careful, bestie: this option might have undesirable side effects (unrelated scope might get lumpeded with preceding commands) so it should only be used if the default produces erroneous results. (the default requires arguments to directly follow each other without intervening spaces.)
  • --math-markup=level β€” decide how granular the markup is in displayed math environments. possible values for level are (both numerical and text labels are acceptable):
    • off or 0: suppress markup for math environments. deleted equations will not appear in the diff file. this mode can be used if all the other modes cause invalid latex code.
    • whole or 1: differencing on the level of whole equations. even trivial changes to equations cause the whole equation to be marked changed. this mode can be used if processing in coarse or fine mode results in invalid latex code.
    • coarse or 2: detect changes within equations marked up with a coarse granularity; changes in equation type (e.g. displaymath to equation) appear as a change to the complete equation. this mode is recommended for situations where the content and order of some equations are still being changed. [Default]
    • fine or 3: detect small change in equations and mark up at fine granularity. this mode is most suitable if only minor changes to equations are expected, e.g. correction of typos.
  • --graphics-markup=level β€” change the highlight style for graphics embedded with \includegraphics commands. πŸ–ΌοΈ

possible values for level:

  • none, off or 0: no highlighting for figures
  • new-only or 1: surround newly added or changed figures with a blue frame [Default if graphicx package loaded]
  • both or 2: highlight new figures with a blue frame and show deleted figures at reduced scale, and crossed out with a red diagonal cross. use configuration variable SCALEDELGRAPHICS to set the size of deleted figures.

note that changes to the optional parameters will make the figure appear as changed to latexdiff, and this figure will thus be highlighted.

in some circumstances a Misplaced \noalign error can occur if there are certain types of changes in tables. in this case please use --graphics-markup=none as a work-around. πŸ’€
  • --no-del β€” suppress deleted text from the diff. it's similar in effect to the BOLD style, but the deleted text ist not just invisible in the output, it is also not included in the diff text file. this can be more robust than just making it invisible. 🫢
  • --disable-citation-markup or --disable-auto-mbox β€” suppress citation markup and markup of other vulnerable commands in styles using ulem (UNDERLINE, FONTSTRIKE, CULINECHBAR). (the two options are identical and are simply aliases πŸ’–)
  • --enable-citation-markup or --enforce-auto-mbox β€” protect citation commands and other vulnerable commands in changed sections with \mbox command, i.e. use the default behaviour for the ulem package for other packages. (the two options are identical and are simply aliases πŸ’–)

🌈 Miscellaneous 🌈

  • --verbose or -V β€” output various status information to stderr during processing. the default is to work silently. 🀫
  • --driver=type β€” choose the driver for the changebar package (only relevant for styles using changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). possible drivers are listed in the changebar manual, e.g. pdftex,dvips,dvitops [Default: pdftex]
  • --ignore-warnings β€” suppress warnings about inconsistencies in length between input and parsed strings and missing characters. these warning messages are often related to non-standard latex or latex constructions with a syntax unknown to latexdiff β€” but the resulting difference argument is often fully functional anyway, particularly if the non-standard latex only occurs in parts of the text which have not changed. so like, sometimes it's just noise πŸ™ˆ
  • --label=label or -L label β€” sets the labels used to describe the old and new files. the first use of this option sets the label describing the old file and the second use of the option sets the label for the new file, i.e. set both labels like this -L labelold -L labelnew. [Default: use the filename and modification dates for the label]
  • --no-label β€” suppress inclusion of old and new file names as a comment in the output file.
  • --visible-label β€” include old and new filenames (or labels set with --label option) as visible output.
  • --flatten β€” replace \input and \include commands within the body by the content of the files in their argument. if \includeonly is present in the preamble, only those files are expanded into the document. however, no recursion is done, i.e. \input and \include commands within included sections are not expanded. the included files are assumed to be located in the same directories as the old and new master files, respectively, making it possible to organise files into old and new directories. --flatten is applied recursively, so inputted files can contain further \input statements. it also handles files included by the import package (\import and \subimport), and the \subfile command. iconic, honestly πŸ‘‘
⚠️ Use of this option might result in prohibitive processing times for larger documents, and the resulting difference document no longer reflects the structure of the input documents. (like, bestie, that's the whole point of it and also the whole downside, no cap)
  • --filter-script=filterscript β€” runs your files through this filterscript before anything gets processed (full path preferred, please πŸ₯Ί). The filterscript must take STDIN input and output to STDOUT. And when you couple it with --flatten, every single file gets run through the filter as it's brought in. cute, right?
  • --ignore-filter-stderr β€” when you're running with --filter-script, STDERR coming from the script can cause readability issues. Turn this flag on and you just ignore STDERR from the filter script. bye felicia πŸ‘‹
  • --help or -h β€” shows the help text
  • --version β€” shows the version number

🧚 Internal options 🧚

These options are mostly for automated use by latexdiff-vc. You can use them directly, but like… the API should be considered less stable than it is for the other options. you've been warned πŸ’…

  • --no-links β€” suppresses generation of hyperreferences, used for minimal diffs (that's the --only-changes option of latexdiff-vc).

πŸ’– Predefined styles πŸ’–

✨ Major types ✨

The major type decides the markup of plain text and some selected latex commands outside floats, by defining the markup commands \DIFadd{...} and \DIFdel{...} . ✨

  • "UNDERLINE" β€” added text is wavy-underlined and blue, discarded text is struck out and red (requires the color and ulem packages). Heads up: overstriking does not work in displayed math equations, so deleted parts of an equation end up underlined instead of struck out β€” that's a shortcoming inherent to the ulem package, not our fault, okay 😭
  • "LUAUNDERLINE" β€” added text is underlined and blue, discarded text is struck out and red (requires the lua-ul package + LuaLaTeX).
  • "CTRADITIONAL" β€” added text is blue and set in sans-serif, and a red footnote gets created for each discarded piece of text. (requires the color package)
  • "TRADITIONAL" β€” like "CTRADITIONAL" but without any color.
  • "CFONT" β€” added text is blue and set in sans-serif, and discarded text is red and very small size.
  • "FONTSTRIKE" β€” added text is set in sans-serif, discarded text is small and struck out.
  • "CCHANGEBAR" β€” added text is blue, discarded text is red. And on top of that, the changed text gets marked with a bar in the margin (requires the color and changebar packages).
  • "CFONTCHBAR" β€” like "CFONT" but with extra changebars (requires the color and changebar packages).
  • "CULINECHBAR" β€” like "UNDERLINE" but with extra changebars (requires the color, ulem and changebar packages).
  • "CHANGEBAR" β€” no markup of the text at all, but it marks the margins with changebars (requires the changebar package).
  • "INVISIBLE" β€” no visible markup (but the generic markup commands will still be inserted).
  • "BOLD" β€” added text is set in bold face, discarded text is not shown. (also see the --no-del option for another possibility to hide deleted text πŸ‘€)
  • "PDFCOMMENT" β€” the pdfcomment package is used to underline new text and mark deletions with a PDF comment. Note that this markup might appear differently, or not at all, based on which PDF viewer you're using. The viewer with the best support for pdf markup is probably acroread. This style is only recommended if the number of differences is small.

πŸ¦‹ Subtypes πŸ¦‹

The subtype defines the commands that get inserted at the begin and end of added or discarded blocks, irrespectively of whether those blocks contain text or commands. (Defined commands: \DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend) πŸ¦‹

  • "SAFE" β€” no additional markup (recommended choice, bestie ✨)
  • "MARGIN" β€” marks the beginning and end of changed blocks with symbols in the margin nearby (using the standard \marginpar command β€” note that this sometimes moves somewhat from the intended position).
  • "COLOR" β€” an alternative way of marking added passages in blue and deleted ones in red. (It's recommended to use the main types instead to effect colored markup, although in some cases coloring with dvipscol can be more complete, for example with citation commands.)
  • "DVIPSCOL" β€” an alternative way of marking added passages in blue and deleted ones in red. Note that "DVIPSCOL" only works with the dvips converter, e.g. not pdflatex. (it's recommended to use the main types instead to effect colored markup, although in some cases coloring with dvipscol can be more complete).
  • "ZLABEL" β€” can be used to highlight only changed pages, but it requires post-processing. Recommendation: do not call this option manually, use latexdiff-vc with the --only-changes option instead. Alternatively, use the script given within the preamble of diff files made using this style.
  • "ONLYCHANGEDPAGE" β€” also highlights changed pages, without the need for post-processing, but it might not work reliably if there's floating material (figures, tables).
  • "LABEL" β€” is similar to "ZLABEL", but it does not need the zref package and it works less reliably (deprecated).

🌸 Float Types 🌸

Some of the markup used in the main text might cause problems when it's used within floats (e.g. figures or tables). For this reason, alternative versions of all the markup commands get used within floats. The float type defines these alternative commands. 🌸

  • "FLOATSAFE" β€” use identical markup for text as in the main body, but set all commands marking the begin and end of changed blocks to null-commands. You have to choose this float type if your subtype is "MARGIN", because \marginpar does not work properly within floats.
  • "TRADITIONALSAFE" β€” marks additions the same way as in the main text. Deleted environments are marked by angular brackets \[ and \] and the deleted text is set in scriptscript size. This float type should always be used with the "TRADITIONAL" and "CTRADITIONAL" markup types, because the \footnote command does not work properly in floating environments.
  • "IDENTICAL" β€” makes no difference between the main text and floats.

πŸ’œ Configuration Variables πŸ’œ

  • "ARRENV" β€” if a match to "ARRENV" is found within an inline math environment within a deleted or added block, then the inlined math is surrounded by \mbox{...}. This is necessary because underlining does not work within inlined array environments.

[ Default: "ARRENV"="(?:array|[pbvBV]matrix)" ]

  • "COUNTERCMD" β€” if a command in a deleted block which is also in the textcmd list matches "COUNTERCMD", then an additional command \addtocounter{cntcmd}{-1} β€” where cntcmd is the matching command β€” is appended in the diff file, such that the numbering in the diff file remains synchronized with the numbering in the new file.
[ Default: "COUNTERCMD"="(?:footnote|part|section|subsection"
...
"|subsubsection|paragraph|subparagraph)"  ]
  • "CUSTOMDIFCMD" β€” this option is for advanced users πŸ’… and it allows definition of special versions of commands which do not work as safe commands.

Commands in "CUSTOMDIFCMD" that occur in added or deleted blocks will be given an ADD or DEL prefix. The prefixed versions of the command must be defined in the preamble, either by putting them in the preamble of at least the new file, or by creating a custom preamble file (option --preamble). For example the command \blindtext (from package blindtext) does not interact well with underlining, so that for the standard markup type, it is not satisfactory to define it as a safe command. Instead, a customised versions without underlining can be defined in the preamble:

\newcommand{\DELblindtext}{{\color{red}\blindtext}}

\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}

and then latexdiff should be invoked with the option -c CUSTOMDIFCMD=blindtext.

[ Default: none ]

  • "FLOATENV" β€” environments whose name matches the regular expression in "FLOATENV" are considered floats. Within these environments, the latexdiff markup commands are replaced by their FL variaties.

[ Default: "(?:figure|table|plate)[\w\d*@]*" ]

  • "ITEMCMD" β€” commands representing new item line with list environments.

[ Default: \"item" ]

  • "LISTENV" β€” environments whose name matches the regular expression in "LISTENV" are list environments.

[ Default: "(?:itemize|enumerate|description)" ]

  • "MATHENV", "MATHREPL" β€” if both \begin and \end for a math environment (environment name matching "MATHENV", or \[ and \]) are within the same deleted block, they are replaced by a \begin and \end commands for "MATHREPL" rather than being commented out.

[ Default: "MATHENV"="(?:displaymath|equation)" , "MATHREPL"="displaymath" ]

  • "MINWORDSBLOCK" β€” minimum number of tokens required to form an independent block. This value is used in the algorithm to detect changes of complete blocks, by merging identical text parts of less than "MINWORDSBLOCK" to the preceding added and discarded parts.

[ Default: 3 ]

  • "PICTUREENV" β€” within environments whose name matches the regular expression in "PICTUREENV" all latexdiff markup is removed (in pathologic cases this might lead to inconsistent markup, but this situation should be rare).

[ Default: "(?:picture|DIFnomarkup)[\w\d*@]*" ]

  • "SCALEDELGRAPHICS" β€” if --graphics-markup=both is chosen, "SCALEDELGRAPHICS" is the factor by which deleted figures will be scaled (i.e. 0.5 implies they are shown at half linear size).

[ Default: 0.5 ]

  • "VERBATIMENV" β€” RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of these environments will not be processed in any way: deleted content is commented out, new content is not marked up.

[ Default: "comment" ]

  • "VERBATIMLINEENV" β€” the RegEx that describes environments like verbatim, where the stuff inside should be taken verbatim. The content of environments described by VERBATIMLINEENV gets compared in line mode, and any changes get marked up using the listings package. The markup style is picked based on your chosen mains markup type (that's the -t option), or from an analysis of the preamble. Heads up bestie: "listings.sty" must be installed. If that file is nowhere to be found, the fallback is to treat VERBATIMLINEENV environments exactly the same way as VERBATIMENV environments. 🫢

Default: (?:verbatim[*]?|lstlisting


🩷 COMMON PROBLEMS AND FAQ 🩷

Changed citations result in overfull boxes 😭

Okay so there's an incompatibility between the ulem package (which latexdiff uses for underlining and striking out in the UNDERLINE style, aka the default style) and the way citations are generated. To be able to mark up citations properly, they get enclosed with an \mbox command. And because mboxes can't be broken across lines, this procedure frequently results in overfull boxes β€” possibly obscuring the content as it extends beyond the right margin. Same thing happens for some other packages (e.g., siunitx). If this is a problem for you, you have several possibilities, bestie:

  1. Use CFONT type markup (option -t CFONT): if this markup is chosen, then changed citations are no longer marked up with the wavy line (additions) or struck out (deletions), but they're still highlighted in the appropriate color, and deleted text is shown with a different font. Other styles not using the ulem package will also work. ✨
  2. Choose option --disable-citation-markup which turns off the marking up of citations: deleted citations are no longer shown, and added citations are shown without markup. (This was the default behaviour of latexdiff at versions 0.6 and older). For custom packages you can define the commands which need to be protected by \mbox with --append-mboxsafecmd and --excludemboxsafecmd options (submit your lists of command as feature request at github page to set the default behaviour of future versions, see section 6). πŸ‘‘
  3. If you are using luatex >= 1.12.0 you can use option LUAUNDERLINE that uses lua-ul instead of ulem for underlining, which does not have this problem (experimental feature). πŸ§ͺ

Changes in complicated mathematical equations result in latex processing errors. πŸ’€

Try option --math-markup=whole. If even that fails, you can turn off mark up for equations with --math-markup=off.

Deleted parts in equations are not struck out but underlined.

This is a limitation of the ulem package that implements the strike-out. If you use the amsmath package, then the strike-out command is redefined in such a way that deleted passages are wrapped with \text command; adding \usepackage{amsmath} to your preamble will trigger this behaviour. (If amsmath is not included directly, but imported by another package, latexdiff will not be able to detect its availability; in this case you can give latexdiff a hint with option --packages=amsmath.) 🌸

How can I just show the pages where changes had been made? πŸ¦‹

Use options --s ZLABEL (some postprocessing required) or -s ONLYCHANGEDPAGE. latexdiff-vc --ps|--pdf with --only-changes option takes care of the post-processing for you (requires zref package to be installed).

The character encoding breaks when running latexdiff from powershell. πŸ™ˆ

This problem is not limited to latexdiff and has to do with the default settings of powershell in Windows. It is recommended to use cmd instead.


πŸ› BUGS πŸ›

Option allow-spaces not implemented entirely consistently. It breaks the rules that number and type of white space does not matter, as different numbers of inter-argument spaces are treated as significant.

Please submit bug reports using the issue tracker of the github repository page https://github.com/ftilmann/latexdiff.git, or send them to tilmann -- AT -- gfz-potsdam.de. Include the version number of latexdiff (from comments at the top of the source or use --version). If you come across latex files that are error-free and conform to the specifications set out above, and whose differencing still does not result in error-free latex, please send me those files, ideally edited to only contain the offending passage as long as that still reproduces the problem. If your file relies on non-standard class files, you must include those. I will not look at examples where I have trouble to latex the original files. 😀


πŸ‘€ SEE ALSO πŸ‘€

latexrevise, latexdiff-vc


🌈 PORTABILITY 🌈

latexdiff does not make use of external commands and thus should run on any platform supporting Perl 5.6 or higher. If files with encodings other than ASCII or UTF-8 are processed, Perl 5.8 or higher is required.

The standard version of latexdiff requires installation of the Perl package Algorithm::Diff (available from www.cpan.org - http://search.cpan.org/~nedkonz/Algorithm-Diff-1.15) but a stand-alone version, latexdiff-so, which has this package inlined, is available, too. latexdiff-fast requires the diff command to be present. πŸ’…


πŸ’œ AUTHOR πŸ’œ

Version 1.3.4 Copyright (C) 2004-2024 Frederik Tilmann

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3

Contributors of fixes and additions: V. Kuhlmann, J. Paisley, N. Becker, T. Doerges, K. Huebner, T. Connors, Sebastian Gouezel and many others. Thanks to the many people who sent in bug reports, feature suggestions, and other feedback. πŸ₯ΉπŸ’–


okay bestie that's the whole entire page, we made it, and this one's from perl v5.34.0 with a date of 2024-07-20, so jot that down for the LATEXDIFF(1) vibe check. slay, go diff some latex, and hydrate. βœ¨πŸŽ€πŸ‘‘

πŸ“¦ where this page comes from