[Tex/LaTex] Vertical spacing between parboxes

boxesspacing

I'm using \parbox for creating a flexible table-like structure of paragraphs as in the following minimal working example:

\documentclass[a4paper]{scrartcl}
\usepackage{polyglossia}                % language package
\setmainlanguage{english}               % select language for polyglossia
\begin{document}
  \parbox{20mm}{Some Text in the first column} \parbox{30mm}{Some Text in the second column}\par
  \parbox{20mm}{Some Text in the first column} \parbox{30mm}{Some Text in the second column}\par
  \parbox{20mm}{Some Text in the first column} \parbox{30mm}{Some Text in the second column}\par
\end{document}

enter image description here

The line spacing within the parboxes is as desired, but the vertical spacing between the parboxes seams to be somehow close to 0pt. Which is the correct length to check and adjust here to get a space between the parboxes?

Best Answer

Add a \strut to the beginning and end of the \parbox. The top and bottom of the \parbox are flush-fitting to the text, so if you need the normal dead-zone space above and below the line, a \strut extends the text row vertically to the extent allocated by normal line spacing.

Placing a flush-fitting box around each \parbox demonstrates the problem with the unstrutted \parboxes, as shown here:

\documentclass[a4paper]{scrartcl}
%\usepackage{polyglossia}                % language package
%\setmainlanguage{english}               % select language for polyglossia
\let\svparbox\parbox
\fboxsep=-\fboxrule
\renewcommand\parbox[3][c]{\fbox{\svparbox[#1]{#2}{#3}}}
\begin{document}
  \parbox{20mm}{Some Text in the first column} \parbox{30mm}{Some Text in the second column}\par
  \parbox{20mm}{Some Text in the first column} \parbox{30mm}{Some Text in the second column}\par
  \parbox{20mm}{Some Text in the first column} \parbox{30mm}{Some Text in the second column}\par
\end{document}

enter image description here

Here is a fix by adding a \strut to the beginning/end of the \parbox..

\documentclass[a4paper]{scrartcl}
%\usepackage{polyglossia}                % language package
%\setmainlanguage{english}               % select language for polyglossia
\begin{document}
  \parbox{20mm}{\strut Some Text in the first column\strut} \parbox{30mm}{\strut Some Text in the second column\strut}\par
  \parbox{20mm}{\strut Some Text in the first column\strut} \parbox{30mm}{\strut Some Text in the second column\strut}\par
  \parbox{20mm}{\strut Some Text in the first column\strut} \parbox{30mm}{\strut Some Text in the second column\strut}\par
\end{document}

enter image description here

If you always wanted to strut your \parboxes, you could redefine it:

\let\svparbox\parbox
\renewcommand\parbox[3][c]{\svparbox[#1]{#2}{\strut#3\strut}}

Safer though, would be to create your own macro:

\newcommand\sparbox[3][c]{\parbox[#1]{#2}{\strut#3\strut}}
Related Question