Open pzinn opened 6 days ago
It's been a long while since I contributed here and KaTeX will no longer build locally for me. I have not the energy to chase down why that is.
If someone would like to work up a PR for this issue, a fix can be done by:
Revising line 344 of macros.js
to read as follows:
defineMacro("\\vdots", "\\TextOrMath{\\textvdots}{{\\varvdots\\rule{0pt}{15pt}}}\\relax");
Adding a line to symbols.js
. I added it after line 676:
defineSymbol(text, textord, "\u22ee", "\\textvdots");
Writing a test in katex.spec.js
. The following can be inserted before line 810:
it("should handle ⋮ and \\vdots", function() {
expect`\text{a \vdots b ⋮ d}`.toParse();
});
I'm happy to implement this.
Before I do so I want to make sure I understand the logic behind \vdots
vs \varvdots
. What's the difference between the two, and why should ⋮
be one rather than the other?
Issue #620 pointed out that the \vdots
in LaTeX 2ε is not just a symbol but also has a vertical kern. So the KaTeX code for \vdots
calls a macro. It calls a character from symbols.js
that is named \vardots
(a KaTeX-only name) and also includes an adjacent zero-width vertical rule to emulate the vertical kern.
The proposed code revises the macro. In text mode, the macro will just call the symbol, and in math mode, the macro will expand as it does currently.
@edemaine is better at macros than I am and he may come up with something more clever in review. But I think this does the job.
why should ⋮ be one rather than the other?
Mapping Unicode characters to LaTeX functions was an exercise that turned out to be harder than expected. The KaTeX mapping usually, but not always, follows unicode-math. KaTeX maps rhe character ⋮
, U+22EE, to \vdots
as in in unicode-math, but we ignore their \mathrel
provision because LaTeX 2ε does not give relation spacing to \vdots
.
\text{⋮} will cause an error message: KaTeX parse error: Can't use function '\mathord' in text mode at position 1: \̲m̲a̲t̲h̲o̲r̲d̲{\varvdots\rule… other ellipsis unicode characters seem to work fine.