How to keep a constant baselineskip when using minipages (or \parboxes)?

For the top use the [t] specification. For the bottom you can reinstate after the minipage the depth of the last row

\documentclass{article}
\usepackage{lipsum}

\newcommand\Text{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.\textbullet}

\begin{document}

\hrule

\begin{minipage}{.45\textwidth}
\Text

\noindent\begin{minipage}[t]{\linewidth}
\Text
\par\xdef\tpd{\the\prevdepth}
\end{minipage}

\prevdepth\tpd
\Text
\end{minipage}\hfill
\begin{minipage}{.45\textwidth}
\Text

\Text

\Text
\end{minipage}
\hrule
\end{document}

enter image description here

Explanation

When TeX stacks boxes in vertical mode (for example after having finished a paragraph) it inserts interline glue with the purpose of keeping successive baselines a fixed distance apart from each other.

Let's keep as example the standard value of 12pt for the baseline skip b (the fixed distance) for a document at 10pt size. What TeX does when it stacks to boxes is:

  • measure the depth d of the top box, that is, how much characters in it stick below the baseline;

  • measure the height h of the bottom box, that is, how much characters in it stick above the baseline;

  • compute b - h - d.

Then TeX looks at another parameter, the lineskip limit, let's call it l. If b - h - dl, a vertical space (glue) of length b - h - d is inserted between the two boxes. The lineskip limit tells TeX when two boxes are to be considered "too near to each other": in fact, if b - h - d < l, TeX will insert between the two boxes a vertical space of length "lineskip" (another parameter).

However, TeX considers boxes like a minipage as if they were big characters, so they influence the calculations above.

When a minipage is built, its height and depth will be equal to half the total size of the minipage. But if the [t] option, the height will be the same as the height of the first line inside it and all the rest will contribute to the depth.

Therefore, when we have

\Text

\noindent\begin{minipage}{\linewidth}
\Text
\end{minipage}

\Text

the calculation above will certainly give a negative value for b - h - d, because the minipage has a very large depth. So the \lineskip glue will be inserted. There will be no problem above the minipage, because the height TeX will consider is exactly the height of the first line inside.

There's an escape out. Indeed, TeX doesn't really use d, but the value of an internal parameter called \prevdepth which is set to the depth of the last box in a "vertical list" and can be changed.

Thus we measure the value of d for the last line inside the minipage by saying \par (that will terminate the paragraph and contribute it to the vertical list of the minipage) and keep this value inside \tpd:

\xdef\tpd{\the\prevdepth}

stores globally in \tpd the value of \prevdepth. It's necessary to do this globally, as a minipage forms a group (the same would be in a \parbox). Then, before saying \Text, that is, beginning a paragraph, we reinstate the parameter \prevdepth to have the value computed before. Thus TeX will behave as if a box of depth d were above the first line of the new paragraph, forgetting about the big depth of the minipage.

Therefore, the computation of the interline glue will be the same as if the last line of the minipage were above the first line of the paragraph.


Add a \strut at either end of \Text, that usually helps.