0

When I using wrapfig2 package, I stumble across that if a theorem-like environment is not the first paragraph after wrapfigure environment, the theorem is indented correctly:

\documentclass{article}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}

\usepackage{wrapfig2}

\begin{document}
\begin{wrapfigure}{l}*
\rule{4cm}{4cm}
\end{wrapfigure}
Texts before theorem. Texts before theorem. Texts before theorem.
Texts before theorem. Texts before theorem. Texts before theorem.
\begin{thm}
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
\end{thm}
Texts after the theorem. Texts after the theorem. Texts after the theorem.
Texts after the theorem. Texts after the theorem. Texts after the theorem.
\end{document} 

output:

enter image description here

My question is, if we can write some hack code like a invisible paragraph so that a figure can be wrapped in a single theorem-like environment:

\documentclass{article}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}

\usepackage{wrapfig2}

\begin{document}
\begin{wrapfigure}{l}*
\rule{4cm}{4cm}
\end{wrapfigure}
%do something here so that the wrapfigure "works" for theorem-like environments
\begin{thm}
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
\end{thm}
Texts after the theorem. Texts after the theorem. Texts after the theorem.
Texts after the theorem. Texts after the theorem. Texts after the theorem.
\end{document} 
0

1 Answer 1

1

\leavevmode starts a paragraph (for \everypar). \hrule will end a paragraph without adding any space. However, this invisible line still counts, so you need to adjust the number of lines (optional argument).

\documentclass{article}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}

\usepackage{wrapfig2}

\begin{document}

Text before wrapfig.

\begin{wrapfigure}[1]{l}*
\rule{4cm}{4cm}
\end{wrapfigure}

\leavevmode\vspace{\dimexpr -\parskip-\baselineskip}\hrule height0pt

\begin{thm}
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
  Texts in the theorem. Texts in the theorem. Texts in the theorem.
\end{thm}
Texts after the theorem. Texts after the theorem. Texts after the theorem.
Texts after the theorem. Texts after the theorem. Texts after the theorem.
Texts after the theorem. Texts after the theorem. Texts after the theorem.
Texts after the theorem. Texts after the theorem. Texts after the theorem.
Texts after the theorem. Texts after the theorem. Texts after the theorem.
\end{document} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .