![引用后立即出现 Wrapfig 错误](https://linux22.com/image/268965/%E5%BC%95%E7%94%A8%E5%90%8E%E7%AB%8B%E5%8D%B3%E5%87%BA%E7%8E%B0%20Wrapfig%20%E9%94%99%E8%AF%AF.png)
我注意到wrapfig
,如果第一个文本是引用或交叉引用,wrapfig
则会忽略整个段落,并且段落会在图像的顶部旋转。
不要要求我提供完整的 MWE,因为我有最后期限,现在没有时间,但如果有人知道我在说什么,请随时加入。
基本上类似这样的事情应该会重现。
\begin{wrapfigure}{r}{0.5\textwidth}
.... image code whatever
\end{wrapfigure}
\citet{key} published bla and bla and the topics discussed are bla and this is a paragraph bla bla bla.
但是,这可以正常工作:
\begin{wrapfigure}{r}{0.5\textwidth}
.... image code whatever
\end{wrapfigure}
The cat sat on the mat. \citet{key} published bla and bla and the topics discussed are bla and this is a paragraph bla bla bla.
答案1
一个解决方案:添加一个\leavevmode
。最小示例:
\documentclass[12pt, oneside, draft]{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{knuth:ct,
author = {Knuth, Donald E.},
title = {Computers \& Typesetting},
volumes = {5},
publisher = {Addison-Wesley},
address = {Reading, Mass.},
year = {{1984--1986}},
}
\end{filecontents}
\usepackage{wrapfig, natbib}
\newcommand\test{\citet{knuth:ct} published bla and bla and the topics
discussed are bla and this is a paragraph bla bla bla.\space}
\begin{document}
\begin{wrapfigure}{r}{0.5\textwidth}
\rule{0.49\textwidth}{3cm}
\end{wrapfigure}
\test \test \test \test \test
\begin{wrapfigure}{r}{0.5\textwidth}
\rule{0.49\textwidth}{3cm}
\end{wrapfigure}
The cat sat on the mat.
\test \test \test \test \test
\begin{wrapfigure}{r}{0.5\textwidth}
\rule{0.49\textwidth}{3cm}
\end{wrapfigure}
\leavevmode \test \test \test \test \test
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
编辑:(来自评论)\leavevmode
根据TeX 按主题分类,一个宏,用于在必要时切换到水平模式。因此,我想您可以修补命令\citet
以包含一个\leavevmode
,但我不确定它是否会在其他地方产生不可预见的后果;我想不出在哪里,但其他人肯定可以比我更好地回答这个问题。无论如何,这适用于此示例:
\usepackage{etoolbox}
\pretocmd{\citet}{\leavevmode}%
{\typeout{***** patching \string\citet\space succeeded !! *****}}%
{\typeout{***** patching \string\citet\space failed !! *****}}