我该如何解决这个问题?第二段的文本覆盖了图形,并且不包含换行符。
\documentclass[parskip=half]{scrbook}
\usepackage[english]{babel}
\usepackage{graphicx,lipsum,wrapfig}
\begin{document}
\begingroup
\setlength{\columnsep}{30pt}%
\begin{wrapfigure}{r}{0.5\textwidth}
\centering\includegraphics[width=\linewidth]{example-image-a}
\caption{A very very very very very very very very long long long caption}
\end{wrapfigure}
foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
foo foo foo foo foo foo foofoo foo foo foo foo foo foofoo foo foo foo foo foo foo
\endgroup
\end{document}
答案1
正如评论中所述哈里什·库马尔,手册上说文本换行应该在组结束之前结束。所以我们需要添加另一行文本。但我们可以在不实际显示添加的文本的情况下执行此操作(例如使用phantom
),如下所示:
\documentclass[parskip=half]{scrbook}
\usepackage[english]{babel}
\usepackage{graphicx,lipsum,wrapfig}
\begin{document}
\begingroup
\setlength{\columnsep}{30pt}%
\begin{wrapfigure}{r}{0.5\textwidth}
\centering\includegraphics[width=\linewidth]{example-image-a}
\caption{A very very very very very very very very long long long caption}
\end{wrapfigure}
foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
foo foo foo foo foo foo foofoo foo foo foo foo foo foofoo foo foo foo foo foo foo
\phantom{foo}
\endgroup
\end{document}
如果这增加了太多的垂直空间,另一个解决方法是添加负数vspace
(虽然风格不好,但对于快速而肮脏的解决方法来说很棒)。