Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
3  
try: \newenvironment{wrapfigure}[3][]{\begin{figure}[htb]\centering}{\end{figure}} but I suppose that it has more optional arguments –  Herbert Jul 29 '11 at 15:49
1  
You might also want to look at the xparse package. –  mbork Jul 29 '11 at 16:47

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.