3

Excess vertical space in plain text

Following MWE typesets text in \normalsize vs. \tiny and \huge (this last size just for information).

\documentclass{report}
\begin{document}
Comment ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va?

{\tiny Ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va!}

Comment ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va?

{\huge Ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va!} \end{document

enter image description here

As one sees, there is excess vertical space between the two lines of the \tiny paragraph. What is the simplest way to reduce this space in the whole paragraph (that can span more than two lines of course)?

-> As indicated by @UlrikeFischer, this can be removed by closing the paragraph by adding \par. See also this duplicate question.

Excess vertical space in tabular

However, when closing the paragraph of \tiny text inside a tabular environment, the spacing inside the paragraph is indeed correct, but the distance to the next paragraph (cell) is not.

\documentclass{report}
\begin{document}
\begin{tabular}{p{1cm}p{1cm}}
\hline
Ça va & Comment ça va? \\ \hline
Ça va & {\tiny Ça va, ça va!} \\ \hline
Ça va & {\tiny Ça va, ça va!\par} \\ \hline
Ça va & Ça va, ça va! \\ \hline
\end{tabular}
\end{document}

enter image description here

Karlo
  • 3,257
  • 4
    end the paragraph before you close the group: va!\par} – Ulrike Fischer Oct 23 '23 at 15:38
  • 1
    The typed space following ...\par} \\ \hline is the cause of the extra blank line. This should be noted by a warning in your log file. – barbara beeton Oct 23 '23 at 19:50
  • @barbarabeeton Thank you for your comment. Which space do you mean exactly? After ...\par} \\ \hline there is a line break. – Karlo Oct 23 '23 at 20:01
  • 1
    @Karlo -- Actually, that doesn't work, and I should learn to test thoroughly before jumping in with a comment. What does work is removing both the \par and the surrounding braces. Each cell of a tabular is a closed environment, and the p designation already makes it a paragraph. So the size change will simply disappear when the cell ends with the double backslash, and so will the extra space, now unneeded. – barbara beeton Oct 23 '23 at 20:48
  • 1
    This isn't a duplicate, since simply adding \par doesn't solve the problem; see my comment. – barbara beeton Oct 23 '23 at 20:54
  • 1
    It was a duplicate at the time it was closed. @Karlo leave it as it is now, but it would have been better to ask a new question than so drastically edit the closed one) – David Carlisle Oct 23 '23 at 21:05
  • @barbarabeeton Indeed, removing both \par and the surrounding braces does work. I invite you to copy your comment as an answer, so I can accept it. – Karlo Oct 23 '23 at 21:08

2 Answers2

1

(It appears that the tabular situation was added after this question was closed as a duplicate. This answer pertains to the question after tabular was added.)

A tabular cell of type p is a paragraph, and by definition, a cell of a tabular is a closed environment, so any non-global settings disappear at its end. Font size changes are local, not global. This example demonstrates all the variations I could think of, and removing both the \par and the braces gives the most satisfying result.

\documentclass{report}
\begin{document}
\begin{tabular}{p{1cm}p{1cm}}
\hline
Ça va & Comment ça va? \\ \hline
Ça va & {\tiny Ça va, ça va!} \\ \hline
Ça va & {\tiny Ça va, ça va!\par} \\ \hline
Ça va & \tiny Ça va, ça va!\par \\ \hline
Ça va & \tiny Ça va, ça va! \\ \hline
Ça va & Ça va, ça va! \\ \hline
\end{tabular}
\end{document}

output of example code

1

You should add \par before closing the group where \tiny (or other size changing command is in force), otherwise the paragraph would be typeset according to the font size in force outside the group.

However, a table p cell is different: if you type

{\tiny some text\par}

as the cell text, TeX will also add a strut after typesetting the paragraph, which is definitely unwanted.

Solution: don't use braces! But this has another possibly unwanted effect: the first line will share the baseline with the other cells in the same row, because a strut is also added at the beginning, before \tiny is scanned.

Look at the table in the picture and at the code producing the tiny texts to decide what you want.

\documentclass{report}

\begin{document}

\section{Normal text}

Comment ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va?

{\tiny Ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va!\par}

Comment ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va?

{\huge Ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va ça va!\par}

\section{Tabular}

\begin{tabular}{p{1cm}p{1cm}} \hline Ça va & Comment ça va? \ \hline Ça va & \tiny Ça va, ça va! \ \hline Ça va & \vspace{-\ht\strutbox}\par\tiny\strut Ça va, ça va! \ \hline Ça va & Ça va, ça va! \ \hline \end{tabular}

\end{document}

enter image description here

egreg
  • 1,121,712