diff --git a/docs/support_table.md b/docs/support_table.md index 1ee633c6..6a7f137b 100644 --- a/docs/support_table.md +++ b/docs/support_table.md @@ -659,7 +659,7 @@ use `\ce` instead| |\mathscr|$\mathscr{AB}$|`\mathscr{AaBb123}`
KaTeX supports A-Z| |\mathsf|$\mathsf{AaBb123}$|`\mathsf{AaBb123}`| |\mathsterling|$\mathsterling$|| -|\mathstrut|Not supported|| +|\mathstrut|$\sqrt{\mathstrut a}$|`\sqrt{\mathstrut a}`| |\mathtip|Not supported|| |\mathtt|$\mathtt{AaBb123}$|`\mathtt{AaBb123}`| |\matrix|Not supported|See `{matrix}`| diff --git a/docs/supported.md b/docs/supported.md index 637421f2..e5bdc145 100644 --- a/docs/supported.md +++ b/docs/supported.md @@ -268,7 +268,7 @@ KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, | `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space | `\` | space | `\negmedspace` | – ⁴∕₁₈ em space | `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space -| `\space` | space | +| `\space` | space | `\mathstrut` | `\vphantom{(}` diff --git a/src/macros.js b/src/macros.js index 829f2892..392842f9 100644 --- a/src/macros.js +++ b/src/macros.js @@ -361,6 +361,9 @@ defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); + // \not is defined by base/fontmath.ltx via // \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} // It's thus treated like a \mathrel, but defined by a symbol that has zero diff --git a/test/katex-spec.js b/test/katex-spec.js index 990b0fdd..451df860 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -2505,6 +2505,7 @@ describe("A phantom builder", function() { expect`\phantom{x^2}`.toBuild(); expect`\phantom{x}^2`.toBuild(); expect`\phantom x`.toBuild(); + expect `\mathstrut`.toBuild(); expect`\hphantom{x}`.toBuild(); expect`\hphantom{x^2}`.toBuild(); diff --git a/test/screenshotter/images/Phantom-chrome.png b/test/screenshotter/images/Phantom-chrome.png index 14ae8f1e..77a0a9ee 100644 Binary files a/test/screenshotter/images/Phantom-chrome.png and b/test/screenshotter/images/Phantom-chrome.png differ diff --git a/test/screenshotter/images/Phantom-firefox.png b/test/screenshotter/images/Phantom-firefox.png index b05f0acd..30570b50 100644 Binary files a/test/screenshotter/images/Phantom-firefox.png and b/test/screenshotter/images/Phantom-firefox.png differ diff --git a/test/screenshotter/ss_data.yaml b/test/screenshotter/ss_data.yaml index a7d974a7..d760e5ba 100644 --- a/test/screenshotter/ss_data.yaml +++ b/test/screenshotter/ss_data.yaml @@ -315,7 +315,8 @@ OverUnderset: | \end{array} Phantom: \begin{array}{l} \dfrac{1+\phantom{x^{\blue{2}}} = x}{1+x^{\blue{2}} = x} \left(\vphantom{\int_t} zzz \right) \left( X \hphantom{\frac{\frac X X}{X}} \right)\\ - \text{a \phantom{123}} b \hphantom{\frac{1}{2}}=c \vphantom{101112} d + \text{a \phantom{123}} b \hphantom{\frac{1}{2}}=c \vphantom{101112} d \\ + \sqrt{\mathstrut a} + \sqrt{\mathstrut d} \end{array} Pmb: \mu\pmb{\mu}\pmb{=}\mu\pmb{+}\mu PrimeSpacing: f'+f_2'+f^{f'}