temml 0.10.21 → 0.10.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/macros.js CHANGED
@@ -184,6 +184,24 @@ defineMacro("\\char", function(context) {
184
184
  return `\\@char{${number}}`;
185
185
  });
186
186
 
187
+ function recreateArgStr(context) {
188
+ // Recreate the macro's original argument string from the array of parse tokens.
189
+ const tokens = context.consumeArgs(1)[0];
190
+ let str = ""
191
+ let expectedLoc = tokens[tokens.length - 1].loc.start
192
+ for (let i = tokens.length - 1; i >= 0; i--) {
193
+ const actualLoc = tokens[i].loc.start
194
+ if (actualLoc > expectedLoc) {
195
+ // context.consumeArgs has eaten a space.
196
+ str += " "
197
+ expectedLoc = actualLoc;
198
+ }
199
+ str += tokens[i].text
200
+ expectedLoc += tokens[i].text.length
201
+ }
202
+ return str
203
+ }
204
+
187
205
  // The Latin Modern font renders <mi>√</mi> at the wrong vertical alignment.
188
206
  // This macro provides a better rendering.
189
207
  defineMacro("\\surd", '\\sqrt{\\vphantom{|}}')
@@ -191,10 +209,6 @@ defineMacro("\\surd", '\\sqrt{\\vphantom{|}}')
191
209
  // See comment for \oplus in symbols.js.
192
210
  defineMacro("\u2295", "\\oplus")
193
211
 
194
- // Per TeXbook p.122, "/" gets zero operator spacing.
195
- // And MDN recommends using U+2044 instead of / for inline
196
- defineMacro("/", "{\u2044}")
197
-
198
212
  // Since Temml has no \par, ignore \long.
199
213
  defineMacro("\\long", "")
200
214
 
@@ -572,6 +586,11 @@ defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
572
586
  defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
573
587
  defineMacro("\\plim", "\\DOTSB\\operatorname*{plim}");
574
588
 
589
+ //////////////////////////////////////////////////////////////////////
590
+ // MnSymbol.sty
591
+
592
+ defineMacro("\\leftmodels", "\\mathop{\\reflectbox{$\\models$}}")
593
+
575
594
  //////////////////////////////////////////////////////////////////////
576
595
  // braket.sty
577
596
  // http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
@@ -581,56 +600,33 @@ defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
581
600
  defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
582
601
  defineMacro("\\Bra", "\\left\\langle#1\\right|");
583
602
  defineMacro("\\Ket", "\\left|#1\\right\\rangle");
584
- const braketHelper = (one) => (context) => {
585
- const left = context.consumeArg().tokens;
586
- const middle = context.consumeArg().tokens;
587
- const middleDouble = context.consumeArg().tokens;
588
- const right = context.consumeArg().tokens;
589
- const oldMiddle = context.macros.get("|");
590
- const oldMiddleDouble = context.macros.get("\\|");
591
- context.macros.beginGroup();
592
- const midMacro = (double) => (context) => {
593
- if (one) {
594
- // Only modify the first instance of | or \|
595
- context.macros.set("|", oldMiddle);
596
- if (middleDouble.length) {
597
- context.macros.set("\\|", oldMiddleDouble);
598
- }
599
- }
600
- let doubled = double;
601
- if (!double && middleDouble.length) {
602
- // Mimic \@ifnextchar
603
- const nextToken = context.future();
604
- if (nextToken.text === "|") {
605
- context.popToken();
606
- doubled = true;
607
- }
608
- }
609
- return {
610
- tokens: doubled ? middleDouble : middle,
611
- numArgs: 0
612
- };
613
- };
614
- context.macros.set("|", midMacro(false));
615
- if (middleDouble.length) {
616
- context.macros.set("\\|", midMacro(true));
603
+ // A helper for \Braket and \Set
604
+ const replaceVert = (argStr, match) => {
605
+ const ch = match[0] === "|" ? "\\vert" : "\\Vert"
606
+ const replaceStr = `}\\,\\middle${ch}\\,{`
607
+ return argStr.slice(0, match.index) + replaceStr + argStr.slice(match.index + match[0].length)
608
+ }
609
+ defineMacro("\\Braket", function(context) {
610
+ let argStr = recreateArgStr(context)
611
+ const regEx = /\|\||\||\\\|/g
612
+ let match
613
+ while ((match = regEx.exec(argStr)) !== null) {
614
+ argStr = replaceVert(argStr, match)
617
615
  }
618
- const arg = context.consumeArg().tokens;
619
- const expanded = context.expandTokens([...right, ...arg, ...left]); // reversed
620
- context.macros.endGroup();
621
- return {
622
- tokens: expanded.reverse(),
623
- numArgs: 0
624
- };
625
- };
626
- defineMacro("\\bra@ket", braketHelper(false));
627
- defineMacro("\\bra@set", braketHelper(true));
628
- defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" +
629
- "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");
630
- defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" +
631
- "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");
632
- defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");
633
- // has no support for special || or \|
616
+ return "\\left\\langle{" + argStr + "}\\right\\rangle"
617
+ });
618
+ defineMacro("\\Set", function(context) {
619
+ let argStr = recreateArgStr(context)
620
+ const match = /\|\||\||\\\|/.exec(argStr)
621
+ if (match) {
622
+ argStr = replaceVert(argStr, match)
623
+ }
624
+ return "\\left\\{\\:{" + argStr + "}\\:\\right\\}"
625
+ });
626
+ defineMacro("\\set", function(context) {
627
+ const argStr = recreateArgStr(context)
628
+ return "\\{{" + argStr.replace(/\|/, "}\\mid{") + "}\\}"
629
+ });
634
630
 
