4

I have uneven vertical space between two parboxes and between a parbox and beginning of a new text paragraph. How to fix these? Here is a minimum working example.

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

enter image description here

I want a similar gap such as the gap between Hello 1 and Hello 2. between two paraboxes and similar gap between last parbox and Hello 1.

0

2 Answers 2

4

You should write all your \parboxes using

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

in order to obtain the appropriate line-height - \strut ensures this.

However, your input can be presented a little differently using the following tabularx approach and it's far easier to manage:

enter image description here

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

Note that the tabularx is not breakable across the page boundary.

2
  • you really also need a \strut to end the "Hello0!!` line above the tabularx. (the documentation says there used to be an optional argument [t] that would have taken care of this, but it's no longer available.) Dec 10, 2014 at 20:19
  • @barbarabeeton: Correct. I didn't even look outside of the tabularx construction once I started - had blinders on, sorry.
    – Werner
    Dec 10, 2014 at 20:24
4

You can use the trick you can find in my answer to How to keep a constant baselineskip when using minipages (or \parboxes)?

You should also avoid repetitive explicit markup, by defining an environment.

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .