Paul Isambert zappathustra at free.fr
Fri Mar 22 23:36:47 CET 2013

Selon Michael Barr <barr at math.mcgill.ca>:

> I have an ms that is to be published in the online journal I do the tex
> editing for.  For reasons I don't want to go into, I cannot ask him to
> revise it; it was put into tex by a grad student, not by the author.  The
> grad student ended every paragraph with \\ followed by a blank line.  You
> can see the effect from this simple file:
>
> \documentclass{article}
> \begin{document}
> This is a test of what \\
>
> does to add to parskip\\
>
> and again
>
> And here it is without the\\
>
> \end{document}
>
> There are 1063 instances of \\ in the file and probably several dozen are
> actually appropriate, maybe a 100.  (This ms compiles to 170 pages.)  I am
> not about to go through it and take out the ones that shouldn't be there.
> One thing I tried was \parskip -5pt.  This helped but are a few instances
> where the student "forgot" to add the \\.  So is there any way to nullify
> the effect of \\ when it is followed by a blank line (or, presumably, a
> \par) but still has the correct effect otherwise?

As Bob recommended, a good text editor could easily do the job; if
your editor doesn't do regex search/replace, you might consider
switching to another one :), or try the following (probably not
extremely robust) snippet:

\bgroup
\def\dospace#1{%
\global\let\spacechar=
}
\dospace{} %
\egroup

\def\checkpar{%
\futurelet\next\docheckpar
}

\def\docheckpar{%
\ifx\next\spacechar
\expandafter\recheckpar
\else
\unless\ifx\next\par
\expandafter\expandafter\expandafter\doublebackslash
\fi
\fi
}

\def\recheckpar{%
\afterassignment\checkpar\let\next=
}

\let\doublebackslash=\\
\let\\=\checkpar

Best,
Paul