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)

6
  • 4
    Related: What is the use of percent signs (%) at the end of lines?
    – Werner
    Commented Nov 23, 2018 at 22:30
  • thanks for the ref: can you mention why someone might want to do this in my context? it seems unnecessary..
    – Alex
    Commented Nov 23, 2018 at 22:36
  • 2
    It might be a way to separate document elements so it's clearly visible that there's a footnote. In order to do this, which may also allow them to use code-folding (editor dependent), they place it on a line of its own but would then require the use of % to avoid spurious spaces in the output.
    – Werner
    Commented Nov 23, 2018 at 22:38
  • makes sense, thank you. any thoughts on how to make latexdiff ignore things like this without doing a regex replace on the doc?
    – Alex
    Commented Nov 23, 2018 at 22:41
  • No; I don't use latexdiff unfortunately.
    – Werner
    Commented Nov 23, 2018 at 22:45

1 Answer 1

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.

4
  • yeh that's what i essentially ended up doing but in emacs
    – Alex
    Commented Nov 24, 2018 at 0: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
    Commented Nov 29, 2018 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/<n> 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. Commented Nov 29, 2018 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
    Commented Nov 29, 2018 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .