从上一篇文章中,我发现我需要capt-of
包中包含数字tcolorbox
。我如何使用subfloats
?
\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage{tabu}
\usepackage{capt-of}
\usepackage[caption = false]{subfig}
\tcbset{
theorem/.style args = {#1#2#3#4}{%
step and label = {#2}{#4},%
title = {\mbox{#1~\csname the#2\endcsname\ }#3:}}
}
\newcounter{exa}
\tcbmaketheorem{examples}{Example Problem}{
breakable,
fonttitle = \bfseries,
}{exa}{ex}
\begin{document}
\begin{examples}{example ert}{exa:test}
\lipsum[1]
\par\medskip
\begin{minipage}{\linewidth}
\centering
\begin{tabular}{cc}
\subfloat[caption]{\includestandalone{line}} &
\subfloat[caption]{\includestandalone{line}}
\end{tabular}
\captionof{figure}{caption}
\end{minipage}
\par\medskip
\lipsum[2]
\end{examples}
\end{document}
\documentclass[convert = false]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (0,5);
\end{tikzpicture}
\end{document}
编辑2:
使用 Gonzalo Medina 的代码,我得到
也就是说,没有(a)
或(b)
。
这与 选项有关caption = false
。subfig
通过删除该选项,(a)
和(b)
会出现。
答案1
由于您不能在 中使用浮点数tcolorbox
,\subfloat
因此这里不起作用。由于您已经在使用subfig
,因此您\captionof
也可以将 用作子浮点数;如果您想要 内的子标题tabular
,则需要将它们包装在 中\parbox
(在其他情况下这不是必需的):
\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage{tabu}
\usepackage{subfig}
\captionsetup[subfigure]{labelformat=parens}
\tcbset{
theorem/.style args = {#1#2#3#4}{%
step and label = {#2}{#4},%
title = {\mbox{#1~\csname the#2\endcsname\ }#3:}}
}
\newcounter{exa}
\tcbmaketheorem{examples}{Example Problem}{
breakable,
fonttitle = \bfseries,
}{exa}{ex}
\begin{document}
As we see in Example Problem~\ref{ex:test}...
\begin{examples}{example ert}{test}
\lipsum[1]
\par\medskip
\begin{minipage}{\linewidth}
\centering
\begin{tabular}{c@{\hspace{2em}}c}
\includestandalone{line} &
\includestandalone{line} \\
\parbox{3.5cm}{\captionof{subfigure}{caption for subfigure one}} &
\parbox{3.5cm}{\captionof{subfigure}{caption for subfigure two}}
\end{tabular}
\captionof{figure}{caption}
\end{minipage}
\par\medskip
\lipsum[2]
\end{examples}
\end{document}
还要注意,我改变了您在最后一个强制参数中使用的标记,examples
因此用于交叉引用的字符串更简单。
答案2
\captionsetup{type=figure}
在正确的位置添加应该有帮助:
\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage{tabu}
%\usepackage{capt-of} % -- dropped
\usepackage{subfig} % -- "caption=false" removed
\tcbset{
theorem/.style args = {#1#2#3#4}{%
step and label = {#2}{#4},%
title = {\mbox{#1~\csname the#2\endcsname\ }#3:}}
}
\newcounter{exa}
\tcbmaketheorem{examples}{Example Problem}{
breakable,
fonttitle = \bfseries,
}{exa}{ex}
\begin{document}
\begin{examples}{example ert}{exa:test}
\lipsum[1]
\par\medskip
\begin{minipage}{\linewidth}
\captionsetup{type=figure} % -- added
\centering
\begin{tabular}{cc}
\subfloat[caption]{\includestandalone{line}} &
\subfloat[caption]{\includestandalone{line}}
\end{tabular}
\caption{caption} % -- replaced by regular \caption
\end{minipage}
\par\medskip
\lipsum[2]
\end{examples}
\end{document}
但是,这需要删除该subfig
选项caption=false
。设置此选项有什么特殊原因吗?