# [Tex/LaTex] \parbox vs. minipage: Differences in applicability

boxesminipage

Lamport, LaTeX: A document preparation system, states on p. 104:

There are two ways to make a parbox at a given point in the text: with the \parbox command and the minipage environment. They can be used to put one or more paragraphs of text inside a picture or in a table item.

\parbox and minipage share one mandatory argument (width of the parbox) and the optional argument (vertical alignment). (The second mandatory argument of \parbox "is the text to be put in the parbox" [p. 105].) Lamport recommends the use of minipages instead of parboxes in some cases (e.g. a parbox containing a tabbing or a list-making environment), but doesn't substantiate his advice (or at least I skipped that part). Finally, from Hendrik Vogt's comment to this answer, I gather that one reason to prefer minipages is that "[y]ou don't have to wait that long for the matching closing brace".

I'm aware that the \footnote command doesn't work with \parbox; by contrast, it "puts a footnote at the bottom of the parbox produced by the [minipage] environment" (Lamport, p. 105). Are there other differences in applicability between \parbox and the minipage environment?

P.S.: Kopka and Daily, A guide to LaTeX, state on p. 89:

The text in a \parbox may not contain any of the centering, list, or other environments described in Sections 4.2 through 4.5. These may, on the other hand, appear within a minipage environment.

However, I did some tests using center, itemize and tabbing environments within a \parbox, and LaTeX did not throw error messages. Are Kopka and Daly wrong, or did I miss something?

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):

\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):

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