我尝试在表格中放置 2 x 2 的数字,每个数字都有标题
我试过
\begin{table}[ht]
\begin{tabular}{cc}
\begin{subfigure}\centering\includegraphics[width=0.3\columnwidth]{./img/1.png}\caption{Figure A}\label{fig:taba}\end{subfigure}&
\begin{subfigure}\centering\includegraphics[width=0.3\columnwidth]{./img/1.png}\caption{Figure B}\label{fig:tabb}\end{subfigure}\\
\newline
\begin{subfigure}\centering\includegraphics[width=0.3\columnwidth]{./img/1.png}\caption{Figure C}\label{fig:tabc}\end{subfigure}&
\begin{subfigure}\centering\includegraphics[width=0.3\columnwidth]{./img/1.png}\caption{Figure A again}\label{fig:taba2}\end{subfigure}\\
\end{tabular}
\caption{A table with figures}
\label{tab:mytable}
\end{table}
但这会产生错误
[109] [110] <use ./img/1.png>
! You can't use `\hrule' here except with leaders.
\caption@hrule ->\hrule
\@height \z@
l.888 ...nwidth]{./img/1.png}\caption{Figure A}
\label{fig:taba}\end{subfi...
有人能帮忙解决吗?我检查了很多代码块来将数字放在表格中,但都没有用
答案1
我猜你想获得这样的东西:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage[skip=1ex]{caption}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabularx}{\columnwidth}{XX}
\includegraphics[width=\linewidth]{./img/1.png}
\captionof{figure}{Figure A}\label{fig:taba}
& \includegraphics[width=\linewidth]{./img/1.png}
\captionof{figure}{Figure B}\label{fig:tabb} \\
\includegraphics[width=0.45\columnwidth]{./img/1.png}
\captionof{figure}{Figure C}\label{fig:tabc}
& \includegraphics[width=\linewidth]{./img/1.png}
\captionof{figure}{Figure D}\label{fig:tabd}
\end{tabularx}
\caption{A table with figures}
\label{tab:mytable}
\end{table}%
\end{document}
或者将图形作为子图形?
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[skip=1ex]{caption}
\usepackage{subcaption}
\begin{document}
\begin{table}[ht]
\begin{subfigure}{0.45\columnwidth}
\includegraphics[width=\linewidth]{./img/1.png}
\caption{figure}\label{fig:taba}
\end{subfigure}\hfill
\begin{subfigure}{0.45\columnwidth}
\includegraphics[width=\linewidth]{./img/1.png}
\caption{Figure B}\label{fig:tabb}
\end{subfigure}\\[1em]
%
\begin{subfigure}{0.45\columnwidth}
\includegraphics[width=\linewidth]{./img/1.png}
\caption{Figure C}\label{fig:tabc}
\end{subfigure}\hfill
\begin{subfigure}{0.45\columnwidth}
\includegraphics[width=\linewidth]{./img/1.png}
\caption{Figure D}\label{fig:tabd}
\end{subfigure}
\caption{A table with figures}
\label{tab:mytable}
\end{table}%
\end{document}