Hi, I was tracing \mathchar created nodes in text mode and they are just a simple glyph nodes with subtype 256. The problem is that there is no how to control the output changing the text font. It's ok if engine throws messages about missing characters in font. But if current font has a different character in this slot that is a problem. Documentation says that this command is allowed in text mode: """""" The commands \mathchar, and \Umathchar and control sequences that are the result of \math- chardef or \Umathchardef are also acceptable in the horizontal and vertical modes. In those cases, the \textfont from the requested math family is used. """""" but maybe could be any other subtype assigned to the glyph node that these characters could be traced down and one could write some control functions (for example error "\mathchar is not allowed in text mode") What do you think? Thanks, Linas
---- On Thu, 21 Mar 2019 13:03:10 +0100 Linas Stonys
Hi, I was tracing \mathchar created nodes in text mode and they are just a simple glyph nodes with subtype 256. The problem is that there is no how to control the output changing the text font. It's ok if engine throws messages about missing characters in font. But if current font has a different character in this slot that is a problem.
Hi, I do not understand the problem about different characters in the slot: Why would a different character in the current font cause a problem, the mathchar will not be influenced by the current text font anyway, it uses the font set for inline math. That font needs the right characters at the selected slots, but that should be a given. Best regards, Marcel Krüger
[...]
On 3/21/2019 1:03 PM, Linas Stonys wrote:
Hi, I was tracing \mathchar created nodes in text mode and they are just a simple glyph nodes with subtype 256. The problem is that there is no how to control the output changing the text font. It's ok if engine throws messages about missing characters in font. But if current font has a different character in this slot that is a problem.
Documentation says that this command is allowed in text mode:
"""""" The commands \mathchar, and \Umathchar and control sequences that are the result of \math- chardef or \Umathchardef are also acceptable in the horizontal and vertical modes. In those cases, the \textfont from the requested math family is used. """"""
but maybe could be any other subtype assigned to the glyph node that these characters could be traced down and one could write some control functions (for example error "\mathchar is not allowed in text mode")
What do you think? 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 Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
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. lets say \mathaccent doesn't compile in text mode but \mathchar does. 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.
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
---- On Thu, 21 Mar 2019 14:51:25 +0100 Linas Stonys
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
Produces three Γ with lualatex TL2018. First one is missing char. And I can't reproduce bad example with the wrong symbol because it was a huge file and I can't find it now. \documentclass{article} \usepackage{amsfonts} \begin{document} \Gamma $\Gamma$ \Gamma $\Gamma$ \end{document} On 3/21/2019 4:14 PM, Marcel Krüger wrote:
---- On Thu, 21 Mar 2019 14:51:25 +0100 Linas Stonys
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
the reason that \mathchar and \mathchardef does not produce an error message when processed outside mathmode is that Don decided that this is a good way to store numbers and to be used in programming. If that would suddnely raise error this would kill a lot of lowlevel code this is similar to other places, eg if you say \newbox\foo and then \foo instead of \box\foo you end up with a printed symbol (no error message, etc. In my opinion those optimizations can't be taken out of the TeX program without invalidating too much frank
Am Thu, 21 Mar 2019 16:54:39 +0200 schrieb Linas Stonys:
First one is missing char.
\documentclass{article} \usepackage{amsfonts}
\begin{document} \Gamma $\Gamma$ \Gamma $\Gamma$ \end{document}
You get a missing char here as math hasn't been setup yet. Something like \begin{document}\setbox0\hbox{$x$} should fix this. -- Ulrike Fischer http://www.troubleshooting-tex.de/
participants (5)
-
Frank Mittelbach
-
Hans Hagen
-
Linas Stonys
-
Marcel Krüger
-
Ulrike Fischer