[Tex/LaTex] Annotated Box around Figures and Tables

floatsframedmdframed

I have a Latex document where I need to put Figures and Tables in boxes. This can be accomplished with e.g. fbox, framed or mdframed. However, I need a solution that also allows me to annotate the box itself and I'm not sure that any of those packages can do this.

For example, I need something that looks like this:

+------------------------+
| note                   |
|                        |
|         Figure         |
|        Fig. Cap        |
|                        |
|                   note |
+------------------------+

Can anyone provide help, suggestions, or solutions?

Best Answer

Here is an example with a very simple tcolorbox setup:

In principle, the tcolorbox can 'conquer' the figure environment and blend into, this would mean, that the caption is at the top and displayed as the the title of the box.

\documentclass{article}

\usepackage{graphicx}

\usepackage{caption}
\usepackage[most]{tcolorbox}


\newtcolorbox{annotatedbox}[1][]{%
  enhanced jigsaw,
  sharp corners,
  colback=white,
  float=htb,
  boxsep=0pt,
  #1%
}

\usepackage{blindtext}

\begin{document}
\blindtext[5]
\begin{annotatedbox}
Some text before

\begin{center}
  \includegraphics[scale=0.2]{ente}
  \captionof{figure}{A beautiful duck}
\end{center}
\hfill Some other text right
\end{annotatedbox}

\blindtext[6]

\begin{annotatedbox}[colframe={red!40!brown},boxrule=5pt]
Some text before

\begin{center}
  \includegraphics[scale=0.2]{ente}
  \captionof{figure}{Another beautiful duck}
\end{center}
\hfill Some other text right
\end{annotatedbox}


\end{document}

enter image description here

Related Question