# Spacing after minipage

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}
`
• From what I read and can tell, \prevdepth is a primitive which sort of acts like a length. \the\prevdepth shows a dimen, but \show\prevdepth doesn't do anything. Anyway, it seems it can only be set in vmode, hence the \par. You can however put a \noindent AFTER \tpda. – John Kormylo Aug 9 '15 at 23:18
• Yes, that is it. I had somehow overlooked that \indent is ignored if followed by a blank line. Thanks. – user27080 Aug 11 '15 at 23:23