Repository: KaTeX/KaTeX (JavaScript)

Issue:
\cal support
KaTeX supports the new-style `\mathcal{...}` but not the old-style `{\cal ...}` font format.  We should ideally support both, as we do for `\rm`/`\mathrm` etc.; see the [support table](https://katex.org/docs/supported.html#style-color-size-and-font).

This oversight was recently mentioned to me by the author of a project using KaTeX as a common issue with KaTeX where they needed to fall back to MathJax, so I think it's relevant to the real world.


Discussion:
Hi @edemaine, 

I see from above comments that this issue is marked as fixed with your enhancement in code, But after i implemented Katex with my Angular project last week only I see the error for '\cal'. 
![image](https://user-images.githubusercontent.com/17924176/99935624-05c6e100-2d9c-11eb-983a-ffac1d59f013.png)

the raw innerHTML: 
![image](https://user-images.githubusercontent.com/17924176/99935690-40307e00-2d9c-11eb-9aad-6da134698790.png)



I'm totally new to this library and everything else is working as expected. 

For appreciation I must write that the library is really fast and my users are very happy. 
Sounds like you have an old version of KaTeX. Can you upgrade? You may be able to detect the version by entering `katex.version` in your JavaScript console. 
Hi, @edemaine 

Thanks for your prompt response. 
My current version of katex is 0.11.1. May I know what is the latest stable version of katex library? and how can to upgrade in angular i am using yarn to install packages. 

references I am using in my application.
![image](https://user-images.githubusercontent.com/17924176/100040558-7d4f4b80-2e42-11eb-9400-52209ffe9f5a.png)

Hi @edemaine ,

Any update for my issue. I am still struggling to fix the above issue. 

Thanks
@nisha2107 Probably you need to update to version 0.12.0, the latest. (https://katex.org/docs/ shows you the available versions in the top left.)

In your image above, you actually use a mix of 0.11.0 and 0.12.0, not 0.11.1... You shouldn't mix CSS and JavaScript across versions; ensure that they're all the same.
Hi @edemaine , 

Very thanks for your response. 
Finally I am able to resolve this by replacing **\cal** to **\mathcal**.  It works absolutely perfect now. 

Also i will make sure to not mix the versions.
Once again thanks and have a great weekend.



Patch:
diff --git a/docs/support_table.md b/docs/support_table.md
index 3303df988a..b429c40ca8 100644
--- a/docs/support_table.md
+++ b/docs/support_table.md
@@ -198,7 +198,7 @@ table td {
 |Symbol/Function |  Rendered   | Source or Comment|
 |:---------------|:------------|:-----------------|
 |\C|<span style="color:firebrick;">Not supported</span>|[Deprecated](https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax)|
-|\cal|<span style="color:firebrick;">Not supported</span>|See `\mathcal`
+|\cal|$\cal AaBb123$|`\cal AaBb123`|
 |\cancel|$\cancel{5}$|`\cancel{5}`|
 |\cancelto|<span style="color:firebrick;">Not supported</span>||
 |\Cap|$\Cap$||
diff --git a/docs/supported.md b/docs/supported.md
index 74c745d5b6..755a8c840c 100644
--- a/docs/supported.md
+++ b/docs/supported.md
@@ -538,7 +538,8 @@ For color definition, KaTeX color functions will accept the standard HTML [pred
 |$\mathsf{Ab0}$ `\mathsf{Ab0}`  |$\textmd{Ab0}$ `\textmd{Ab0}`  |$\frak{Ab0}$ `\frak{Ab0}`
 |$\textsf{Ab0}$ `\textsf{Ab0}`  |$\mathtt{Ab0}$ `\mathtt{Ab0}`  |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
 |$\sf Ab0$ `\sf Ab0`            |$\texttt{Ab0}$ `\texttt{Ab0}`  |$\mathcal{AB0}$ `\mathcal{AB0}`
-|                               |$\tt Ab0$ `\tt Ab0`            |$\mathscr{AB}$ `\mathscr{AB}`
+|                               |$\tt Ab0$ `\tt Ab0`            |$\cal AB0$ `\cal AB0`
+|                               |                               |$\mathscr{AB}$ `\mathscr{AB}`
 
 One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
 
diff --git a/src/functions/font.js b/src/functions/font.js
index 005182d28a..2ba74990eb 100644
--- a/src/functions/font.js
+++ b/src/functions/font.js
@@ -95,7 +95,7 @@ defineFunction({
 // Old font changing functions
 defineFunction({
     type: "font",
-    names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it"],
+    names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
     props: {
         numArgs: 0,
         allowedInText: true,


Test patch:
diff --git a/test/katex-spec.js b/test/katex-spec.js
index 2aa7b148be..a418a13345 100644
--- a/test/katex-spec.js
+++ b/test/katex-spec.js
@@ -1601,6 +1601,15 @@ describe("A font parser", function() {
         const built = getBuilt`a\boldsymbol{}b\boldsymbol{=}c\boldsymbol{+}d\boldsymbol{++}e\boldsymbol{xyz}f`;
         expect(built).toMatchSnapshot();
     });
+
+    it("old-style fonts work like new-style fonts", () => {
+        expect`\rm xyz`.toParseLike`\mathrm{xyz}`;
+        expect`\sf xyz`.toParseLike`\mathsf{xyz}`;
+        expect`\tt xyz`.toParseLike`\mathtt{xyz}`;
+        expect`\bf xyz`.toParseLike`\mathbf{xyz}`;
+        expect`\it xyz`.toParseLike`\mathit{xyz}`;
+        expect`\cal xyz`.toParseLike`\mathcal{xyz}`;
+    });
 });
 
 describe("A \\pmb builder", function() {