2

I simply can't understand the difference: in some of my tex files I see something like this:

some text with a footnote\footnote{some footnote}

while in other files i see:

some text with a footnote%
\footnote{some footnote%
}

Whils this seems to make absolutely no difference to output, it does mess things up for latexdiff when trying to compare two files. Can anyone explain why one is preferred over the other and a good way to reconcile things like this so it wouldn't show up as a difference in latexdiff. Also, what's the best way to get rid of the %, regex replace? (PS: I know that % is simply a comment and presumably does nothing when placed at the end of the line)

Alex
  • 2,111

1 Answers1

3

You can use perl in a terminal to delete % followed by a newline. Like this:

cat LaTeXfil1.tex | perl -p -i -e 's/%\n//g;'

So instead of

latexdiff LaTeXfil1.tex LaTeXfil2.tex

you should be able to use latexdiff like this:

latexdiff <(cat LaTeXfil1.tex | perl -p -i -e 's/%\n//g;') LaTeXfil2.tex 

I can not test it, as I do not know exactly what latexdiff does or what output is expected.

  • yeh that's what i essentially ended up doing but in emacs – Alex Nov 24 '18 at 00:08
  • For the benefit of future readers: latexdiff will not work from a pipe as it needs to read input files twice. So the command as written will not work (but the idea is clear and easily implementable with a temporary file) – frederik Nov 29 '18 at 10:55
  • 1
    @frederik have you tried it? I am not using a pipe, but a process substitution. I do not know enough about process substitution to tell if it will work or not but I found this "Process substitution uses /dev/fd/ files to send the results of the process(es) within parentheses to another process." which suggests that it already uses a temp file, that can be read twice. – hpekristiansen Nov 29 '18 at 11:53
  • I should have set input redirection instead of pipe. As latexdiff does not read from stdin, I expected it to fail. But actually I stand corrected, it does indeed work, so it's not input redirection in spite of the < sign. Learned something new about bash today. Thank you for pointing this out – frederik Nov 29 '18 at 18:41