4

To produce html and pdf files from the same set of sources I need to transform all wrapfigure environments (package wrapfig) to standard figure environments. One example is:

\begin{wrapfigure}[15]{i}{0pt}
\includegraphics[width=0.40\textwidth]{parabola}
\caption{La traiettoria bla bla.}
\label{fig:parabola}
\end{wrapfigure}

Defining something like this (and not loading wrapfig package):

\newenvironment{wrapfigure}[3]{\begin{figure}[htb]\centering}{\end{figure}}

works but leaves an annoying ']i0pt' between image and caption. Any idea (except manual editing of the resulting html...) Thanks!

2
  • 3
    try: \newenvironment{wrapfigure}[3][]{\begin{figure}[htb]\centering}{\end{figure}} but I suppose that it has more optional arguments
    – user2478
    Jul 29, 2011 at 15:49
  • 1
    You might also want to look at the xparse package.
    – mbork
    Jul 29, 2011 at 16:47

1 Answer 1

7

The wrapfig manual states that the syntax is:

\begin{wrapfigure}[<number of narrow lines>]{<placement>}[<overhang>]{<width>}
    <figure>
\end{wrapfigure}

Note the two optional and two mandatory arguments. You need to define a replacement which removes all of this possible arguments. This is possible by removing the first two with as environment arguments and then use a gobble macro to remove the other two:

\newcommand{\gobbleom}[2][]{}
\newenvironment{wrapfigure}[2][]
    {\begin{figure}[htb]\centering\gobbleom}
    {\end{figure}}

You could also use the xparse package to define an environment with two such optional arguments:

\usepackage{xparse}
\DeclareDocumentEnvironment{wrapfigure}{omom}
      {\begin{figure}[htb]\centering}
      {\end{figure}}

Using xparse is very useful if you want to redefine very complicated macros or environments. However, if you want to reduce the number of used packages I would go with the first method.

You must log in to answer this question.

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