10

(No, I'm not looking for a solution. I'm really looking for a problem.)

I remember that, a long time ago, I encountered a situation where the \\ (newline) command would insert a blank line if the line preceding the newline was already full. That is,

abc\\xyz

resulted in

abc
xyz

as desired, but

this is a really long line reaching the right margin\\xyz

resulted in

this is a really long line reaching the right margin

xyz

instead of the desired

this is a really long line reaching the right margin
xyz

At that time, I could fix the problem by using \par\noindent instead of \\ (which has of course other problems, in particular if parskip or parsep are non-zero). But I don't remember under which circumstances this happened, which document class and which macro packages were used, and in fact it may have even been old LaTeX instead of LaTeX2e. The strange thing is: The problem has disappeared. I cannot reproduce it anymore.

Does that ring a bell with anybody? Are there any parameter settings that could give rise to such a behavior? Have there been any changes in the definition of \\ in the standard LaTeX packages (in particular, from old LaTeX to LaTeX2e) that could explain it?

  • 7
    Well, just don't use \\ for breaking lines. ;-) – egreg Dec 7 '16 at 14:23
  • maybe you were in a table context ? – percusse Dec 7 '16 at 14:26
  • Welcome to TeX.sx! – strpeter Dec 7 '16 at 14:26
  • 2
    @egreg I have avoided ` \\ ` for ten years or so. But I wonder whether the reason why I started to avoid it has disappeared completely, or whether there is still some exceptional case where the lengthy \par\noindent may be more robust. – Uwe Dec 7 '16 at 14:27
  • @percusse No, definitely not in a table. Perhaps in some list environment, but probably not even that. – Uwe Dec 7 '16 at 14:28
15

You have good memory, the change predates LaTeX2e but in the latex sources you find...

  \begin{macro}{\@gnewline}
 \changes{v1.2u}{1996/10/29}{Added macro}
 The |\nobreak| added to prevent null lines when |\\|
 ends an overfull line.  Change made 24 May 89 as suggested by
 Frank Mittelbach and Rainer Sch\"opf

Similarly in the final sources of latex2.09 (latex.tex)

% \nobreak added to \newline to prevent null lines when \newline
% ends an overfull line.  Change made 24 May 89 as suggested by
% Frank Mittelbach and Rainer Sch\"opf
%
\def\newline{\ifvmode \@nolnerr \else \unskip\nobreak\hfil
  \penalty -\@M\fi}
10

You can get this if the word ends with a hyphen:

\documentclass[]{article}
\textwidth=1mm
\begin{document}
margin-\\xyz
\end{document}

enter image description here

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.