# [OS X TeX] wrapfig problem

Ross Moore ross.moore at mq.edu.au
Mon Sep 13 17:51:42 EDT 2010

Hi Themis,

On 14/09/2010, at 4:46 AM, Themis Matsoukas wrote:

> I am using wrapfigure but I have run into a problem. Apparently, sometimes a figure is moved to a place that causes latex to quit without producing a pdf. The error message is:
>
> [8
> ./proposal.tex:326: pdfTeX error (ext4): \pdfendlink ended up in different nest
> \AtBegShi at Output ...ipout \box \AtBeginShipoutBox
>                                                  \fi \fi

This coding is related to creating extended hyperlink anchors.
Are you trying to make the image into a clickable link?

Best is to first set up the figure and links in a box;
e.g. using TeX's \setbox  macro or its LaTeX equivalent.
Then when you put it onto the page, with \box or \usebox,
those trickier aspects do not need to be revisited.

test this kind of strategy.

> l.326
>
> ./proposal.tex:326:  ==> Fatal error occurred, no output PDF file produced!
> Transcript written on proposal.log.
>
> By moving (with quite a bit of trial and error) the offending wrapfigure, or commenting it out, things return to normal. The problem is that this situation can show up unexpectedly during editing, since adding/removing text moves figures around.

Any macro that has to test for different places to cut text,
to decide whether it goes in one place or another, is susceptible
to this kind of problem.

In fact, I now think that you have a hyperlink in the text that
goes at the side of the figure. Is this correct?
If that anchor-text is such that it starts in the portion
that needs to be placed next to the figure, but finishes
within the normal paragraphing that goes below the figure,
then there is the potential for trouble of this kind.

>
> Does anyone know of a solution? Or perhaps can suggest a better alternative to wrapfigure?
>
> Thanks
>
> Themis
>
> PS: I am using wrapfigure inside memoir. I don't know if the conflict is specific to memoir, or a general conflict with latex.

The file  wrapfig.sty  includes its own documentation.
Among it is the following:  (dated 2003)

>> Some idiosyncrasies:
>>
>>   - You must not specify a wrapfigure in any type of list environment or
>>     or immediately before or immediately after one.  It is OK to follow
>>     a list if there is a blank line ("\par") in between.
>>
>>   - 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.
>>
>>   - It does work in two-column format, but are your figures that small?
>>
>>   - It may be out of sequence with regular floats.
>>
>>   - The hlines that may be printed above and below floats are ignored;
>>     you must insert them manually if desired.
>>
>>   - "\linewidth" is now adjusted within the wrapped text, but since it
>>     can only be set for whole paragraphs at a time, it will persist with
>>     the wrong value after the wrapping, until the paragraph is finished.
>>
>> New wrapping environments may be added when new float types are defined
>> (using memoir.cls, float.sty, or ccaption.sty).  Any wrapping environment,
>> "wrapfigure", "wraptable", or something else may be invoked using the
>> "wrapfloat" environment, as in "\begin{wrapfloat}{figure}{O}{5cm}".
>>
>> To use float.sty properly, load package "float" before "wrapfig",
>> and declare any new float types after loading both.  Likewise for
>> ccaption.sty and "\newfloatlist" and memoir.cls and its "\newfloat".

These may not be the only idiosyncracies when hyperref is involved,
as it make many redefinitions of other packages' macros.

Other packages might be more stable, for wrapping text around
figures in some situations, but I'd doubt that they do not face
similar problems.

Hope this helps,

Ross

------------------------------------------------------------------------
Ross Moore                                       ross.moore at mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114
------------------------------------------------------------------------