-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading the unicode-math package breaks mhchem math #459
Comments
The problem is that in math mhchem surrounds everything with
Imho it would be very useful to have a official way command to "break out " of a \mathrm as this is used internally by packages (see also #438). |
So, is this a bug with |
Well difficult to say. The problem is that this here gives a different output if
So the question is if mhchem can rely on the first output or not, and if unicode-math should ensure it or not. |
Unlike |
@krishnakumarg1984 What is your reasoning why |
@mhchem, a variant of @u-fischer 's example removes amsmath showing it's really a unicode-math issue.
this gives roman in unicode-math and italic with pdftex |
@davidcarlisle But I wonder if unicode-math can really avoid it. I mean it would have to reset the Umathchar codes at every math to make sure to nullify some \mathXX command. |
@u-fischer not sure it seems to me that setting \fam should be enough. |
@davidcarlisle I don't think that \fam1 as in the tex.sx answer works. It actually uses the cmmi-fonts:
|
@u-fischer I guess you are right, perhaps
or higher level way to get unicode-math to put things back in nested contexts |
There is so much setting and reseting of mathcodes that I get a bit lost sometimes :)
The reason using \fam doesn’t work is that the mathcodes for ascii need to be set to plane 1 for regular maths to work. It looks here, though, like I should perhaps patch \mbox to call \mathnormal if it’s already inside maths mode?
|
@wspr patching \mbox wouldn't work in most cases eg ams\text (which is actually what gets used here) use \hbox in \mathchoice, you could patch \everymath but that seems a bit costly as well. as nested math in a \mathxxx is probably rare, an alternative plan would be to document that unlike the classic setup the setting is inherited by a nested math construct (which to be honest is I would guess what most people expect from \mathrm{\hbox{$x$}} and then @mhchem could use \ensuremath{\mathnormal{... to normalize the nested math constructs back to math italic. perhaps.. |
which means that my \fam=-1 answer at stackexchange is wrong so I'll delete (mentioning here for those who can't see deleted tex.sx posts) |
I also think that resetting everything all the time would be too costly and \mathnormal looks like the "official way to break out of \mathrm" I asked about above. But beside this: the use of \mathrm feels wrong in this context. I'm not quite sure what the code really wants to achieve. But if it wants actually the upright math style, a local version of Btw: perhaps it would be useful to have "switch" variants of the sym-commands. E.g.
But as I don't understand what exactly |
Can the Unicode-math team officially announce using chemformula as a viable workaround, until @mhchem and unicode-math team are able to figure out a solution? I am a bit surprised this hasn't been reported so far. Aren't there any chemistry folks using Unicode fonts? |
@krishnakumarg1984 I'm a chemist but (1) use |
@krishnakumarg1984 I don't understand your problem. The work-around I suggested at the tex.sx question should work fine.
|
@u-fischer I am sorry if I misunderstood, but I thought that the solution you proposed worked only in certain cases, i.e. your answer said "But it doesn't work if the argument doesn't consist of a single char". Secondly, such kind of low-level kernel-hacks by inspecting document stack-trace defeats the purpose of the For an electrical engineer like me, looking to describe a few chemical equations in my thesis and move on, On the other hand, |
My solution doesn't work for more than one char as mhchem actively sets another font in such cases, this is independant from unicode-math. It is not the task of unicode-math to maintain long lists about problematic package -- it is the documentation of mhchem which should mention this. Beside this: your bug report is one day old and you already have a work-around, people analyzed the problem and also the maintainer of mhchem got involved in the discussion, so be a bit more patient. |
@u-fischer Sorry about that. I have anyway moved on using the workaround in my thesis. Sorry for the noise. My heartfelt thanks to you, David Carlisle, Will Robertson, Joseph Wright and mhchem for actually taking a deep look and analysing the issue. Never did I expect the bug to get such attention from TeX heavyweights .... :) |
@u-fischer I tried to update mhchem in a way so that it works with unicode-math and without. At first, |
@mhchem I would need an example document to play around. And could you say which fonts |
@u-fischer mhchem uses the text font when called from a text environment. And it uses the (upright) math font, when called from a math environment. For layout (superscript and subscript) it uses the math mode (and switches to However, not all things are upright in a chemical formula. Some things are mathematics like a subscripted variable x. For this, I need a way to switch from So, I am looking for an alternative for |
I did understand what mhchem is doing now. But does it switch to mathrm because of a logical reason, or only "to get the correct output"? As an example lets assume that the text font, mathrm and the math font are really different looking fonts (lmodern, Arial and Cambria in the example below). Which output do you want to get in such a case?
|
Good question. When used in running text, When used in a math environment, like |
"the math font" doesn't make sense. \mathrm is not "the" math font, it is one of a variety of math alphabets. And you didn't answer the question why do you use in math \mathrm instead of \symrm or switching to text mode with \text. But imho this is no longer an issue for unicode math and you should perhaps move the discussion to a better place. |
"the math font" means: the set of mathematical alphabets, as you call them. Scientific typography follows certain rules. Variables are printed in italics, operators etc. are not. This is the reason, why the sinus operator is not I still think, it is a unicode-math-related issue, because it is this package that introduces this inconsistency and breaks the behavior of existing documents and packages that now are forced to adapt. |
I still think, it is a unicode-math-related issue, because it is this
package that introduces this inconsistency and breaks the > behavior of
existing documents and packages that now are forced to adapt.
Well not really, as I mentioned on tex.sx the underlying mechanisms are
completely different and unicode-math hides the differences as far as
possible but in this case not enough for you not to notice.
in classic tex math usually uses 16 different fonts and \mathrm switches to
one of them and 9at the primitive tex level) that switch is not seen by
nested math contests so nested math starts off again in italic.
when using a Unicode Math font then (normally) all teh symbols come from a
single font and math italic is not just the normal ascii slots in a math
italic font the characters are translated up to the plane 1 1Dxxx Unicode
Math range, so at the primitive level this is inherited in nested math
contexts.
So the difference is not due to the unicode-math package it is because you
are using a Unicode math font and Unicode math layout engine.
|
@mhchem I know than \sin is typeset in a upright font. But the font used is
Beside this: I don't know much about chemical typesetting but I got the impression that in the tex.sx question align wasn't used to get a math font but to get math alignment. |
Yes. I used align environment to align the equations at their reaction arrows (as per the mhchem manual) |
I find it strange to have a different font for chemistry depending whether you are in a math environment or not… |
@davidcarlisle, I think we got lost in the fine-details of language. Sorry, my English is a foreign language for me. I did not mean to say that unicode-math does anything wrong. I just wanted to say the issue we discuss here is related to unicode-math, because, to a user, it looks like "when I load unicode-math, my documents look different than before". @krishnakumarg1984 Currently, there is no option to use Anyway, I will update mhchem to detect the presence of unicode-math. @u-fisher thanks for pointing me to the issues with beamer. It really does a strange setup. @ArchangeGabriel The possibility to use |
Fixed with mhchem v4.08 (2018-06-22), uploaded to CTAN a few minutes ago. |
Description
Loading
unicode-math
breaks the math-mode typesetting of chemical formulae provided by themhchem
package. Link to the stackexchange discussion (provided below) gives a more detailed description.Check/indicate
Minimal example demonstrating the issue
Further details
The text was updated successfully, but these errors were encountered: