我试图将一个图形(使用 \tabular)放入表格(\tabular)中:
我已经尝试过代码:
\begin{tabular}{cc}
\begin{figure}
\begin{tabular}{ccc}
\includegraphics[width=0.16\linewidth]{example-image} &
\includegraphics[width=0.16\linewidth]{example-image} &
\includegraphics[width=0.16\linewidth]{example-image}
\end{tabular}
\caption{Some text}
\end{figure}
&
\begin{figure}
\begin{tabular}{ccc}
\includegraphics[width=0.16\linewidth]{example-image} &
\includegraphics[width=0.16\linewidth]{example-image} &
\includegraphics[width=0.16\linewidth]{example-image}
\end{tabular}
\caption{Some text}
\end{figure}
\end{tabular}
和
\begin{table}{cc}
\begin{figure}
\begin{subfigure}
\includegraphics[width=0.16\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\includegraphics[width=0.16\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\includegraphics[width=0.16\linewidth]{example-image}
\end{subfigure}
\caption{Some text}
\end{figure}
&
\begin{figure}
\begin{subfigure}
\includegraphics[width=0.16\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\includegraphics[width=0.16\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\includegraphics[width=0.16\linewidth]{example-image}
\end{subfigure}
\caption{Some text}
\end{figure}
\end{table}
这两个代码块都会出错。
谢谢!
答案1
欢迎来到 TeX:SE!
借助tabularx
包:
\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage{graphicx}
\begin{document}
\begin{figure}[ht]
\setkeys{Gin}{width=0.32\linewidth}
\begin{tabularx}{\linewidth}{@{} XX @{}}
\includegraphics{example-image-duck}\hfill
\includegraphics{example-image-duck}\hfill
\includegraphics{example-image-duck}
%
\caption{Some text}
& \includegraphics{example-image-duck}\hfill
\includegraphics{example-image-duck}\hfill
\includegraphics{example-image-duck}
%
\caption{Some text}
\end{tabularx}
\end{figure}
\end{document}
答案2
这是一个不需要任何tabular
类似结构的解决方案。
\documentclass{article}
\usepackage{graphicx} % for '\includegraphics' macro
\usepackage{caption} % for '\captionof' macro
\begin{document}
\noindent
\begin{minipage}[t]{0.48\textwidth}
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}
\captionof{figure}{Some text}
\end{minipage}\hfill
\begin{minipage}[t]{0.48\textwidth}
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}
\captionof{figure}{Some more text}
\end{minipage}
\end{document}
或者,如果您希望将图像放置在figure
浮点数中,则可以使用以下代码:
\begin{figure}
\begin{minipage}[t]{0.48\textwidth}
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}
\caption{Some text}
\end{minipage}\hfill
\begin{minipage}[t]{0.48\textwidth}
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}\hfill
\includegraphics[width=0.32\linewidth]{example-image}
\caption{Some more text}
\end{minipage}
\end{figure}