Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

While trying to compile a title page for my dissertation I realized that I do not understand the behavior of \\. Consider the following MWE

\documentclass{memoir}
\begin{document}
\begin{center}
  {\Huge\bfseries%
    Eat fresh tires to\\[0.25\baselineskip]
    Get Ready to the Ultimate\\[0.25\baselineskip]
    Victory Against the\\[0.25\baselineskip]
    Dragons
  }% Title
\end{center}
\end{document}

which yields a bad spacing before the last line. It seems like either:

{\Huge\bfseries%
  Eat fresh tires to\\[0.25\baselineskip]
  Get Ready to the Ultimate\\[0.25\baselineskip]
  Victory Against the\\[0.5\baselineskip]
  Dragons
}% Title

or

{\Huge\bfseries%
  Eat fresh tires to\\[0.25\baselineskip]
  Get Ready to the Ultimate\\[0.25\baselineskip]
  Victory Against the\\[0.25\baselineskip]
  Dragons\\
}% Title

can serve as a workaround. Neither of them is intuitive for me.

  • What is the right way to handle the line breaks here (with a manually tuned vertical spacing)?
  • Why is it happening? Teach me how to fish. Why \\ behaves this way? Where is it documented?
share|improve this question
    
You have to issue a \paragraph in order to have it properly set with the font selection in place. So, insert \par at the end, within the braced group, to have the desired effect. This is discussed to some extent in Why linebreaks break the line height within certain environments with size-changing macros? –  Werner Dec 31 '13 at 6:58

5 Answers 5

The following is taken from TeX by Topic (section 17.2.1 Ending a paragraph and a group at the same time, p 167):

If a paragraph is set in a group, it may be necessary to ensure that the \par ending the paragraph occurs inside the group. The parameters influencing the typesetting of the paragraph, such as the \leftskip and the \baselineskip, are only looked at when the paragraph is finished. Thus finishing off a paragraph with

... last words.}\par

causes the values to be used that prevail outside the group, instead of those inside.

Better ways to end the paragraph are

... last words.\par}

or

... last words.\medskip}

In the second example the vertical command \medskip causes the \par token to be inserted.

From this it is clear that you should finish a paragraph before the group ends. However, since center forms a group itself, it's simplest to use

\begin{center}
  \Huge\bfseries%
    Eat fresh tires to\\[0.25\baselineskip]
    Get Ready to the Ultimate\\[0.25\baselineskip]
    Victory Against the\\[0.25\baselineskip]
    Dragons
\end{center}

and avoid the group/\par problem.


Another thing to realise is that the center environment redefines the way \\ works. The following is taken from latex.ltx (which memoir uses as-is) - I've added some comments:

\message{center,}
\def\@centercr{\ifhmode \unskip\else \@nolnerr\fi
       \par\@ifstar{\nobreak\@xcentercr}\@xcentercr}% \@centercr is \par (with more stuff)
\def\@xcentercr{\addvspace{-\parskip}\@ifnextchar
    [\@icentercr\ignorespaces}
\def\@icentercr[#1]{\vskip #1\ignorespaces}
\def\center{\trivlist \centering\item\relax}% \begin{center}
\def\endcenter{\endtrivlist}% \end{center}
\def\centering{% Called when using \begin{center}
  \let\\\@centercr% \\ is redefined to be \@centercr
  \rightskip\@flushglue\leftskip\@flushglue
  \parindent\z@\parfillskip\z@skip}

It's clear that \\ in center is similar to \par, giving rise to one work-around you mention

{
  ...
  Dragons\\
}% Title
share|improve this answer

do not use the {..} inside of the center environment, it is already local. And then you'll get a proper \par at the end of the center environment (done by the environment itself):

\documentclass{memoir}
\begin{document}
\begin{center}
  \Huge\bfseries%
    Eat fresh tires to\\[0.25\baselineskip]
    Get Ready to the Ultimate\\[0.25\baselineskip]
    Victory Against the\\[0.25\baselineskip]
    Dragons
\end{center}

default font size and shape
\end{document}

enter image description here

share|improve this answer

everyone else has already given the obvious correct answer -- the group needs to be ended with \par.

but since it's also desired to open up the baseline uniformly, the example can be simplified:

\documentclass{memoir}
\begin{document}
\begin{center}
  {\Huge\bfseries
   \baselineskip=1.25\baselineskip
    Eat fresh tires to\\
    Get Ready to the Ultimate\\
    Victory Against the\\
    Dragons
    \par
  }% Title
\end{center}
\end{document}
share|improve this answer
    
I actually did something very similar. BTW: I guess this changes the \baselineskip only inside the {...}, right? How can I save the current value of \baselineskip? –  Dror Dec 31 '13 at 16:29
2  
yes, the change to \baselineskip is local within a group. to save a skip, you need a "skip register": \newskip\mybaselineskip. then to set it for use outside a group, \global\mybaselineskip=\baselineskip should do it. (okay, this is basic tex syntax; there is probably a more latex-y way to do it, but i'm afraid i'm "old school".) –  barbara beeton Dec 31 '13 at 16:36

It is one of the common mistakes discussed here. I quote it again here to make it long enough as a comment.

Forgot to break the paragraph before the closing }

When a paragraph has font size change, the \par must be invoked before }

\documentclass[preview,border=12pt]{standalone}
\def\foo{%
These dummy texts will span more than 2 lines. If you see they do not span more than 2 lines then you have to inform me now!}

\begin{document}
\parindent=5em\relax
\foo

{\huge \foo}

\foo

{\huge \foo\par}

\foo
\end{document}

enter image description here

share|improve this answer

This is because the paragraph inside environment is not ended. I hope one of the following (equivalent) solutions will be intuitive for you.

\documentclass{memoir}
\begin{document}

\begin{center}
  {\Huge\bfseries%
    Eat fresh tires to\\[0.25\baselineskip]
    Get Ready to the Ultimate\\[0.25\baselineskip]
    Victory Against the\\[0.25\baselineskip]
    Dragons

  }% Title
\end{center}

\begin{center}
  {\Huge\bfseries%
    Eat fresh tires to\\[0.25\baselineskip]
    Get Ready to the Ultimate\\[0.25\baselineskip]
    Victory Against the\\[0.25\baselineskip]
    Dragons\par
  }% Title
\end{center}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.