In LaTeX we can use \tag to a display formula so we can easily referenece to a formula.
But KaTeX doesn't support this marco. Will this marco be added in the future?
\tag looks relatively easy to add support for. But do you need \label and \ref too? That is probably more difficult, because of KaTeX's limited support for text mode.
Please see https://github.com/Khan/KaTeX/issues/350 for previous discussion about \tag and equation numbering in general.
@kevinbarabash Thanks!
@edemaine I think that \tag would be an ideal addition to KaTex, because it is for manual equation numbering. While \label and \ref might be more complicated, as long as we have \tag, we can give names to our equations and reference them in text.
That would be a much cleaner solution than the CSS equation numbering, and probably cover most use cases where not every equation needs to be numbered.
For what it's worth, here is a fiddle with a crude \tag hack: link. It uses a macro to define \tag as \pod\text, which gives you a nice equation number with a bit of space to the left. The rest is dirty JS+CSS trickery to make the equation number right-aligned in display mode.
katex.render(tex.textContent, tex, {
displayMode: true,
throwOnError: false,
macros: {
'\\tag': '\\pod\\text'
}
});
@ntessore cool!
@kevinbarabash I think an official \tag command could be as simple as that. It would only need to add parentheses around a textmode block and wrap the whole thing in a <span> with some new class. That class can then be picked up by CSS and moved to the right of the .katex-display block.
I slightly updated the example to better position the equation number on the right. This should keep the vertical positioning of the equation number block intact and just move it to the right of the display block.
It also appears as if \tag inside \aligned etc. is illegal in LaTeX, so that would not be an issue for a simple solution either. You might even detect that, as well as \tag outside displaymath, and simply throw an error.
Most helpful comment
@kevinbarabash I think an official
\tagcommand could be as simple as that. It would only need to add parentheses around a textmode block and wrap the whole thing in a<span>with some new class. That class can then be picked up by CSS and moved to the right of the.katex-displayblock.I slightly updated the example to better position the equation number on the right. This should keep the vertical positioning of the equation number block intact and just move it to the right of the display block.
It also appears as if
\taginside\alignedetc. is illegal in LaTeX, so that would not be an issue for a simple solution either. You might even detect that, as well as\tagoutside displaymath, and simply throw an error.