Katex: mhchem "\cf" macro support

Created on 1 Jul 2019  Â·  4Comments  Â·  Source: KaTeX/KaTeX

Before reporting a bug

Describe the bug:

Here I found the following mhchem expression, which uses the \cf macro:

\ce{ Zn^2+ <=>[\ce{+ 2OH-}][\ce{+ 2H+}]$\underset{\text{amphoteric hydroxide}}{\ce{Zn(OH)2 v}}$<=>C[+2OH-][{+ 2H+}]$\underset{\text{tetrahydroxozincate}}{\cf{[Zn(OH)4]^2-}}$ }

And KaTeX (with its mhchem plugin) isn't able to render it properly because it doesn't define said macro.

I've seen this \cf macro used elsewhere, but I see no mention of it in the mhchem docs.

What's it about? Can it be implemented?

bug

Most helpful comment

A bit of history: mhchem for LaTeX started out with a \cf command for chemical formula. It was then extended by a \ce command for equations. Over time, \cfbecame unnecessary on a user level because I could solve all isses (even with recursion). So, I removed \cf from all documentation (but kept it internally for mhchem for LaTeX for backwards compatibility).

mhchem for MathJax and KaTeX has _no_ support for \cf and my preference would be to keep it that way.

We should write a copy&paste answer here for beginners that find a (very rare) mhchem example with \cfand google the error message.

All 4 comments

@mhchem Do you know about \cf? Is it from an old or forked version of mhchem?

I've taken a closer look at this, and replacing \cf with \ce in the formula I posted makes it render properly, so maybe it's just an alias for \ce? (Chemical Expression <=> Chemical Formula or something)

The page where I found the formula points to this package, there's a pdf available for download documenting it which says the following about \cf:

Deprecated commands like \cf, , and ‘ and \hyphen and \cmath were removed completely

I've found a pdf documenting mhchem v3 and it says:

All features mentioned above are provided by the \cf command. \ce calls \cf internally for all summary formulae
and only sets the reaction arrows on its own. Most of the time, you do not have to worry about what command to use.
Simply use \ce all the time. In some special cases, however, you may run into trouble. Recursion is one example (i.e.
calling \ce from inside \ce). It may be helpful then, to use the \cf command for the inner formula.

I guess it should be safe enough to alias \cf as \ce in KaTeX, but maybe it's not worth implementing it directly in KaTeX as it's a deprecated macro 🤔

@fabiospampinato Thanks for investigating. You can add a \cf -> \ce macro in notable (via the macros option) if you need that for your users.

I could see going either way on including such a macro in the mhchem extension. Perhaps useful for legacy code, but also not important (and easy to fix). Probably something for @mhchem to decide.

A bit of history: mhchem for LaTeX started out with a \cf command for chemical formula. It was then extended by a \ce command for equations. Over time, \cfbecame unnecessary on a user level because I could solve all isses (even with recursion). So, I removed \cf from all documentation (but kept it internally for mhchem for LaTeX for backwards compatibility).

mhchem for MathJax and KaTeX has _no_ support for \cf and my preference would be to keep it that way.

We should write a copy&paste answer here for beginners that find a (very rare) mhchem example with \cfand google the error message.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OisinMoran picture OisinMoran  Â·  4Comments

asmeurer picture asmeurer  Â·  3Comments

sophiebits picture sophiebits  Â·  3Comments

msridhar picture msridhar  Â·  3Comments

hagenw picture hagenw  Â·  3Comments