[XeTeX] \XeTeXpdffile causes over-long line unless wrapped in \hbox

John Was johnoxuk at gmail.com
Thu Apr 15 17:05:52 CEST 2021


In case it's of any relevance,  I've always boxed images, e.g.

\setbox1=\hbox{\XeTeXpdffile "image.pdf"}

That's mainly so that I can use \wd1 as the width of any caption beneath
the image (which is invoked by "\box1", of course).  I *think* from memory
that the XeTeX manual says that an image is then basically treated as if it
were a single character.  At any rate, I've never had any problems with
XeTeX not seeing the size of the image accurately, but I haven't gone into
the details of what precisely is going on (on the basis that if it ain't
broken, don't tinker).

Best wishes

John Waś



<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, 15 Apr 2021 at 15:42, Bruno Le Floch <blflatex at gmail.com> wrote:

> David got mislead.  The truth is rather stranger: it seems the width of the
> image used when placing glyphs of a given hlist on the page is different
> from
> (and larger than) the width of the image used when measuring the total box
> size.
>
> For instance "!" does not get eaten: it overlaps with the following "t".
> What
> happens in David's \imga is that the hbox is seen ("from the outside") as
> being
> a bit smaller than it really is, as if there was a space after
> \XeTeXpdffile...\relax and the same negative at the end of the \hbox.
>
> Adding a space to the line with \hbox{\img} in the original test code does
> not
> give an overfull line: there are plenty enough spaces to set the line a bit
> tighter and make it fit.
>
> No idea where in the code that comes from.
>
>
>
> On 4/15/21 4:31 PM, Jonathan Kew wrote:
> > On 15/04/2021 15:24, David Carlisle wrote:
> >> The command is scanning ahead for keywords such as  page 2 in the
> unhboxed case
> >
> > Shouldn't the \relax stop it scanning ahead anyway?
> >
> >> but in the boxed case the } stops the scan but it seems having decided
> that
> >> test is not a keyword it is inserting a space before it which seems
> wrong.
> >> More surprising is that it eats ! here even though  ! isn't part of the
> >> allowed syntax as far as I can see
> >>
> >>
> >> \def\imga{\hbox{\XeTeXpdffile "image.pdf"\relax!}}
> >> \def\imgb{\XeTeXpdffile "image.pdf"\relax!}
> >>
> >>
> >>
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> \imga
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >>
> >>
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> \imgb
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >> test test test test test test test test test test test test test
> >>
> >> \end
> >>
> >>
> >> The effect on linebreaking is more or less accidental "test" can't be
> >> hyphenated so it's not surprising that some lines can not be justified,
> and
> >> the extra space or not space after the image is changing the
> linebreaking in
> >> the paragraph.
> >>
> >> David
> >>
> >>
> >>
> >> On Thu, 15 Apr 2021 at 14:24, Gavin Smith wrote:
> >>
> >>     If I XeTeX to display an image in text, like
> >>
> >>     \def\img{\XeTeXpdffile "image.pdf"\relax}
> >>
> >>     test test test test test test test test test test test test test
> >>     test test test test test test test test test test test test test
> >>     test test test test test test test test test test test test test
> >>     test test test test test test test test test test test test test
> >>     \img
> >>     test test test test test test test test test test test test test
> >>     test test test test test test test test test test test test test
> >>     test test test test test test test test test test test test test
> >>     test test test test test test test test test test test test test
> >>
> >>     \end
> >>
> >>     and then process with "xetex test.tex" on the command line, then the
> >>     line
> >>     after the image is too long and goes into the margin.  You can see
> this
> >>     in the attached file.
> >>
> >>     I found wrapping the \XeTeXpdffile in an \hbox, thus:
> >>
> >>     \def\img{\hbox{\XeTeXpdffile "image.pdf"\relax}}
> >>
> >>     fixed the problem, but I don't see why this should be necessary.
> >>
> >>     Is this a bug?
> >>
> >>     XeTeX reports its version as follows:
> >>
> >>     $ xetex test.texi
> >>     This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/Debian)
> >>     (preloaded format=xetex)
> >>       restricted \write18 enabled.
> >>     entering extended mode
> >>     (./test.texi [1] )
> >>     Output written on test.pdf (1 page).
> >>     Transcript written on test.log.
> >>
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/xetex/attachments/20210415/ad91a23a/attachment-0001.html>


More information about the XeTeX mailing list.