From f6a377b91cdeb33d03989432025efe96718e573a Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Sun, 26 Nov 2017 20:24:31 -0500 Subject: [PATCH] Avoid negative space in \bmod. (#984) This is a workaround for #836 for the command case of using \bmod, without changing any spacing (and making the code and generated output slightly more efficient). In particular, fix #982. --- src/functions/mod.js | 20 ++++++++++++-------- static/katex.less | 5 +++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/functions/mod.js b/src/functions/mod.js index 32c6208d..902664d4 100644 --- a/src/functions/mod.js +++ b/src/functions/mod.js @@ -12,13 +12,16 @@ const htmlModBuilder = (group, options) => { const inner = []; if (group.value.modType === "bmod") { - // “\nonscript\mskip-\medmuskip\mkern5mu” + // “\nonscript\mskip-\medmuskip\mkern5mu”, where \medmuskip is + // 4mu plus 2mu minus 1mu, translates to 1mu space in + // display/textstyle and 5mu space in script/scriptscriptstyle. if (!options.style.isTight()) { inner.push(buildCommon.makeSpan( - ["mspace", "negativemediumspace"], [], options)); + ["mspace", "muspace"], [], options)); + } else { + inner.push(buildCommon.makeSpan( + ["mspace", "thickspace"], [], options)); } - inner.push( - buildCommon.makeSpan(["mspace", "thickspace"], [], options)); } else if (options.style.size === Style.DISPLAY.size) { inner.push(buildCommon.makeSpan(["mspace", "quad"], [], options)); } else if (group.value.modType === "mod") { @@ -40,12 +43,13 @@ const htmlModBuilder = (group, options) => { buildCommon.mathsym("d", group.mode)]; if (group.value.modType === "bmod") { inner.push(buildCommon.makeSpan(["mbin"], modInner, options)); - // “\mkern5mu\nonscript\mskip-\medmuskip” - inner.push( - buildCommon.makeSpan(["mspace", "thickspace"], [], options)); + // “\mkern5mu\nonscript\mskip-\medmuskip” as above if (!options.style.isTight()) { inner.push(buildCommon.makeSpan( - ["mspace", "negativemediumspace"], [], options)); + ["mspace", "muspace"], [], options)); + } else { + inner.push(buildCommon.makeSpan( + ["mspace", "thickspace"], [], options)); } } else { Array.prototype.push.apply(inner, modInner); diff --git a/static/katex.less b/static/katex.less index e778efb2..1c69188f 100644 --- a/static/katex.less +++ b/static/katex.less @@ -118,6 +118,7 @@ @ptperem: 10.0; @nulldelimiterspace: 1.2em / @ptperem; + @muspace: 0.055556em; // 1mu @thinspace: 0.16667em; // 3mu @mediumspace: 0.22222em; // 4mu @thickspace: 0.27778em; // 5mu @@ -327,6 +328,10 @@ margin-left: -@thinspace; } + &.muspace { + width: @muspace; + } + &.thinspace { width: @thinspace; }