3

Biology papers often have explanations of key points in "boxes", which are typeset like figures, i.e. they are floating, but they are not numbered as figures and they usually have a frame around them or a shaded background. I would like to achieve the same effect in a LaTeX document.

That is, I would like to have a floating element in my document that is similar to a figure in that it consists of an image an a caption, but:

  • there should be some title text (so the layout is title, then figure, then caption text)
  • it should have a frame drawn around the whole thing (i.e. around the title, figure and the caption)
  • it should not say "Figure 1" in front of the caption
  • it should not affect the numbering of subsequent figures
  • it should look as unobtrusive as possible, since it's not strictly part of the format for the conference I'm submitting to. So just a plain frame is preferred, without colour, shading, rounded corners etc.

For bonus points, it would be nice to automatically number these as "Box 1", "Box 2" and so on, though I don't strictly need that since my document only has one box.

I can find solutions to each of these things individually and could cobble them all together, but that feels like a bit of a hack and it would be good to have a clean solution.

2

Use tcolorbox.

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{blindtext}

\newtcolorbox[auto counter]{mybox}[2][]{float,title={Box~\thetcbcounter: #2},#1}

\begin{document}

\blindtext

\begin{mybox}[floatplacement=t,label={box:first}]{My Box}
  Lorem ipsum
\end{mybox}

\begin{mybox}[floatplacement=b,label={box:second}]{My Box}
  Dolor sit amet
\end{mybox}

\blindtext

For more info see Boxes~\ref{box:first} and~\ref{box:second}.

\end{document}

enter image description here

  • Thanks, this works and I'm able to adjust the appearance appropriately. However, no matter what I do I cannot get the box to appear on page 1 where it belongs - even if I put it before the abstract, it still comes out at the top of page 2. This was not the case when I was using a figure environment for the same content. Do you have any idea how I might resolve that? – Nathaniel May 22 '17 at 2:35
  • Actually I guess that might be because the extra margins have made the box taller and thinner than the figure was. (It's a two column layout.) I'll play around with the options and see if I can fix that. – Nathaniel May 22 '17 at 2:37

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.