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}
You could use a figure
or table
environment, using LaTeX's floating objects capabilities:
\documentclass{article}
\begin{document}
\begin{table}[!htbp]
\centering
\fbox{
\begin{minipage}[t]{0.48\linewidth}%
\begin{tabbing}
\quad \= \quad \= \quad \= \quad \= \quad \= \hspace{5cm} \= \\[-\baselineskip]\kill
...
...
\end{tabbing}
\end{minipage}}\hfill
\caption{A Testbox}
\label{testbox}
\end{table}
See box \ref{testbox}.
\end{document}
If you don't want the objects to float, but need captions and cross-referencing, you could use the caption
package and its command \captionof
:
\documentclass{article}
\usepackage{caption}
\begin{document}
\begin{center}
\fbox{
\begin{minipage}[t]{0.48\linewidth}%
\begin{tabbing}
\quad \= \quad \= \quad \= \quad \= \quad \= \hspace{5cm} \= \\[-\baselineskip]\kill
...
...
\end{tabbing}
\end{minipage}}\hfill
\captionof{table}{A Testbox}
\label{testbox}
\end{center}
See box \ref{testbox}.
\end{document}
I used a center
environment, you could also use just another minipage around instead. I chose table
instead of figure
since it's a tabular object. You could also declare your own caption type.
Best Answer
Regarding
\fbox
, as Joseph said: there's a closing brace missing, determining the end of the argument.For the whole text width you could use the
framed
package and its environment with the same name, such asAnother option is the improved version
mdframed
.For framing math environments, there's the
\boxed
command ofamsmath
.