reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
187 stars 52 forks source link

Hook code inserted in caption affects spacing #575

Closed davidcarlisle closed 1 year ago

davidcarlisle commented 1 year ago

See

https://tex.stackexchange.com/a/669374/1090

A write to the lof file is added by polygossia but this means

xxx
\caption{...}

has a paragraph ending xxxSPACE\write...{...} so forces a spurious line if xxx happens to be full width, including the common case of a full width image.

jspitz commented 1 year ago

Thanks, @davidcarlisle. I do not fully understand what is going on here. Would adding \par before the code we write be a sane fix or just an ugly workaround?

davidcarlisle commented 1 year ago

possibly better would be \ifhmode\unskip\fi just in case someone has a non standard caption that is not set in vmode.

what is happening is end of paragraph does one implicit \unskip to remove any space from a final end of line but if you have

aaaa
\write{}\par

the unskip just sees the write whatsit, so removes nothing. The space after aaaa may be "lost" with \parfillskip but if, as in the linked example, it does not fit you get a linebreak at the space and a final line that is all white, with just parfillskip, so looks like vertical space.

I did not trace everywhere polyglossia is adding whatsits, just observed the behaviour here.

jspitz commented 1 year ago

Thanks for the explanation and the suggestion, committed.

Let's see whether there are other such cases (I don't think so).

TheReallyDumbDane commented 1 year ago

Thanks for the explanation and the suggestion, committed.

Let's see whether there are other such cases (I don't think so).

@jspitz Any idea when the patch will be released?

jspitz commented 1 year ago

No, there are no release plans yet. We just had a release recently.