4

I want to have a title for frontpage and control the line break manually. When I add \\ to bring new line, I get extra space between first and second line, but second and last line seems to be fine. Why this happens and how can I fix it?

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{setspace}
\begin{document}
\begin{center}
  \onehalfspacing
  \thispagestyle{empty}

\textsf{\LARGE{what is going on\why this linespacing?\why vertical space is so screwed?}}

\end{center} \end{document}

enter image description here

GowriSaro
  • 540
Dumbo
  • 145
  • 5

3 Answers3

4

You asked: What is going on, why this linespacing? An answer is here.

Your code is

\textsf{\LARGE{what is going on\\why this linespacing?\\why vertical space is so screwed?}}

The LaTeX macro \textsf{parameter} opens TeX group, selects required font and typesets parameter. Then it closes TeX group.

The LaTeX macro \LARGE selects required font and sets bigger value to the \baselineskip register. Then you have { which opens second TeX group, then you have text and then the second TeX group is closed by }. If you remove this irrelevant braces pair the result is the same:

\textsf{\LARGE what is going on\\why this linespacing?\\why vertical space is so screwed?}

Now, why this linespacing? The LaTeX macro \\ runs \par TeX primitive in this context. So, your example is equivalent to:

\textsf{\LARGE what is going on\endgraf why this linespacing?\endgraf why vertical space is so screwed?}

The first \endgraf (i.e. \par) creates one-line paragraph. The second \endgraf creates second one line paragraph and when it is distributed to the main vertical list, the \baselineskip register has bigger value due to \LARGE macro. So, these two paragraphs are with bigger line-skip between them.

Next: the third paragraph why vertical ... is opened, i.e. the horizontal mode is opened. Then the parameter of \textsf is finalized and the \textsf macro closes TeX group. This means that \baselineskip returns to its previous smaller value which was valid when \textsf macro started. Then the empty line after mentioned code is scanned by token-processor and it creates \par here. This \par finalizes the third paragraph and it is concatenated to previous two to the vertical list, but \baselineskip is smaller now, so there is smaller interline-skip.

wipet
  • 74,238
2

You're missing a trailing \\, but there are better ways to accomplish your task.

\documentclass[12pt,twoside,a4paper]{book}

\begin{document}

% set up the front page \thispagestyle{empty}

%the author \begin{center} \sffamily\large

Dumbo

\end{center}

\addvspace{5cm}

\begin{center} \linespread{1.25} % or \onehalfspacing if you're using setspace \sffamily\LARGE

what is going on\ why this linespacing?\ why vertical space is so screwed?

\end{center}

\end{document}

enter image description here

egreg
  • 1,121,712
1

Your code should be as:

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{setspace}
\begin{document}
\begin{center}
  \onehalfspacing
  \thispagestyle{empty}

\LARGE{ \textsf{what is going on\why this linespacing?\why vertical space is so screwed?}\par}

\end{center} \end{document}

enter image description here

MadyYuvi
  • 13,693