TeX has two "math italic" fonts with different italic corrections. Here's a comparison from quicklatex for fff\mathnormal{fff)\mathit{fff):

KaTeX doesn't support \mathnormal but renders all italic text as if it is mathnormal. This is correct in the default, but is not how \mathit is supposed to work.
This might be why we have two italic fonts (Main and Math) but I'm not sure. We should investigate how TeX does this.
P.S. We might also look at what MathJax does, as it gets this right.
The \mathit should use text italic fonts, KaTeX-Main-Italic.
Agreed: \mathit should use text italic fonts but remain in math mode. (I guess this doesn't explain Main vs. Math then.)
KaTeX-Math-Regular and KaTeX-Math-Italic have pretty much the same glyphs except KaTeX-Math-Italic has a solidus. All of the glyphs in both are all in italics. The contain upper and lowercase Latin and Greek letters.
I think we should get rid of KaTeX_Math_* and move any glyphs that don't already exist in KaTeX_Main_* already to those font files.
In LaTeX, math and text fonts can be different. We don't support that yet in KaTeX; will we ever want to? If so, \mathit and \textit would then need to load different fonts...
@edemaine what are some of the differences?
@kevinbarabash They aren't different by default, but you can \usepackage{euler} for example to use Euler math fonts, but keep text font the same (Computer Modern by default); or \usepackage{crimson} to use Crimson for the text font, but keep math font the same (Computer Modern by default). If we want to eventually support font changing like this, we might be careful when defining \mathit to behave like \textit.
I don't think this affects the decision to remove KaTeX-Math-*. Those are all still Computer Modern, so there's no point in having two copies. More about the internal code logic.
Interesting. It sounds like we need some sort of mapping to say which font either math fonts or text fonts are pointing to. At least initially they'd point to the same font.
math font | alphabet / greek | number / Greek
---------- | ----------------- | ---------------
(default) | wide spacing
(Math-Italic) | normal
(Main-Regular)
\mathnormal | wide spacing
(Math-Italic) | old-style / italic, wide spacing
(Caligraphic / Math-Italic)
\mathit | narrow spacing / ?
(Main-Italic / Math-Italic) | italic, narrow spacing
(Main-Italic)
Related: #584
@ylemkimon can you please add to options the old behaviour?
@rokyed If you need \mathnormal behavior for \mathit, you can define a macro, "\\mathit": "\\mathnormal".
@ylemkimon I have latexes stored on the back-end, that I can't modify them anymore, adding mathit or mathnormal on them it's impossible since I'm front-end, my only fix was to revert the version to 0.9.0 which is not ideal. Also all our latex uses multiline and multiline with aligned signs and from what I tested, it's not ideal to write macros. My only solution would be to fork the repo and revert your solution in order to get back the old behaviour, but that's unrealistic. This behaviour was present on every piece of text before. Thanks.
@rokyed You don't need to change your LaTeX at all. You just need to call KaTeX with options that includes {macros: {"\\mathit": "\\mathnormal"}}. See https://katex.org/docs/options.html
You asked for an option to revert to the old behavior. Our point is that already is such an option, namely the macros option.
Hope this helps!
@edemaine So, I need to apply by default on anything \mathit but that's not simple since all the latex is stored on the servers and it's not modifiable anymore and to make things even harder \begin{aligned} bla &= bla\\ bla &= 300blas\\ the 300 blas &= boom\end{aligned} is something that occurs often. So the equations are not simple. Thanks for trying.
@rokyed I still don't understand. Like I said, you don't need to change your LaTeX at all. If you're upgrading KaTeX, just change the calls to KaTeX at the same time.
If you have further questions, please open a fresh issue instead of appending to this old one.
@rokyed how are you calling katex.render?
return katex.renderToString(latex, options)
return katex.render(latex, element, options) // the element is usually a <div> empty by default.
nothing special
let options = {
unicodeTextInMathMode: true,
// unicodes are not fully supported yet,
// this is how we do 'round here
macros: LATEX_MACROS,
}
Is LATEX_MACROS coming from the server? Regardless of where it's coming from though, you should be able to do:
let options = {
unicodeTextInMathMode: true,
// unicodes are not fully supported yet,
// this is how we do 'round here
macros: Object.assign({}, LATEX_MACROS, {"\\mathit": "\\mathnormal"}),
};