# Text in tcolorbox by using new enviroment

how can I insert a text line under the picture? If I try to take a text after \includegraphics[...] it goes wrong.

\documentclass{article}

% Standard Packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[theorems,skins,breakable]{tcolorbox}
\tcbuselibrary{breakable, skins, raster}
\usepackage{lipsum}

\newtcolorbox[blend into=figures]{myfigure}[2][]{float=htb,capture=hbox,
blend before title=dash hang,title={#2},every float=\centering,#1}

\begin{document}

\begin{tcolorbox}[breakable]
\lipsum{}
\begin{myfigure}[nofloat]{A tcolorbox figure with quite a long title}
\includegraphics[height=5cm]{example-image}
\\ example-text
\end{myfigure}
\end{tcolorbox}

\end{document}

• You use capture=hbox. That won't work with line breaks. – TeXnician Sep 18 '18 at 16:33
• What have I use instead? – Benjamin Bebernik Sep 18 '18 at 16:40
• What is your aim? Do you want hboxed content? Then you'll have a problem, because line breaks won't work. Do you want vboxed content? Then you can just remove that capture option. But currently, it is not clear what you want. Another thing: You want every float to be centered, what should happen with the image? – TeXnician Sep 18 '18 at 16:43
• What I in fact want is a colorbox with the picture in there and a small text for source information under the picture. The caption should be in the title-frame on the top – Benjamin Bebernik Sep 18 '18 at 16:57
• Shall it be centered? And shall the box be hboxed (only as wide as the content)? – TeXnician Sep 18 '18 at 17:17

As mentioned by @TeXnician and from the tcolorbox package:

/tcb/capture=hbox: ... The content cannot have a lower part and cannot be broken...

But we can get arround this by adding tikznode option to myfigure definition

\documentclass{article}

% Standard Packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[theorems,skins,breakable]{tcolorbox}
\tcbuselibrary{breakable, skins, raster}
\usepackage{lipsum}

\newtcolorbox[blend into=figures]{myfigure}[2][]{
float=htb,
capture=hbox,
blend before title=dash hang,
title={#2},
every float=\centering,
#1}

\begin{document}

\begin{tcolorbox}[breakable]
\lipsum{}
\begin{myfigure}[nofloat]{A tcolorbox figure with quite a long title}
\includegraphics[height=5cm]{example-image} \\
example-text
\end{myfigure}
\end{tcolorbox}

\end{document}


• Because of a another reason I had to remove the float=htb. In fact it is still not working, after adding tikznode. My text is in the same line, where the picture i shown. – Benjamin Bebernik Sep 19 '18 at 8:10
• Even if float=htb is removed it should be ok! Try the to copy past the code I have posted. – Hafid Boukhoulda Sep 19 '18 at 8:21