635
631
  //////////////////////////////////////////////////////////////////////
636
632
  // actuarialangle.dtx
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.10.21";
11
+ export const version = "0.10.22";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}
package/src/replace.js CHANGED
@@ -106,22 +106,22 @@ const offset = Object.freeze({
106
106
  "sans-serif-bold-italic": ch => { return 0x1D5F5 },
107
107
  "monospace": ch => { return 0x1D629 }
108
108
  },
109
- upperCaseGreek: { // A-Ω
109
+ upperCaseGreek: { // A-Ω
110
110
  "normal": ch => { return 0 },
111
- "bold": ch => { return ch === "∇" ? 0x1B4BA : 0x1D317 },
112
- "italic": ch => { return ch === "∇" ? 0x1B4F4 : 0x1D351 },
111
+ "bold": ch => { return 0x1D317 },
112
+ "italic": ch => { return 0x1D351 },
113
113
  // \boldsymbol actually returns upright bold for upperCaseGreek
114
- "bold-italic": ch => { return ch === "∇" ? 0x1B4BA : 0x1D317 },
114
+ "bold-italic": ch => { return 0x1D317 },
115
115
  "script": ch => { return 0 },
116
116
  "script-bold": ch => { return 0 },
117
117
  "fraktur": ch => { return 0 },
118
118
  "fraktur-bold": ch => { return 0 },
119
119
  "double-struck": ch => { return 0 },
120
120
  // Unicode has no code points for regular-weight san-serif Greek. Use bold.
121
- "sans-serif": ch => { return ch === "∇" ? 0x1B568 : 0x1D3C5 },
122
- "sans-serif-bold": ch => { return ch === "∇" ? 0x1B568 : 0x1D3C5 },
121
+ "sans-serif": ch => { return 0x1D3C5 },
122
+ "sans-serif-bold": ch => { return 0x1D3C5 },
123
123
  "sans-serif-italic": ch => { return 0 },
124
- "sans-serif-bold-italic": ch => { return ch === "∇" ? 0x1B5A2 : 0x1D3FF },
124
+ "sans-serif-bold-italic": ch => { return 0x1D3FF },
125
125
  "monospace": ch => { return 0 }
126
126
  },
127
127
  lowerCaseGreek: { // α-ω
@@ -181,7 +181,7 @@ export const variantChar = (ch, variant) => {
181
181
  ? "upperCaseLatin"
182
182
  : 0x60 < codePoint && codePoint < 0x7b
183
183
  ? "lowerCaseLatin"
184
- : (0x390 < codePoint && codePoint < 0x3AA) || ch === "∇"
184
+ : (0x390 < codePoint && codePoint < 0x3AA)
185
185
  ? "upperCaseGreek"
186
186
  : 0x3B0 < codePoint && codePoint < 0x3CA || ch === "\u03d5"
187
187
  ? "lowerCaseGreek"
package/src/symbols.js CHANGED
@@ -128,7 +128,8 @@ defineSymbol(math, textord, "\u2135", "\\aleph", true);
128
128
  defineSymbol(math, textord, "\u2200", "\\forall", true);
129
129
  defineSymbol(math, textord, "\u210f", "\\hbar", true);
130
130
  defineSymbol(math, textord, "\u2203", "\\exists", true);
131
- defineSymbol(math, textord, "\u2207", "\\nabla", true);
131
+ // is actually a unary operator, not binary. But this works.
132
+ defineSymbol(math, bin, "\u2207", "\\nabla", true);
132
133
  defineSymbol(math, textord, "\u266d", "\\flat", true);
133
134
  defineSymbol(math, textord, "\u2113", "\\ell", true);
134
135
  defineSymbol(math, textord, "\u266e", "\\natural", true);
@@ -182,6 +183,7 @@ defineSymbol(math, bin, "\u2021", "\\ddagger");
182
183
  defineSymbol(math, bin, "\u2240", "\\wr", true);
183
184
  defineSymbol(math, bin, "\u2a3f", "\\amalg");
184
185
  defineSymbol(math, bin, "\u0026", "\\And"); // from amsmath
186
+ defineSymbol(math, bin, "\u2AFD", "\\sslash", true); // from stmaryrd
185
187
 
186
188
  // Arrow Symbols
187
189
  defineSymbol(math, rel, "\u27f5", "\\longleftarrow", true);
@@ -600,6 +602,7 @@ defineSymbol(math, mathord, "\u2aeb", "\\Bot");
600
602
  defineSymbol(math, bin, "\u2217", "\u2217", true);
601
603
  defineSymbol(math, bin, "+", "+");
602
604
  defineSymbol(math, bin, "*", "*");
605
+ defineSymbol(math, bin, "\u2044", "/", true);
603
606
  defineSymbol(math, bin, "\u2044", "\u2044");
604
607
  defineSymbol(math, bin, "\u2212", "-", true);
605
608
  defineSymbol(math, bin, "\u22c5", "\\cdot", true);