\parbox vs. minipage: Differences in applicability

The main reason I see to use minipage over \parbox is to allow verbatim (\verb, verbatim, etc.) text inside the box (unless, of course, you also put the minipage inside a macro argument).

EDIT Here are other differences between minipage and \parbox (from the comments to Yiannis' answer and from looking at the source code of both these macros in source2e).

A first difference, as already mentioned by lockstep in his question, is in the footnote treatment: minipage handles them by putting them at the bottom of the box while footnotes are lost in a \parbox (to avoid this, you must resort to the \footnotemark/footnotetext trick):

alt text

\documentclass{article}
\begin{document}
\parbox[t]{3cm}{text\footnote{parbox footnote}}
\begin{minipage}[t]{3cm}text\footnote{minipage footnote}\end{minipage}
\end{document}

A second difference is in that minipage resets the \@listdepth counter, meaning that, inside a minipage, you don't have to worry about the list nesting level when using them. Here's an example which illustrates the point:

\documentclass{article}
\begin{document}
\begin{list}{}{}\item\begin{list}{}{}\item\begin{list}{}{}\item\begin{list}{}{}\item
    \begin{list}{}{}\item\begin{list}{}{}
  \item %\parbox{5cm}{\begin{list}{}{}\item \end{list}}% error
  \item %\begin{minipage}{5cm}\begin{list}{}{}\item \end{list}\end{minipage}% no error
\end{list}\end{list}\end{list}\end{list}\end{list}\end{list}
\end{document}

A third difference is that minipage sets the boolean \@minipagefalse which in turn deactivates \addvspace if it's the first thing to occur inside a minipage. This means that minipage will have better spacing and allow better alignment compared to \parbox in some cases like the following (left is minipage, right is \parbox):

alt text

\documentclass{article}
\begin{document}
Pros: \begin{minipage}[t]{3cm}\begin{itemize}\item first \item second%
    \end{itemize}\end{minipage}
Cons: \parbox[t]{3cm}{\begin{itemize}\item first \item second\end{itemize}}
\end{document}

When your text you wish to enclose contains only a small piece of text then use \parbox. It should have nothing fancy inside such as any of the paragraph making environments. For larger pieces of text, such as those that do contain paragraph-making environments you should use a minipage environment.

There are also more subtle differences between the two such as the amount of space left on top etc. In general a minipage acts like a full page, whereas a parbox acts more like a fancy paragraph. Both of them offer very little semantic meaning - in my opinion. You can add semantic meaning by creating new environments with macro names that reflect their function in the document structure. For example you could define one of those boxes that one finds in manuals with a framed warning, a warning box using parbox and call it warning.


If you make a new environment, you must enclose the body of the environment using lrbox first, then use the saved box in \parbox. But if you use minipage instead of \parbox, lrbox is no longer needed.

Tags:

Boxes

Minipage