[Dev-luatex] \mathchar feature request

Marcel Krüger tex at 2krueger.de
Thu Mar 21 15:14:12 CET 2019


 ---- On Thu, 21 Mar 2019 14:51:25 +0100 Linas Stonys <lstonys at vtex.lt> wrote ----
 > the problem is that this command appears not in math mode.
 > Then it takes \textfont for character to output.
 > For example one forgot \Gamma to write as $\Gamma$ and he/she
 > used some packages where \Gamma appeared in pdf. But such a file comes 
 > to publishing system where different packages and different fonts are 
 > used this \Gamma will silently become some other character.

Sorry, I think I am missing something here but I still do not see your point.
If someone forgot to write $\Gamma$ instead of \Gamma
and \Gamma is a \mathchar, then \Gamma is printed outside math mode with the
appropriate \textfont. But if he would have written $\Gamma$, basically the same thing
would have happened:
The Gamma would still be written with the same \textfont, so the same slot + the same font => The same character.
How can this silently become another character? The only difference is that there are no mathon/mathoff nodes
around it and \everymath is not called.

Is the problem that `\everymath` would have changed your math fonts but this doesn't happen for non math mode mathchars? 

 > 
 > lets say \mathaccent doesn't compile in text mode but \mathchar does.
 > 

What does \mathaccent has to do with this? Are you concerned that a \mathchar might be implemented using \mathaccent in
other packages?

 > luatex sources just outputs:
 > void math_char_in_text(mathcodeval mval)
 > {
 > ....
 > p = new_char(fam_fnt(mval.family_value, text_size), mval.character_value);
 > }
 > 
 > that's why I'm asking about some other subtype that I could control
 > such situations.

I do not think that this would be a bad idea, I just do not see why you need it in this situation.

But if this LuaTeX team does not want to implement this, you might be able to detect such characters by scanning
for glyph nodes using a math font and not being inside a mathon/mathoff pair


Best regards
Marcel Krüger

 > 
 > > subtypes already have a defined meaning
 > > 
 > > but you can consider setting an attribute in mathmode (with everymath) 
 > > so that you can then (wherever) check if a character originates in math
 > >



More information about the dev-luatex mailing list