Como manter uma legenda de figura com tcolorbox

Como manter uma legenda de figura com tcolorbox

insira a descrição da imagem aqui Como posso manter uma figura de legenda dentro de um tcolorbox? Quero colocar a torta em um tcb mas quando eu deleto \begin{figure}[h]e \end{figure}, a legenda é removida. Alguma solução? Obrigado.

Ilustração:

 \begin{figure}[h]
 \centering 
 \begin{tikzpicture}
   \pie [polar]{10/Excellentes, 20/Bonnes, 30/Moyennes, 40/Mauvaises}
 \end{tikzpicture}
 \caption{ Présentation  }
 \label{fig: Question}
 \end{figure}

 \\

 \begin{tcolorbox}[colback=white]

 \centering 
 \begin{tikzpicture}
   \pie [polar]{10/Excellentes, 20/Bonnes, 30/Moyennes, 40/Mauvaises}
 \end{tikzpicture}
 \caption{ Présentation  ghjghjghjg }
 \label{fig: Qp}
 \end{tcolorbox}

Responder1

Bem-vindo! tcolorboxpermite que você tenha carros alegóricos como figuras em (ou, mais precisamente, como) tcolorboxes. Você precisa definir um tcolorboxpara isso.

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{pgf-pie}
\begin{document}
 \begin{figure}[h]
 \centering 
 \begin{tikzpicture}
   \pie [polar]{10/Excellentes, 20/Bonnes, 30/Moyennes, 40/Mauvaises}
 \end{tikzpicture}
 \caption{ Pr\'esentation  }
 \label{fig: Question}
 \end{figure}

% define a tcolorbox version of figures, see p. 115 of the manual
\newtcolorbox[blend into=figures]{myfigure}[2][]{float=htb,capture=hbox,
title={#2},every float=\centering,#1}


\begin{myfigure}[label={fig:Qp},% <- label goes here
    colback=white]{Another pr\'esentation.}% <- caption goes here
 \begin{tikzpicture}
   \pie [polar]{10/Excellentes, 20/Bonnes, 30/Moyennes, 40/Mauvaises}
 \end{tikzpicture}
 \end{myfigure}

As shown in figure~\ref{fig:Qp}, one can have floats in (or, more precisely, as)
\verb|tcolorbox|es.
\end{document}

insira a descrição da imagem aqui

Além disso, considere, no futuro, fornecer-nos documentos completos que comecem \documentclasse terminem com \end{document}, sejam mínimos e possam ser compilados.

informação relacionada