[ This is an updated version of https://stackoverflow.com/questions/3233031/latex-defining-a-custom-wrapfig-environment ]
The wrapfig package interacts badly with the setup and teardown done by \begin and \end. Concretely, this is not typeset correctly:
\documentclass{article}
\usepackage{wrapfig}
\newenvironment{pullquote}
{\begin{wrapfigure}{o}{2in}\large}
{\end{wrapfigure}}
\begin{document}
\begin{pullquote}
Chicken chicken
\end{pullquote}
Chicken chicken chicken chicken,
chicken chicken chicken chicken.
Chicken chicken, chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken.
\end{document}
The "pull quote" is displaced downward to the end of the document (or to the next wrapfigure, if any) and I get a warning about collisions between wrapping environments in the log file.
But this is typeset correctly (note the dirty-trick use of the internal macros defined by \newenvironment):
\documentclass{article}
\usepackage{wrapfig}
\newenvironment{pullquote}
{\begin{wrapfigure}{o}{2in}\large}
{\end{wrapfigure}}
\begin{document}
\pullquote
Chicken chicken
\endpullquote
Chicken chicken chicken chicken,
chicken chicken chicken chicken.
Chicken chicken, chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken.
\end{document}
I am looking for concrete advice on how to fix this apparent bug in wrapfig, which AFAICT is unmaintained.
newenvthat wraps anoldenv, you should use\oldenvand\endoldenvin the definition of\newenvironment{newenv}{...}{...}. The\beginand\endcommands do some preparation to start/end the environment, which are not needed more than once. – Juan A. Navarro Aug 05 '10 at 11:34\beginand\ends before anyone notices* I did notice that (La)TeX will complain about unmatched\beginand\ends, but not if they're replaced by the requisite commands. – Andrew Stacey Aug 05 '10 at 11:49