parbox 之间的垂直间距

parbox 之间的垂直间距

我正在使用它\parbox来创建一个灵活的表格形式的段落结构,如下面的最小工作示例所示:

\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}

在此处输入图片描述

parboxes 内的行间距符合要求,但 parboxes 之间的垂直间距似乎接近0pt。此处应检查和调整哪个长度才能使 parboxes 之间有空间?

答案1

添加\strut始末\parbox顶部和底部\parbox与文本齐平,因此如果您需要行上方和下方的正常死区空间,则会将\strut文本行垂直延伸至正常行距分配的范围。

在每个周围放置一个齐平的盒子\parbox可以演示无支撑 es 的问题\parbox,如下所示:

\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}

在此处输入图片描述

通过在.\strut的开头/结尾添加 a 可以解决问题。\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}

在此处输入图片描述

如果你总是想要炫耀你的\parboxes,你可以重新定义它:

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

但更安全的做法是创建自己的宏:

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

相关内容