[Tex/LaTex] How to prevent \parpic from cutting into every paragraph inside a proof environment

picinstheorems

When using \parpic to put an image next to a short theorem it will cut into every paragraph in the next proof environment if the picture spans beyond the theorem. The following MWE and its output better illustrate the problem. How can I correct this behavior?

\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}

output

Best Answer

Picins works by redefining \par to restore \hangindent after the end of each paragraph. Anyway, using \killpic AFTER the last paragraph indented will fix this and any following paragraph.

\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}
Related Question