有人能帮我吗?我正在制作一些教程,需要添加一些图片到文档中
我希望能够在一行上并排添加三张图片,而在下一行只能添加一张或两张图片,但我遇到了一个问题:当我有两张图片时,它们都以“两列”为中心,而我需要“三列”,其中第三列是空白的。
有人能帮我吗?谢谢,Georgerrr
我的代码是:
\begin{figure}
\begin{minipage}{0.3\textwidth}
\centering
{\includegraphics[width=5cm]
{../images/Mail_Phone/WindowsPhoneMail/EN/08_NastaveniSync.png}}
\caption{Caption A}
\end{minipage}\hfill
\begin{minipage}{0.3\textwidth}
{\includegraphics[width=5cm]
{../images/Mail_Phone/WindowsPhoneMail/EN/09_NastaveniSync2.png}}
\caption{Caption B}
\end{minipage}\hfill
\begin{minipage}{0.3\textwidth}
\end{minipage}\hfill
\end{figure}
答案1
我会尝试使用tabular
或 像这里一样tabularx
来填充页面宽度,而不是单独的minipage
s。
\documentclass{article}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{graphicx}
\begin{document}
\lipsum[1]
\begin{figure}[htb]
\begin{tabularx}{\linewidth}{@{}XXX@{}}
\includegraphics[width=\linewidth]{example-image}
& \includegraphics[width=\linewidth]{example-image}
& \includegraphics[width=\linewidth]{example-image}\\[-1.5em]
\caption{This is an example image}
&\caption{This is also an exampe image}
&\caption{And one more}\\
%%
\includegraphics[width=\linewidth]{example-image}
& \includegraphics[width=\linewidth]{example-image}
& \\[-1.5em]
\caption{More picture}
&\caption{Next empty}
&\\
%%
\includegraphics[width=\linewidth]{example-image}
&
& \includegraphics[width=\linewidth]{example-image}\\[-1.5em]
\caption{This row has empty in the middle}
&
&\caption{This is the last one!}\\
\end{tabularx}
\end{figure}
\lipsum[2]
\end{document}
也可以使用 来实现相同的效果minipage
。空槽的问题在于,空槽minipage
会折叠为空,因此您需要在其中放入一些东西。我使用\strut
但您也可以~
按照问题评论中的建议使用。
\begin{figure}[htb]
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{This is an example image}
\end{minipage}\hfill%
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{This is also an exampe image}
\end{minipage}\hfill%
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{One more}
\end{minipage}%
\newline
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{More picture}
\end{minipage}\hfill%
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{Next empty}
\end{minipage}\hfill%
\begin{minipage}[t]{0.3\linewidth}
\strut
\end{minipage}%
\newline
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{This row has empty in the middle}
\end{minipage}\hfill%
\begin{minipage}[t]{0.3\linewidth}
\strut
\end{minipage}\hfill%
\begin{minipage}[t]{0.3\linewidth}
\includegraphics[width=\linewidth]{example-image}
\caption{This is the last one!}
\end{minipage}
\end{figure}