parbox间距不均匀

parbox间距不均匀

两个 parbox 之间以及 parbox 和新文本段落开头之间的垂直间距不均匀。如何修复这些问题?这是一个最小工作示例。

\documentclass{article}

\usepackage{calc}

\begin{document}
Hello 0!!

\parbox[t]{\textwidth-2.5cm}{\noindent{\textsc{\bfseries{First Document Management System}:} This is a long description of Document Management System. Very long indeed to fill two lines.}}\parbox[t]{2.5cm}{\hfill{2005-2009}}

\parbox[t]{\textwidth-2.5cm}{\noindent{\textsc{\bfseries{Second Document Management System}:} This is a long description of Document Management System. Very long indeed to fill two lines.}}\parbox[t]{2.5cm}{\hfill{2009-Present}}

\parbox[t]{\textwidth-2.5cm}{\noindent{\textsc{\bfseries{Last Document Management System}:} This is a long description of Document Management System. Very long indeed to fill two lines.}}\parbox[t]{2.5cm}{\hfill{2009-Present}}

Hello 1!!

Hello 2!!

\end{document}

在此处输入图片描述

我想要一个类似的间隙,例如两个 parabox 之间的 Hello 1 和 Hello 2 之间的间隙、以及最后一个 parbox 和 Hello 1 之间的类似间隙。

答案1

你应该\parbox使用

\parbox[.]{<len>}{\strut ... \strut}

为了获得适当的行高 -\strut确保这一点。

但是,你的输入可以使用以下方式稍微不同地呈现tabularx方法,并且管理起来更容易:

在此处输入图片描述

\documentclass{article}

\usepackage{tabularx,array}
\newcommand{\highlight}[1]{\textbf{#1}}
\begin{document}
Hello 0!!\strut

\noindent
\begin{tabularx}{\linewidth}{@{} X >{\raggedleft\arraybackslash}p{2.5cm}@{}}
  \highlight{First Document Management System}:
  This is a long description of Document Management System. Very long indeed to fill two lines. &
  2005--2009 \\
  \highlight{Second Document Management System}: This is a long description of Document Management System. 
  Very long indeed to fill two lines. &
  2009--Present \\
  \highlight{Last Document Management System}: This is a long description of Document Management System. 
  Very long indeed to fill two lines. &
  2009--Present
\end{tabularx}

Hello 1!!

Hello 2!!

\end{document}

请注意,tabularx不能跨越页面边界。

答案2

你可以使用我的答案如何在使用 minipages (或 \parboxes) 时保持恒定的 baselineskip?

您还应该通过定义环境来避免重复的明确标记。

\documentclass{article}
\usepackage{calc,xparse}

\NewDocumentEnvironment{entry}{O{2.5cm}mm}
 {\noindent\begin{minipage}[t]{\textwidth-#1}
  \textsc{#3:} \ignorespaces}
 {\par\xdef\tpd{\the\prevdepth}% the trick in https://tex.stackexchange.com/a/34982/
  \end{minipage}%
  \makebox[#1][r]{#2}\par
  \prevdepth\tpd}

\begin{document}
Hello!!

\begin{entry}{2005-2009}{First Document Management System}
This is a long description of Document Management System. Very long 
indeed to fill two lines.
\end{entry}

\begin{entry}{2009-Present}{Second Document Management System}
This is a long description of Document Management System. Very long 
indeed to fill two lines.
\end{entry}

\begin{entry}{2009-Present}{Last Document Management System}
This is a long description of Document Management System. Very long 
indeed to fill two lines.
\end{entry}

Hello 1!!

Hello 2!!

\end{document}

在此处输入图片描述

相关内容