如果我将图像与 wrapfig 一起使用到逐项列表中或附近,则结果是图像与文本重叠(见图)。我读了很多与 wrapfig 和 itemize 不兼容相关的帖子,但没有人解决这个问题 ;-) 有什么帮助吗?
\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
This is an example: first paragraph is OK but the second have the problem!
\begin{itemize}
\item
\parbox[t]{\dimexpr\textwidth-\leftmargin}{%
\vspace{-2.5mm}
\begin{wrapfigure}{r}{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{beach.png}
\caption{The beach}
\end{wrapfigure}
\lipsum[1]
}
\item
\parbox[t]{\dimexpr\textwidth-\leftmargin}{%
\vspace{-2.5mm}
\begin{wrapfigure}{r}{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{beach.png}
\caption{The beach}
\end{wrapfigure}
This is a short text...
}
\item \lipsum[1]
\end{itemize}
\end{document}
答案1
在列表中使用wrapfig
显然是不受支持的,但如果你想这样做,只要稍加帮助它就可以工作:
\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
This is an example: first paragraph is OK but the second have the problem!
\begin{itemize}
\item
\parbox[t]{\dimexpr\textwidth-\leftmargin}{%
\vspace{-2.5mm}
\begin{wrapfigure}[10]{r}{0.5\textwidth}
\centering
\vspace{-\baselineskip}
\includegraphics[width=\linewidth]{beach.png}
\caption{The beach}
\end{wrapfigure}
\lipsum[1]
}
\item
\parbox[t]{\dimexpr\textwidth-\leftmargin}{%
\vspace{-2.5mm}
\begin{wrapfigure}{r}{0.5\textwidth}
\centering
\vspace{-\baselineskip}
\includegraphics[width=\linewidth]{beach.png}
\caption{The beach}
\end{wrapfigure}
This is a short text...
}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
\vspace{-2.5mm}
\begin{wrapfigure}[8]{r}{0.5\textwidth}
\end{wrapfigure}
\lipsum[1]}
\end{itemize}
\end{document}