Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Images

25 views
Skip to first unread message

Ian Fantom

unread,
Nov 2, 2024, 7:45:19 AM11/2/24
to latexus...@googlegroups.com
Having moved from pdflatex to xelatex compiler, I now find my images are
sometimes misplaced. I've searched quite a bit, but I'm still confused.

For instance, with xelatex:

    \begin{wrapfigure}{R}{0.6\textwidth}
        \centering
\includegraphics[width=0.6\textwidth]{pictures/extremismaen-img019.png}
        \caption[0.6\textwidth]{\emph{David Cameron at the UN Security
Council: ideology of extremism.}}
    \end{wrapfigure}

places the image on the left-hand-side, with only a blank on the right,
and so no wrapping.

Yet the same configuration for a different image, with a different
caption a couple of paras lower gives the image on the right-hand-side
with para text on the left, as required. But I get a warning message:
"Collision between wrapping environments".

I'm confused over when to use wrapfigure, figure and float, and which
configurations should work on xelatex.

Sorry to keep coming back. There must be something somewhere that I've
missed, though I bought two beginners books on Latex and one PhD Thesis
Latex book before embarking on this venture!

Thanks in advance!

Ian.

Peter Flynn

unread,
Nov 2, 2024, 12:19:48 PM11/2/24
to latexus...@googlegroups.com
On 02/11/2024 11:45, Ian Fantom wrote:
> Having moved from pdflatex to xelatex compiler, I now find my images are
> sometimes misplaced. I've searched quite a bit, but I'm still confused.

If the file is unchanged, and the fonts are unchanged, there should be
no differences. However, pdflatex uses the old Postscript Type1 fonts,
and xelatex (with the fontspec package) uses their TrueType equivalents.

Can you check to see if the line-breaks are the same in all paragraphs?

> For instance, with xelatex:
>
>     \begin{wrapfigure}{R}{0.6\textwidth}
>         \centering
> \includegraphics[width=0.6\textwidth]{pictures/extremismaen-img019.png}
>         \caption[0.6\textwidth]{\emph{David Cameron at the UN Security
> Council: ideology of extremism.}}
>     \end{wrapfigure}
>
> places the image on the left-hand-side, with only a blank on the right,
> and so no wrapping.

Can you create a minimal worked example that we can run with both
processors to see this happen? Then we can check the log files and try
to work out what it's doing.

> Yet the same configuration for a different image, with a different
> caption a couple of paras lower gives the image on the right-hand-side
> with para text on the left, as required. But I get a warning message:
> "Collision between wrapping environments".

I don't use wrapfig, so I'm not familiar with that. Are you using the
same TeX Live installation for both processors, or are they different?

> I'm confused over when to use wrapfigure, figure and float, and which
> configurations should work on xelatex.

They all work on all processors. The "figure" environment is the normal
use for figures.

1. Figures, of course, like Tables, are *floats*, because they are not a
part of your textual argument, but illustrations that can be positioned
a little away from the text to allow typesetting to proceed; but usually
only moved to the top or bottom of the page, or in some circumstances to
the next page, according to the positioning hint[s] you provide as the
optional argument [t,b,h,p]. The basis is that if a figure simply will
not fit on what's left of the page, then it *has* to be moved. Also, if
it is too big outside the paramaters defined in the default LaTeX, then
it will be moved to occupy the whole of the next page.

2. The "float" package lets you create new types of float,such as
"example" or "exercise", using figure and table as models. The package
also adds one new float positioning hint, "H" (capital) which means
Here, REALLY HERE, and break any rules needed to make it fit...with of
course one exception, if it really, really, really won't fit, it *has*
to go to the next page. Also (warning) the "H" positional hint BREAKS
the flow of serial numbering. It tries to fake it up so that no-one
notices, but occasionally some manual adjustment is needed.

3. The "wrapfig" package is just a way to put a small figure in the
corner of a paragraph, and have short lines wrap round it. The paragraph
MUST be long enough to allow the right number of lines height for the
figure AND still have text left over to carry on typesetting at full
width underneath. There are numerous parameters to try and compensate
for unusual circumstances. I've never used such a design, but it seems
to be quite popular.

