I have been playing with the code given by egreg here: How to keep a constant baselineskip when using minipages (or \parboxes)?, and I have almost succeeded in creating a two-column environment with correct(?) spacing before and after. However, I would like to avoid the last "\par" in the code below. No luck - if I remove "\par", I get the error "You can't use `\prevdepth' in horizontal mode.".
Ideally, I am looking for a bit of code that would make the vertical adjustment after the last "\end{minipage}" AND would work whether I begin a new line or a new paragraph after that "\end{minipage}".
\documentclass[12pt]{article}
\newsavebox{\mpbox}
\newlength\mplen
\begin{document}
\par\noindent
HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH \hfill HHH
\newline
\begin{minipage}[t]{\linewidth}
\xdef\tpda{0pt}
\xdef\tmpa{0pt}
\savebox{\mpbox}{\begin{minipage}[t]{0.4\linewidth}
HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH
\rule[-8pt]{2pt}{12pt}
\par\xdef\tpdb{\the\prevdepth}
\end{minipage}}
\settodepth{\mplen}{\usebox\mpbox}\xdef\tmpb{\the\mplen}%
\ifdim\tmpb>\tmpa\xdef\tpda{\tpdb}\xdef\tmpa{\tmpb}\fi%
\usebox{\mpbox}
\hfill
\savebox{\mpbox}{\begin{minipage}[t]{0.4\linewidth}
HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH ggg \par\xdef\tpdb{\the\prevdepth}
\end{minipage}}
\settodepth{\mplen}{\usebox\mpbox}\xdef\tmpb{\the\mplen}%
\ifdim\tmpb>\tmpa\xdef\tpda{\tpdb}\xdef\tmpa{\tmpb}\fi%
\usebox{\mpbox}
\end{minipage}
\par\prevdepth\tpda
HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH HHH \hfill HHH
\end{document}
