有人可以幫我嗎?我正在製作一些教程,我需要在文件中添加一些圖片
我希望能夠在一行上並排添加三張圖片,而下一行只能添加一張或兩張圖片,但我有問題:當我有兩張圖片時,它們都以“兩列”為中心,並且我需要“三欄”,其中第三欄為空。
有人可以幫我嗎?謝謝你,喬治爾
我的程式碼是:
\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}