> Sorry to keep coming back. There must be something somewhere that
> I've missed, though I bought two beginners books on Latex and one PhD
> Thesis Latex book before embarking on this venture!

I'm sorry you're having trouble with this. I switched my entire
consultancy's processing from pdflatex to xelatex over a weekend, with
only two files needing editing (they used heavily customised fonts). But
that may have had to do with us not writing LaTeX by hand: it's all
generated from XML documents using XSLT, so the formatting tends to be
light, and as generic as we can make it.

If you can make a test file that illustrates the problem, that would be
very useful.

Peter

Ian Fantom

unread,
Nov 3, 2024, 3:30:13 PM11/3/24
to latexus...@googlegroups.com
Strangely, I've been unable to create a minimal test file to show the
problem. Between asking the question and receiving your reply I looked
at all the preceding images in the same document, and made some
adjustments. No problems there. Then when I checked on the image that
had been causing the problem I found it was appearing correctly. In
enlarging some of the other images I'd changed the lines layout and
hence the position of the problematic image. So it looks as if there may
have been some anomaly somewhere. Either that or the software had got
itself tied up in a knot. There was a case fairly recently when it
wasn't compiling the pdf file, and eventually I closed it all down and
called it up again, then lo and behold, everything worked. Unfortunately
I no longer remember exactly what the issue was. At least I'll recognise
such problems if they should arise in the future.

One thing I noticed is that on quitting TexStudio it remembers all the
files given in the tabs, so that when I start it up again for a
different document there can be some confusion. I have to delete all the
tabs before exiting. That might just have accounted for some of the
problems.

Yes, I use only one Tex installation. It's TexStudio. When I do 'tex --
version' I get:

    TeX 3.14159265 (TeX Live 2017/Debian)
    kpathsea version 6.2.3

The only mystery remaining is the use of \caption, as in:

\caption[0.6\textwidth]{\emph{David Cameron at the UN Security Council:
ideology of extremism.}}

I've tried different decimals instead of '0.6', and they don't to make
any difference. Every time the caption text takes the width declared in
wrapfigure, left-adjusted. That's not an immediate problem, but if the
answer if easy it's worth having it.

Many thanks, Peter. If ever you're in Halifax I'll buy you a pint!

Regards,

Ian

Peter Flynn

unread,
Nov 3, 2024, 6:40:20 PM11/3/24
to latexus...@googlegroups.com
On 03/11/2024 20:30, Ian Fantom wrote:
> Strangely, I've been unable to create a minimal test file to show the
> problem. [...] I'd changed the lines layout and
> hence the position of the problematic image.

One of the hidden benefits of creating a Minimal Worked Example is that
the discipline of doing it often reveals the problem :-)

> One thing I noticed is that on quitting TexStudio it remembers all the
> files given in the tabs, so that when I start it up again for a
> different document there can be some confusion.

That sounds like something the designers though would be a benefit...but
only to people who have one single project at a time.

> \caption[0.6\textwidth]{\emph{David Cameron at the UN Security Council:
> ideology of extremism.}}

Ouch. No. The optional argument for \caption is to provide a short
version of the caption for use in the List of Figures or List of Tables.
I'm not clear what you're hoping to achieve with giving a dimension. You
should be writing

\caption[Davis Cameron at UN]{David Cameron at the UN Security Council:
ideology of extremism.}

If you want captions italicised, use one of the captioning packages
which lets you format captions without needing to type \emph every time.

> I've tried different decimals instead of '0.6', and they don't to make
> any difference. Every time the caption text takes the width declared in
> wrapfigure, left-adjusted.

I sincerely hope the wrapfig package does not change the usage of the
optional argument to \caption. That would be a very bad design move.

> Many thanks, Peter. If ever you're in Halifax I'll buy you a pint!

Alas unlikely, but who knows, thank you very much!

Peter
Reply all
Reply to author
Forward
0 new messages