1

To write a report I am using the package wrapfigure which generates figures on a side and the text flows around it.

It is not news that it is very difficult to handle the spacing and positioning of wrapfigure, which requires a lot of manual tweaking. But when one gets it right, the results are beautiful; so it is worth the pain.

The problem at this point is that I am generating drafts and along editions I have to adjust every single wrapfigure environment to keep the draft even readable (the figures very easily overlap with the text). So what I thought is that I can use the figure environment for drafting and switch to wrapfigure only in the final version.

The wrapfigure enviromnent is used like this:

\documentclass{article}
\usepackage{wrapfig}
\begin{document}

\begin{wrapfigure}[26]{r}{0.5\textwidth}
my graphics here
%\includegraphics{...}
\caption{...}
\end{wrapfigure}

\end{document}

So, I though I can redefine wrapfigure inside my document to be such that the above is translated as

\begin{figure} %arguments ignore
\includegraphics{...}
\caption{...}
\end{figure}

So I imagine that I can do this:

% comment following line for final version
\renewenvironment{wrapfigure}[???]{\begin{figure}}{\end{figure}}

My problem is that wrapfigure takes three arguments that when working as a figure in the draft are going to be ignore.

What do I have to put in ??? to have a compatible syntax?

In otherwords how I redefine wrapfigure so that this line \begin{wrapfigure}[26]{r}{0.5\textwidth} behaves simply as \begin{figure} with the extra arguments ignored.

1 Answer 1

3

The syntax for \begin{wrapfigure} is

\begin{wrapfigure}[<number>]{<letter>}[<dimen>]{<dimen>}

You can use xparse:

\usepackage{xparse}
\usepackage{wrapfig}

\RenewDocumentEnvironment{wrapfigure}{omom}
 {\begin{figure}}
 {\end{figure}}
2
  • ok, I have to learn xparse once and for all. Do you know if it is possible to give a certain width to the figure float (not necessarily to the include graphics)? The captions now look too wide. And if so how can I pass the width argument to the internal figure argument?
    – alfC
    Nov 19, 2015 at 7:59
  • 1
    @alfC Either use caption features like \captionsetup[figure]{margin=3cm}, if you load caption. Otherwise you have to patch \@makecaption.
    – egreg
    Nov 19, 2015 at 8:23

You must log in to answer this question.

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