[texhax] Interaction between \iffodd and wrapfig

David Carlisle d.p.carlisle at gmail.com
Fri Dec 11 16:30:30 CET 2015


wrapfig can't possibly work if you put it in an \mbox, It can't work if you
put it in a _group_ never mind a box as it needs to set the paragraph shape
of the following paragraph.

The comments in the file say:


  - If you put a wrapfigure in a parbox or a minipage, or any other type
    of grouping, the text wrapping should end before the group does.


On 11 December 2015 at 15:17, Hefferon, James S. <jhefferon at smcvt.edu>
wrote:

>
> Hello everyone,
>
> I am trying to put graphics in a document using wrapfig.  I want a graphic
> to be wrapped on one side of the page on odd pages, and on the other side
> on even pages, so it would be on the outside in both cases.
>
> To determine if the current page is odd I use the changepage package's
> \checkoddpage and \ifodd construct, as in the mwe below.
>
> But the mwe document below does this:
>
> * if wrapfig is commented out then I get just what I expect, a bunch of
> K's followed by a bunch of O's at the start, where I invoked the macro
> \margingraphic. That is what I expect.
>
> * if wrapfig is uncommented then the K's appear where I put them, but the
> O's now appear at the very end of the document, after \lipsum[8] (and on
> the left).  That is not what I expect.  (I certainly compiled twice.)
>
> I am stumped.  I'd be most grateful for a push in the right direction.
>
> Thanks,
> Jim
>
> \documentclass{article}
> \usepackage{graphicx, caption}
> \usepackage{changepage}
> \usepackage{wrapfig}
>
> \makeatletter
> % Figures sticking into the margin.
> % \margingraphic -- graphic that sticks out into margin
> % #1 width of graphic (before it is shifted)
> % #2 graphic filename
> % #3 caption
> \newcommand{\margingraphic}[3][0.2\textwidth]{%
>   \mbox{\checkoddpage\ifoddpage% changepage docs recommend the \mbox{..}
>     KKKKKK
>       \begin{wrapfigure}{R}{0.3\textwidth}
>         OOOOO
>       \end{wrapfigure}
>     \else%
>       % \begin{wrapfigure}{L}{0.3\textwidth}
>           EEEEEE
>       % \end{wrapfigure}
>     \fi}%
> }
> \makeatother
>
> \usepackage{lipsum}
> \begin{document}
> \margingraphic{ctan_lion.png}{test caption}
> \lipsum[1-5]
>
> \lipsum[6-8]
> \end{document}
>
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org
>



-- 
http://dpcarlisle.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20151211/536e9a67/attachment.html>


More information about the texhax mailing list