mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 14:08:42 +00:00
Add \smash, laps, spaces, and phantoms (#833)
* Add \smash, laps, spaces, and phantoms 1. Support `\smash`, including the optional argument from AMS. 2. Change `\llap` and `\rlap` so that they render in text style. Repeat: This *changes* KaTeX behavior. 3. Add `\mathllap` and `\mathrlap`. These will act as they do in `mathtools` and as in previous KaTeX versions of `\llap` and `\rlap`. 4. Add `\mathclap` and `\clap`. 5. Add `\hphantom` and \vphantom`. 6. Add `\thinspace`, `\medspace`, `\thickspace` 7. Add `\hspace`. This work will resolve issue #270 and parts of #50 and #164. A. Perlis has written a [concise description](https://www.math.lsu.edu/~aperlis/publications/mathclap/perlis_mathclap_24Jun2003.pdf) of items 1 thru 5. Except for `\smash`'s optional argument. It's described in the [AMS User's Guide](http://texdoc.net/texmf-dist/doc/latex/amsmath/amsldoc.pdf). Item 6 also comes from the AMS User's Guide. * Fix test spec * Exploit makeVList for smash * update smash and phantom screenshots for chrome * Pick up review comments * Change test from \llap to \mathlap \llap is fundamentally a text-mode function. We should not expect it to work correctly when given math-mode arguments. So test \mathllap instead. * Correct \llap macro A correction. The previous macro returned an error if given an argument with math-mode content, such as x^2. The corrected macro will not return an error. It will instead return well rendered math, but letters are in `\mathrm` font. * update \llap, \rlap, \clap macros to use \textrm * update Lap screenshots
This commit is contained in:
@@ -19,6 +19,11 @@ defineMacro("\\endgroup", "}");
|
||||
// (In TeX, the mu unit works only with \mkern.)
|
||||
defineMacro("\\mkern", "\\kern");
|
||||
|
||||
// \llap and \rlap render their contents in text mode
|
||||
defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
|
||||
defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
|
||||
defineMacro("\\clap", "\\mathclap{\\textrm{#1}}");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// amsmath.sty
|
||||
|
||||
@@ -38,6 +43,19 @@ defineMacro("\\iff", "\\;\\Longleftrightarrow\\;");
|
||||
defineMacro("\\implies", "\\;\\Longrightarrow\\;");
|
||||
defineMacro("\\impliedby", "\\;\\Longleftarrow\\;");
|
||||
|
||||
// http://texdoc.net/texmf-dist/doc/latex/amsmath/amsmath.pdf
|
||||
defineMacro("\\thinspace", "\\,"); // \let\thinspace\,
|
||||
defineMacro("\\medspace", "\\:"); // \let\medspace\:
|
||||
defineMacro("\\thickspace", "\\;"); // \let\thickspace\;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// LaTeX source2e
|
||||
|
||||
// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
|
||||
// \def\@hspace#1{\hskip #1\relax}
|
||||
// KaTeX doesn't do line breaks, so \hspace is the same as \kern
|
||||
defineMacro("\\hspace", "\\kern{#1}");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// mathtools.sty
|
||||
|
||||
|
Reference in New Issue
Block a user