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.

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 \\
a \\
b \\
\caption{a caption}
  • Welcome to TeX.sx! More information on this site can be seen in the faq and the Unofficial TeX-SX FAQ meta.tex.stackexchange.com/q/1144/19384 as well as the markdown help tex.stackexchange.com/editing-help. Welcome to the community! – Peter Jansson Jan 2 '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 2 '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 2 '13 at 21:49
  • @JanGorzny What alignment do you want of the two objects? – egreg Jan 2 '13 at 21:51
  • Should the box borders align, or be visibly separate from one another? – Werner Jan 2 '13 at 21:59

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

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


6,% lines above
r,% position
A simple caption% the subcaption
\caption{A figure float with a pseudo-subfloat inside.}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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