将图片插入文本

将图片插入文本

我目前正在做这个项目,并试图将图片添加到文本中。我希望图片能够换行。我将它们添加到段落后面,否则 Overleaf 会将其标记为错误。

我将其插入为:

\begin{wrapfigure}{r}{0.4\textwidth}
    \centering
    \includegraphics[width=0.4\textwidth]{chicago.png}
    \caption{Chicago, USA}
\end{wrapfigure}

然而,它最终看起来像这样

答案1

Overleaf 遵循默认的 wrapfig 包规则,图像占 \textwidth 的 20% 还是 80% 并不重要。每次只显示一个图像和相邻的段落,如果段落在标题清除之前结束,则允许另一个段落与该段落一起显示,因此如果空间不足,下一个图像将浮动到下一个段落或 overleaf 到下一页。通常,您只能控制尝试的段落位置。

规则是第二个 wrapfig 才会开始......

“如果该段落没有围绕另一个图形”

在此处输入图片描述

\documentclass{article}
%\usepackage{mwe} % may be required one time to trigger on the fly example-image downloads
\usepackage{graphicx}
\usepackage{wrapfig}
\begin{document}
FIRST we have text and here we have text and here we have text and here we have CITIES continues
% implied end paragraph still needs
\par
\begin{wrapfigure}{l}{0.45\textwidth}
\centering
    \includegraphics[width=0.45\textwidth]{example-image-A}
    \caption{Frankfurt am Main, DE}
\end{wrapfigure}
FRANKFURT we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text AND\par SECOND FRANKFURTwe have text and here we have and here we have text and here we have text and here we have text AND
\newline
\par
CHICAGO we have text and here we have text and here we have text and here we have text and here we have text and here we have text  and here we have text  and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have text and here we have AND \par
 \begin{wrapfigure}{r}{0.49\textwidth}
 \centering
    \includegraphics[width=0.49\textwidth]{example-image-duck}
    \caption{Chicago, USA}
\end{wrapfigure}
SECOND CHICAGO we have text and here we have and here we have text and here we have text and here we have text AND continues...
\par
\end{document}

相关内容