2

The question How to create a box with caption and label like a float? explains perfectly what I need except for one thing; they use the custom caption "InfoBox". How can I use the caption "Box" and avoid the error "Command \Box already defined."?

  • You should take a look at the tcolorbox package. – Joseph Jan 28 '18 at 1:42
4

The answer you mention uses undocumented commands. Better to declare the new float type explicitly.

\documentclass{article}
\usepackage{caption,graphicx,newfloat}

\DeclareFloatingEnvironment[
  fileext=lob,
  listname={List of Boxes},
  name=Box,
  placement=htp,
]{BOX}

\begin{document}

\begin{BOX}[ht]
\centering

\fbox{\includegraphics[width=2in]{example-image-b}}

\caption{Here is my caption\label{box:b}}

\end{BOX}

In box \ref{box:b}...

\end{document}

enter image description here

0

You can use tcolorbox do suit your needs (check the documentation for further customizations):

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcolorbox[auto counter,list inside=mybox]{mybox}[2][]{%
    title={Box~\thetcbcounter:~#2},
    #1,
    halign title=center,
    sharp corners,
    fonttitle=\bfseries\sffamily\large,coltitle=black,titlerule=0pt,
    colbacktitle=white,
    colback=white,
    drop fuzzy shadow
}


\begin{document}

\tcblistof[\section*]{mybox}{List of boxes}


\begin{mybox}{An mybox}
That's it.
\end{mybox}


\end{document}

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.