我有一个包含 4 个子图的表格,我想分别为每个图设置标题。我正在使用 subcaption 包,但在编译时出现以下错误:package floatrow error: caption(s) lost。有人能告诉我问题出在哪里吗?
{\centering
\begin{table}[ht]
\begin{tabular}{ll}
\begin{subfigure}{}
\includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{figure} \label{fig:taba2}
\end{subfigure} &
\begin{subfigure}{}
\includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{fd} \label{fig:taba3}
\end{subfigure}\\ \newline
\begin{subfigure}{}
\includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{figure}\label{fig:taba4}
\end{subfigure} &
\begin{subfigure}{}
\includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{figure} \label{fig:taba5}
\end{subfigure}\\
\end{tabular}
\caption{A table with figures}
\label{tab:mytable}
\end{table}
}
答案1
我无法重现您的错误。但是,您在定义 时出错了subfigure
。为此,您需要声明其宽度,例如
\begin{subfigure}{0.5\textwidth}\centering
在其中您可以设置图形相对于subfigure
宽度的宽度,例如:
\includegraphics[width=\linewidth]{example-image}
也\centering
应该在环境内部table
。完整代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{3em}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{cc}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\linewidth]{example-image} \caption{figure} \label{fig:taba2}
\end{subfigure} &
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\linewidth]{example-image}
\caption{fd} \label{fig:taba3}
\end{subfigure} \\
%
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\linewidth]{example-image} \caption{figure}\label{fig:taba4}
\end{subfigure} &
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\linewidth]{example-image}
\caption{figure} \label{fig:taba5}
\end{subfigure}
\end{tabular}
\caption{A table with figures}
\label{tab:mytable}
\end{table}
\end{document}