如何防止 \parpic 切入证明环境内的每个段落?

如何防止 \parpic 切入证明环境内的每个段落?

当使用\parpic将图像放在短定理旁边时,如果图片超出定理的范围,它将在下一个证明环境中切入每个段落。以下 MWE 及其输出更好地说明了这个问题。我该如何纠正这种行为?

\documentclass[11pt,a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{amsmath,amsthm,picins}

\newtheorem{thm}{Theorem} 

\begin{document}
\parpic[r]{\includegraphics[width=3.2cm,height=3.2cm]{figure}}\vspace{-9pt}
\begin{thm}\label{test}
    This is a rather short theorem that contains a few lines. It has a figure
    to make things clear and an equation:
    \[
        \frac{a}{\sin\alpha} = \frac{b}{\sin\beta} = \frac{c}{\sin\theta} = 2r
    \]    
\end{thm}

\begin{proof} The first paragraph is properly cut in to prevent the picture
from overlapping with text. This happens only on the first line of this
paragraph, as is expected and desired.

Any later paragraph contained in the proof environment also has the cutin on
the first line of the paragraph. This is unexpected and undesired.
\end{proof}

This behavior happens for every paragraph inside the proof environment, but
not in paragraphs outside the proof environment such as this one.

\end{document}

输出

答案1

Picins 的工作方式是重新定义以在每个段落结束后\par恢复。无论如何,在最后一段缩进后使用 AFTER 将修复此段落和任何后续段落。\hangindent\killpic

\documentclass[11pt,a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{amsmath,amsthm,picins}

\makeatletter
\newcommand{\killpic}{%
  \hangindent=0pt
  \let\par=\old@par
}
\makeatother

\newtheorem{thm}{Theorem} 

\begin{document}
\parpic[r]{\includegraphics[width=3.2cm,height=3.2cm]{figure}}\vspace{-9pt}%
\begin{thm}\label{test}
    This is a rather short theorem that contains a few lines. It has a figure
    to make things clear and an equation:
    \[
        \frac{a}{\sin\alpha} = \frac{b}{\sin\beta} = \frac{c}{\sin\theta} = 2r
    \]    
\end{thm}

\begin{proof} The first paragraph is properly cut in to prevent the picture
from overlapping with text. This happens only on the first line of this
paragraph, as is expected and desired.

\killpic
Any later paragraph contained in the proof environment also has the cutin on
the first line of the paragraph. This is unexpected and undesired.

Any later paragraph contained in the proof environment also has the cutin on
the first line of the paragraph. This is unexpected and undesired.
\end{proof}

This behavior happens for every paragraph inside the proof environment, but
not in paragraphs outside the proof environment such as this one.
\end{document}

相关内容