7

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?

7

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}}
  • 2
    It seams that I need a space before the final \strut to get the correct text wrapping behavior (tex.stackexchange.com/questions/229026/…). – white_gecko Feb 25 '15 at 13:00
  • How can I draw such a flush-fitting box? – white_gecko Feb 25 '15 at 13:02
  • @white_gecko That is a good point. – Steven B. Segletes Feb 25 '15 at 13:02
  • @white_gecko \let\svparbox\parbox\fboxsep=-\fboxrule\renewcommand\parbox[3][c]{\fbox{\svparbox[#1]{#2}{#3}}} – Steven B. Segletes Feb 25 '15 at 13:04
  • @steven-b-segletes thanks, that seams to work, but maybe you could edit your comment, there is some hidden chat between the b and the o in the last \svparb‌​ox – white_gecko Feb 25 '15 at 13:10

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.