我如何在图片下插入一行文本?如果我尝试在 \includegraphics[...] 后插入文本,就会出错。
\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}
答案1
正如@TeXnician 所提到的,彩色盒子包裹:
/tcb/capture=hbox: ... 内容不能有下部,也不能被破坏...
但我们可以通过在定义中添加tikznode
选项来解决这个问题myfigure
\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][]{
tikznode, % add this option
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}