1

I am using tcolorbox for boxes containing a theorem. They are divided into two halves: on the left text and equations, on the right a picture. How can I achieve both

  • fit the caption text to (halft the) box width i. e. to fit below the image (my caption is always rendered as a too wide single line)

and

  • left-align the caption text

?

I only manage to achieve one of the above

\documentclass[11pt,a4paper,oneside]{report} 
\usepackage{float}
\usepackage[demo]{graphicx}
\usepackage{tcolorbox} % Frames
\usepackage{caption} % Frames
\tcbuselibrary{breakable,theorems}

\newtcbtheorem[auto counter, number within = part]
{The}{Satz}{%
breakable
}{the}


\begin{document}

\begin{The}{Satz des Pythagoras}{FKT-Pythagoras}
\parbox{0.5    \textwidth}{
\[
a^2+b^2=c^2.
\]
}     \parbox{0.5    \textwidth}{
%Bild_TrigoPolyGrad1
    \begin{figure}[H]
        \includegraphics[width=0.5    \textwidth]{../../Bausteine/FKT/Bilder/FKT_pythagoras.png}
\captionsetup{justification=justified,singlelinecheck=false,labelsep=newline}       
    \caption[]{Satz des Pythagoras im rechtwinkligen Dreieck.}
        \label{fig:FKT-pythagoras2}
    \end{figure}
}
\end{The}

\begin{The}{Satz des Pythagoras}{FKT-Pythagoras}
\parbox{0.5    \textwidth}{
\[
a^2+b^2=c^2.
\]
}     \parbox{0.5    \textwidth}{
%Bild_TrigoPolyGrad1
    \begin{figure}[H]
        \includegraphics[width=0.5    \textwidth]{../../Bausteine/FKT/Bilder/FKT_pythagoras.png}
\captionsetup{justification=justified,singlelinecheck=false,labelsep=newline,width=0.25    \textwidth}      
    \caption[]{Satz des Pythagoras im rechtwinkligen Dreieck.}
        \label{fig:FKT-pythagoras}
    \end{figure}
}
\end{The}


\end{document}
1

The figure environment is for floating, but you do not want the figures to float, so use center instead and \captonof{figure}{...}. Consider using minipages instead of \parboxes too, since minipages are designed to hold vertical material. Below I give examples of both uses.

Sample output

\documentclass[11pt,a4paper,oneside]{report}

\usepackage{float}
\usepackage[demo]{graphicx}
\usepackage{tcolorbox}
\usepackage{caption}
\tcbuselibrary{breakable,theorems}

\newtcbtheorem[auto counter, number within = part]
{The}{Satz}{%
breakable
}{the}

\captionsetup{justification=justified,singlelinecheck=false,labelsep=newline}
\begin{document}

\begin{The}{Satz des Pythagoras}{FKT-Pythagoras}
  \begin{minipage}{0.5\textwidth}
    \[
      a^2+b^2=c^2.
    \]
  \end{minipage}%
  \begin{minipage}{0.5\textwidth}
    % Bild_TrigoPolyGrad1
    \begin{center}
      \includegraphics[width=\textwidth]{../../Bausteine/FKT/Bilder/FKT_pythagoras.png}
      \captionof{figure}{Satz des Pythagoras im rechtwinkligen
      Dreieck.}
      \label{fig:FKT-pythagoras}
    \end{center}
  \end{minipage}
\end{The}

\begin{The}{Satz des Pythagoras}{FKT-Pythagoras}
  \parbox{0.5\textwidth}{
  \[
    a^2+b^2=c^2.
  \]
  }%
  \parbox{0.5\textwidth}{
  % Bild_TrigoPolyGrad1
  \begin{center}
    \includegraphics[width=0.5\textwidth]{../../Bausteine/FKT/Bilder/FKT_pythagoras.png}
    \captionof{figure}{Satz des Pythagoras im rechtwinkligen Dreieck.}
    \label{fig:FKT-pythagoras2}
  \end{center}
  }
\end{The}


\end{document}
| improve this answer | |

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.