Closed ghost closed 4 years ago
Looks like \&
was changed to be encoding specific. Simple fix:
\usepackage[greek]{babel}
\makeatletter
\DeclareRobustCommand\&{\ifmmode\ltx@amp \else \ensureascii\ltx@amp\fi}
\makeatother
Could be done a bit cleaner I guess
Thanks for a quick reply!
\ltx@amp
doesn't seem to be public interface, is your workaround supposed to be temporary until a new release of LaTeX and/or babel?xelatex
/lualatex
or should the solution be kept specific to pdflatex
and latex
compilers?Don't know, I'm not maintaining babel nor greek for babel. It is defined by the greek style for babel (or by babel, have't checked which). I would expect it also works in the Unicode engines, but I haven't checked.
The maintainer of the Greek style for babel es Günter Milde. You should contact him (the e-mail is in greek.ldf
). I guess this is just one of many changes to make a non-LICR encoding (LGR) work within LaTeX. I would switch to a Unicode engine (xetex, luatex) if it's an option.
E-mail sent. As for the suggestion of Frank, it clashes wtih soul+microtype: running pdflatex on
\documentclass{article}
\usepackage[greek,ngerman]{babel}
\makeatletter%%% Tries to work around a bug in babel 3.32, cf. https://github.com/latex3/babel/issues/53#issuecomment-598078217
\DeclareRobustCommand\&{\ifmmode\ltx@amp \else \ensureascii\ltx@amp\fi}
\makeatother
\usepackage{microtype}
\usepackage{soulutf8}
\begin{document}
\(\&\)
\hl{\&}
\end{document}
yields
! Package soul Error: Reconstruction failed.
See the soul package documentation for explanation.
Type H <return> for immediate help.
...
l.10 \hl{\&}
? X
No pages of output.
Transcript written on mwe.log.
I have no idea what microtype does so that soul thinks that executing \& has a possible hyphen inside, but debugging soul or microtype would be rather difficult and I don't have enough time to solvethat puzzle. So following the advice of soul:
\DeclareRobustCommand\&{\ifmmode\ltx@amp \else \mbox{\ensureascii\ltx@amp}\fi}
But this isn't really the right thing to do, it looks as if microtype causes a problem when there is a local encoding change to T1 or OT1 inside \hl, should be reported to Robert I guess, perhaps he can see what is wrong.
Here is an example with \textsterling, the same really happened with \&
\documentclass{article}
\usepackage{microtype}
\usepackage{soul}
% this is the default for textsterling and it works
\DeclareTextCommandDefault{\textsterling}{\UseTextSymbol{TS1}{\textsterling}}
\DeclareTextSymbol\textsterling{TS1}{163}
% this one fails also fails if I point to OT1
% the moment microtype is added
\DeclareTextCommandDefault{\textsterling}{\UseTextSymbol{T1}{\textsterling}}
\DeclareTextSymbol\textsterling{T1}{191}
\begin{document}
\pounds
\hl{a b \pounds{} c}
\end{document}
I've just made the maintainers of microtype and soulutf8 aware of the issue you reported. Since the new issue doesn't involve babel, how about a new post at SE or latex.org for this? (Btw., my workaround of the problem induced by your original definition of \& was replacing the occurrence of \hl{some text \& some other text}
by \hl{some text and some other text}
, and I don't feel I need more bugfixing beyond this as of now.) In any case, thanks for looking into this. I'm afraid that soul (even with soulutf8) needs a rewrite from scratch anyway.
neither soul nor microtype are maintained by us so the problem doesn't belong on latex-project.org or our github presence. My second suggestion does work though or explicitly doing
\hl{abc \mbox{\&} xyz}
would work too. \&
should work in math so greek would need some fixing (implemented just like \pounds
is probably the right way) but again that is not core babel but a different maintainer. But that would fail still in soul because of the issue with microtype. I couldn't see what the cause was, but perhaps Robert does.
the problem doesn't belong on latex-project.org or our github presence
I fully agree.
(phew, debugging soul is always such a blast ...)
The problem with regards to microtype
is the font change. soul
typesets its text twice: first in a vbox with a width of 1sp to get the single syllables (similar to \showhyphens
), and then later again in an hbox, whose width is compared to that of the (split-up) vbox. Because of the font change, the text will not be typeset in the tt font that soul
normally uses internally, but in a font that microtype
gets to see and transform. This alone is not the problem, however, but rather that font expansion will be applied differently in the two cases: Inside the vbox (case 1) the font will be shrunk to the maximum, while, by design, there never is any expansion in an hbox (case 2) -- this results in a mismatch of the widths which will finally make soul
stumble.
So, what I could do in microtype
is disable font expansion for the first case (the vbox):
\makeatletter
\let\MT@SOUL@doword\SOUL@doword
\def\SOUL@doword{\pdfadjustspacing=0 \MT@SOUL@doword}
\makeatother
which would at least solve the problem for \&
or \pounds
.
But of course, soul
remains awfully fragile -- even \def\pounds{Pounding}
will fail, with or without microtype
...
Robert, thanks for looking into this!
@FrankMittelbach , @schlcht : To avoid cluttering this bugreport, let us move the discussion concerning microtype
and soul
to https://latex.org/forum/viewtopic.php?t=33292 and let this bugreport to track the issue of \&
in math mode when the greek module of babel is loaded.
@jbezos : Thanks for your patience; no answer from Günter Milde yet.
@jbezos Have you received the file from Günter? (Several days ago, he replied to me with a bugfix, and I tested it.)
@MdAyquassar No, I haven't, or at least I cannot find it.
Dear Javier: Why have you closed the bug report then? Perhaps, you could wait until Günter (in "Cc:") comes with a new greek.ldf. In my understanding, he has something to say (at least I have seen a bug fix), but I would not like to speak instead of him.
Cheers, Md Ayquassar
22.03.2020, 15:10, Javier Bezos notifications@github.com
@MdAyquassar No, I haven't, or at least I cannot find it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
The error is not in babel, but in a package I'm not maintaining and I don't have to take any further action from my part.
@MdAyquassar JFYI, I've noticed Günter has released the new version: https://ctan.org/pkg/babel-greek .
@jbezos Given that you closed the issue report and given your earlier message https://github.com/latex3/babel/issues/53#issuecomment-602505546, I don't have to continue any conversation with you here on this topic.
Running
pdflatex
on the inputprints the following to the log and to tty:
But, the ampersand is supposed to be used in both math and text modes, isn't it?
The same problem persists if you retain the
greek
option but add (probably) any other language (try, say,[greek,ngerman]
instead of[greek]
).The PDF output looks ok, though.
An up-to-date Ubuntu 19.10 stock TeXLive installation is used, which has (according to the log) pdfTeX 3.14159265-2.6-1.40.20, LaTeX2e 2018-12-01, article 2018/09/03 v1.4i, babel 3.32, and lgrenc.def 2015/12/07 v0.13.1.
Any bugfix? Thx in advance.