Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
Thanks for your comment... my minipage is on the left half side of the page, but following your method, the caption is in the center of the page, how could I just put the caption under the minipage? –  SoftTimur Aug 16 '11 at 20:52
    
@SoftTimur: no problem ... I guess you would like to center the caption below the minipage, but outside the box. So, put another minipage around the box, use \centering at the begin and \captionof before the end of the outer minipage. –  Stefan Kottwitz Aug 16 '11 at 21:04
    
Now it is better, but still, the right minipage has moved a little bit to the right --- there is no more space between the 2 minipages... I am going to add my code in the initial post immediately –  SoftTimur Aug 16 '11 at 21:21
    
@SoftTimur: Now you have a follow-up question which is about positioning two minipages. It's getting complicated if you mix it here into the original question & answer. In such cases, it would be better to post a separate question with an example on the new basis. I guess you just should move the \hfill between the two outer minipages, not keeping it inside an inner minipage. –  Stefan Kottwitz Aug 16 '11 at 22:01
    
Well... no deed to post another question... it is indeed \hfill which should be after the outer minipage, instead of inner minipage, thank you very much! –  SoftTimur Aug 16 '11 at 22:05
add comment

Another way to achieve your objective is to use the float package, which lets you create a custom environment akin to the figure and table environments, but with a box drawn around its contents. The new environment -- let's call it boxx because box is a reserved word -- can be given labels and thus also cross-referenced, exactly like you would do with figures and tables. In addition, if needed, all boxes (or boxxes) can be listed in the document's table of contents using the command \listofboxxes.

Consider the following code (again, please forgive the awkward name boxx, but box is a reserved word in TeX and LaTeX):

\documentclass{article}
\usepackage{float,lipsum}
\floatstyle{boxed}
\newfloat{boxx}{thb}{lob}
\floatname{boxx}{Box}

\begin{document}

\begin{boxx}
\caption{Lipsum, Para 1}\label{box:1}
\lipsum[1]
\end{boxx}

\begin{boxx}
\caption{Lipsum, Para 2} \label{box:2}    
\lipsum[2]
\end{boxx}

And here are cross-references to Boxes \ref{box:1} and \ref{box:2}.
\end{document}

If all you want is to restyle the appearance of LaTeX's table environment by placing a box around its contents (rather than creating a whole new environment), you could still load the float package in the preamble and then insert the commands \floatstyle{boxed} and \restylefloat{table}, and all table environments will automatically be boxed rather than plain.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.