5

How can I put a small box of text inside another larger text box (which is a figure)? (Perhaps similar to adding a boxed legend manually.)

I'm looking for something like this:

_________
|aaa bbb|
|ccc ---|
|ddd |ee|
---------

I have tried "\begin{subfigure}...\end{subfigure}" but I don't know how to position it (really, I have no clue, aside from placement specifiers). Starter code below; ideally the "a b" box should overlap the bottom right corner of the "lots of text" box.

\begin{figure}[t]
\begin{center}
\scalebox{0.8}{
\begin{boxedminipage}[t]{5in}
\begin{tabbing}
lots of text lots of text  \\
lots of text lots of text \\
lots of text lots of text \\
lots of text lots of text  \\
lots of text lots of text  \\
lots of text \\
lots of text \\
lots of text \\
lots of text \\
\end{tabbing}
\end{boxedminipage}}
\end{center}
\vspace{-0.2in}
\begin{boxedminipage}[b]{0.5in}
\begin{subfigure}
a \\
b \\
\end{subfigure}
\end{boxedminipage}
\caption{a caption}
\vspace{-0.2in}
\end{figure}
David Carlisle
  • 757,742
  • Welcome to TeX.sx! More information on this site can be seen in the faq and the Unofficial TeX-SX FAQ http://meta.tex.stackexchange.com/q/1144/19384 as well as the markdown help http://tex.stackexchange.com/editing-help. Welcome to the community! – Peter Jansson Jan 02 '13 at 21:29
  • Can you please add a minimal working example of what you have tried so far? This would help us pick up, where you left. – Max Jan 02 '13 at 21:31
  • @Max I've added as far as I've gotten. I'm not sure I'm on the right track, but I can't seem to find tutorials for positioning the objects I'm attempting to use (which themselves may be poorly chosen). – Jan Gorzny Jan 02 '13 at 21:49
  • @JanGorzny What alignment do you want of the two objects? – egreg Jan 02 '13 at 21:51
  • Should the box borders align, or be visibly separate from one another? – Werner Jan 02 '13 at 21:59
  • @Werner I think in this situation the box borders aligning would be ideal. I might settle for visibly separate however. – Jan Gorzny Jan 02 '13 at 22:04
  • A traditional tabular structure would work here, but it depends on how you want things to look like inside the two boxes. For example, is aaa bbb ccc ddd regular paragraph text that should flow/wrap around eee? It doesn't seem that way from your example, since you manually break the lines within the tabbing environment. Does it include only text (and nothing fancy like figures)? – Werner Jan 02 '13 at 22:09
  • @Werner it would only be text and math, no figures – Jan Gorzny Jan 03 '13 at 02:18
  • As a general sidenote: you shouldn't use center inside figure. See Should I use center or centering for figures and tables? for an explanation. You also need a % direct after \scalebox{0.8}{ to avoid a space here. These are actually a frequently made mistakes. Not sure about tabbing as well, which doesn't make much sense to me without any tabbing instructions. – Martin Scharrer Jan 03 '13 at 08:26

1 Answers1

3

One option is to use the not-well documented picinpar package, to create a window for the image inside a normal float. Some considerations:

(1) There are not a bottom option as far I know, but vertical position can be controlled by the number of lines to skip (first option).

(2) If you want a numbered captions for the image and not for the whole float, use figwindow insteaf of window environment. Note that custom captions made with captiondef, capt-of or caption packages do not work here.

(3) The package picins is recommended instead of picinpar. Unfortunately is not available in the TeXLive distribution, but you can download it from CTAN if you have problems with picinpar.

On the other hand, if the main float must be framed you can use a minipage inside a \fbox for example (see MWE). Or more simple, use a framed or mdframed environment (both needs the package with the same name).

\documentclass{article}
\usepackage[demo]{graphicx} % option demo to use fake images
\usepackage{lipsum}         % dummy text
\usepackage{picinpar}       % win­dows in para­graphs

\begin{document}

\begin{figure}[t]
\fbox{  
\begin{minipage}{1\textwidth}
\begin{window}[%
6,% lines above
r,% position
\includegraphics[width=.5\textwidth]{some.jpg},% 
A simple caption% the subcaption
]
\lipsum[1]  
\end{window}
\end{minipage}
}
\caption{A figure float with a pseudo-subfloat inside.}
\end{figure}
\end{document}

MWE

Fran
  • 80,769