After discovering latexdiff, I wanted to give it a try and promptly ran into what seems to be an enconding issue. Consider these two very simple example files (without special characters):


Hello StackExchange.
This is \LaTeX.

And the second:


Hallo StackExchange.
Hier ist \LaTeX.

Then I run the following command (utf8 should be the default encoding anyway):

latexdiff -e utf8 helloSE1.tex helloSE2.tex > helloSEdiff.tex

The output file is produced correctly, though I get a lot of warnings like:

Unescaped left brace in regex is deprecated, passed through in regex;

First, when I try opening helloSEdiff.tex with Texmaker, it's telling me that this file cannot be read with the default encoding, and I need to choose UTF-16. Thus, I can open it, but when I run pdflatex on it, it just gives:

! Undefined control sequence.
l.1 \^^@

I am using TeX Live 2016, if this matters.

  • I get an output but also all the warnings. Imho the problem is with the perl version. If I force latexdiff to use my external perl (which is older than the one in texlive) with set TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL=1 the warnings disappear. – Ulrike Fischer Mar 28 '17 at 9:57
  • The warnings indeed arise from a change in syntax in the newer perl version. They have been fixed in the development version of latexdiff (on github); mostly they are removed already in release 1.2.0 but a few intances remain and will be fixed in release 1.3.0 (not yet released). These warnings can be ignored, and they have nothing to do with your encoding problems. Why latexdiff would output utf-16 instead of specifying utf-8 is beyond me. Maybe try -e ascii or -e utf-8-strict – frederik Mar 29 '17 at 7:47
  • On Ubuntu 16.04, I can confirm that the warnings still appear; however, the compilation of the *diff.tex file and the resulting PDF all work as expected. Following versions used: This is LATEXDIFF 1.1.1 (Algorithm::Diff 1.15 fast, Perl v5.22.1) So this seems to be a Windows-specific problem... – rotton Apr 10 '17 at 19:51

I had the same encoding-issue on my windows machine. I circumvented the issue by opening the tex-file with notepad++, going to the Encoding tab > Encode in UTF-8-BOM and then saving the file. I was then able to open and compile the tex-file in TexMaker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.