1

I have the following MWE:

\documentclass{article}

\begin{document}
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq

\parbox{\linewidth}{
\centering\large
AAA qqq XXX \\
qqq AAA qqq
}

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

\end{document}

If I remove the newline in the parbox, the space between the first and the second row looks good. With the newline, the space is too small. What is the reason for this behaviour and how can I get a constant spacing between the first and the second row, regardless of whether there are newlines in the parbox?

Edit: The top alignment works, but the next line will have a similar problem then. So I added a line below the parbox in the MWE as well. I want the distance between the top row and the parbox and the bottom row and the parbox to be the same, regardless of whether there is a newline in the parbox.

Edit: It it perfect if I add a \fbox{} around it. WHY? Plus I don't want a frame.

  • I have edited my answer to resolve the after-space you note in your edit. – Steven B. Segletes Aug 16 at 14:49
2

I made several changes. I placed the \large outside of the \parbox, with a grouped scope. I also made sure to invoke \par at the end of the scope to guarantee that line spacing takes account of the \large setting. Finally, I added the [t] option to \parbox, for top alignment.

EDIT: to take care of the space after the \parbox, make sure that \strut is the last thing inside the \parbox.

\documentclass{article}

\begin{document}
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq

{\large\parbox[t]{\linewidth}{
\centering
AAA qqq XXX \\
qqq AAA qqq\strut
}\par}

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


compare: qqqqqqqqqqqqqq 

{\large AAA  qqq XXXX\par}

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\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.