[Tex/LaTex] Where to add a caption and a reference to a tabbing&fbox&minipage

boxescaptionscross-referencingminipagetabbing

I put some texts enclosed within tabbing, embedded in fbox and minipage:

\fbox{%
\begin{minipage}[t]{0.48\linewidth}%
\begin{tabbing}
\quad \= \quad \= \quad \= \quad \= \quad \= \hspace{5cm} \= \\[-\baselineskip]\kill
 ...
 ...
\end{tabbing}
\end{minipage}}\hfill

The question is… if I want to put a caption for the whole text, just under and outside the frame, and make it a reference. Do where should I put this \caption{acap} and \reference{aref}?

Could anyone help? Thank you very much!

Edit1: Following the second proposition of @Stefan Kottwitz, I have the following code, which prints the two minipages on the same height. The problem now is that, before adding the outer minipage of the first minipage, there was space between two sides, and their positions were all right. But now, the right minipage has moved a little bit to the left, so that the space has disappeared… Could anyone help? Thank you!

\begin{minipage}[t]{0.48\linewidth}%
\centering
\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{minipage}
\begin{minipage}[t]{0.48\linewidth}
...
\end{minipage}

Best Answer

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.

enter image description here