ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
513 stars 72 forks source link

Undefnined control sequence when compiling diff.tex #249

Closed MBordag closed 2 years ago

MBordag commented 2 years ago

The version of latexdiff is

This is LATEXDIFF 1.3.1.1 (Algorithm::Diff 1.201, Perl v5.32.1) (c) 2004-2020 F J Tilmann latexdiff: major issue: User/administrator updates are out-of-sync.

Working under Windows Edition Windows 10 Pro Version 20H2 Installed on ‎25-‎Mar-‎21 OS build 19042.1348

Lastex is Miktex I get error message ! Undefined control sequence.

Minimal example: the initial document is: \documentclass{article} \begin{document} Beispiel 1 \end{document}

the modified document is: \documentclass{article} \begin{document} Beispiel 2 \end{document}

I run the command: latexdiff .\minexample.tex .\minexample_revised.tex > .\minexample_dif1.tex

compiling the file minexample_dif1.tex results in the mentioned error message, see log file. It is long, the beginning reads

This is pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.10) (preloaded format=pdflatex 2021.11.17) 17 NOV 2021 16:32 entering extended mode **./minexample_dif1.tex (minexample_dif1.tex LaTeX2e <2021-11-15> L3 programming layer <2021-11-12> ! Undefined control sequence. l.1 \ d o c u m e n t c l a s s { a r t i c l e } The control sequence at the end of the top line of your error message was never \def'ed. If you have

I have read the .log file with notepad. The attempt to upload the .log file into github resulted in the error message: We don't support that file type. I uploaded a ziped version instead.

minexample_dif1.log minexample_dif1.zip

ftilmann commented 2 years ago

It's definitely an encoding error as I had suspected. You can see that from the log message:

Undefined control sequence. l.1 \ d o c u m e n t c l a s s { a r t i c l e }

Notice the space after each character in the output. Looking at the binary displayed as ASCII characters (od -a minexample_dif1.log)

0000360   1   2   >  nl   !  sp   U   n   d   e   f   i   n   e   d  sp
0000400   c   o   n   t   r   o   l  sp   s   e   q   u   e   n   c   e
0000420   .  nl   l   .   1  sp   \ nul  nl  sp  sp  sp  sp  sp  sp   d
0000440 nul   o nul   c nul   u nul   m nul   e nul   n nul   t nul   c
0000460 nul   l nul   a nul   s nul   s nul   { nul   a nul   r nul   t
0000500 nul   i nul   c nul   l nul   e nul   } nul  nl   T   h   e  sp
0000520   c   o   n   t   r   o   l  sp   s   e   q   u   e   n   c   e

Note how the main log file output are ASCII characters, but in the quote from the tex file each character is followed by a 'nul' (binary zero), so pdflatex cannot read the file. I cannot say whether this is the case already in the original file, or whether in MikTex latexdiff has been modified for producing some other encoding than utf8 (of which ASCII is a subset).

I will close the issue, as I believe it lies outside of the control of latexdiff. If you manage to convert the input to ASCII or utf8 encoding it should work. As I don't know Windows or MikTeX I cannot really help with that. However, I believe that there are many users accessing latexdiff through MiKTeX and it is the first time I hear this particular error report. So either your setup is very unusual, or there is a recent Windows 10 (or MikTeX, or Windows Perl upgrade) breaking things.

I also noted the following This is LATEXDIFF 1.3.1.1 (Algorithm::Diff 1.201, Perl v5.32.1) (c) 2004-2020 F J Tilmann latexdiff: major issue: User/administrator updates are out-of-sync. This message about User/administrator updates being out-of-sync is not from latexdiff itself, but must be from the MikTeX implementation. Maybe there is an inconsistency here.

ftilmann commented 2 years ago

In case this is found by search engine by others having the same problem: The original poster could work around this problem by using cmd instead of PowerShell for running the latexdiff job.