效果如上
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{tcolorbox}
\begin{center}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{img_new/t1}
\caption{Sub-caption 1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{img_new/t1}
\caption{Sub-caption 2}
\end{subfigure}
\end{center}
\caption{Total Caption}
\end{tcolorbox}
\end{figure}
\end{document}
下面这种会出现出现这些问题1, Package subcaption Error: subfigure outside float. \begin{subfigure}2, Package caption Error: \caption outside float. \caption.
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{tcolorbox}[title={My Title},colback=white,colframe=black]
\tcbsubtitle{Sub-title}
\begin{center}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{image1}
\caption{Sub-caption 1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{image2}
\caption{Sub-caption 2}
\end{subfigure}
\end{center}
\caption{Total Caption}
\end{tcolorbox}
\end{document}
The difference is that the tcolorbox is wrapped inside a figure environment, which is required for subfigure and caption environments.