3

I defined a new environment with \newtcolorbox in the preamble. If I call it in the document I can use it. That´s fine!

\documentclass{article}

% Standard Packages
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx, subfig}
\graphicspath{{img/}}
\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{}
\end{tcolorbox} 

\begin{myfigure}{A tcolorbox figure with quite a long title}
    \includegraphics[height=5cm]{modulation.png}
\end{myfigure}

\end{document}

Now I want to integrate the myfigure-Environment into the tcolorbox, like this:

\begin{tcolorbox}[breakable]
    \lipsum{}
    \begin{myfigure}{A tcolorbox figure with quite a long title}
        \includegraphics[height=5cm]{modulation.png}
    \end{myfigure}
\end{tcolorbox} 

Why is this not possible? What means the error-messages:

  • Not in outer par mode. \end{myfigure}

  • Undefined control sequence. \end{myfigure}

  • Missing number, treated as zero. \end{myfigure}

Can somebody help me to configure it right?

3
  • 3
    Welcome to TeX.SX! You cannot use a float within a breakable box.
    – TeXnician
    Aug 23 '18 at 8:21
  • Thankyou. So what have I have to do, to get the result I want? Aug 23 '18 at 8:26
  • 1
    What is the expected result? If you have a breakable outer box you must disable floating for the inner box.
    – TeXnician
    Aug 23 '18 at 8:29
2

You cannot have a float within a breakable box. But as you allow options to be passed to the floating box, you can do the following (disabling float once):

breakable box with float

\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}
\end{myfigure}
\end{tcolorbox} 

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