Equation alignment and Numbering

105 views
Skip to first unread message

Andrew Murdza

unread,
May 28, 2023, 2:58:32 PM5/28/23
to MathJax Users
I would like the equation number to appear one \quad after the end of the text instead of on the far right. How can I achieve this without having to manually add the equation number like $$hi\quad (1)$$ (manually adding also breaks \eqref)?

This is my mathjax-config file

window.MathJax = Object.assign({
  loader: { load: ['[tex]/color'] },
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']],
    packages: { '[+]': ['bold-chars', 'color'] },
    tags: 'ams',
    macros: Object.assign({
      recip: ['\\frac{1}{#1}', 1],
      h: ['\\frac{#1}{2}', 1],
      eps: '\\varepsilon',
      R: '\\mathbb{R}',
      a: ['\\begin{aligned}#1\\end{aligned}', 1],
      ya:['\\left(#1\\right)',1],
      //p: ['\\left( #1 \\right)', 1],
      iff: '\\Longleftrightarrow',
      b: ['\\textcolor{bluee}{#1}', 1],
      bk: ['\\textcolor{black}{#1}', 1],
      r: ['\\textcolor{redd}{#1}', 1],
      pu: ['\\textcolor{purplee}{#1}', 1],
      yu: ['\\pu{#1}', 1],
      go: ['\\textcolor{goldd}{#1}', 1],
      pk: ['\\textcolor{pinkk}{#1}', 1],
      yk: ['\\pk{#1}', 1],
      lb: ['\\textcolor{lightbluee}{#1}', 1],
      g: ['\\textcolor{greenn}{#1}', 1],
      o: ['\\textcolor{orangee}{#1}', 1],
      w: ['\\textcolor{white}{#1}', 1],
      gb: ['\\bbox[10px, border: 6px solid LimeGreen]{#1}',1],
      ob: ['\\bbox[10px, border: 6px solid DarkOrange]{#1}',1],
      bb: ['\\bbox[10px, border: 6px solid CornflowerBlue]{#1}',1],
      t:['\\text{#1}',1],
      bkt: ['\\bk{\\text{#1}}', 1],
      wt: ['\\w{\\text{#1}}', 1],
      ot: ['\\o{\\text{#1}}', 1],
      gt: ['\\g{\\text{#1}}', 1],
      lbt: ['\\lb{\\text{#1}}', 1],
      put: ['\\pu{\\text{#1}}', 1],
      pn:['#1',1],
      pkt: ['\\pk{\\text{#1}}', 1],
      yut: ['\\put{#1}', 1],
      ykt: ['\\pkt{#1}', 1],
      got: ['\\go{\\text{#1}}', 1],
      bt: ['\\b{\\text{#1}}', 1],
      rt: ['\\r{\\text{#1}}', 1],
      greyOut:['\\textcolor{lightGray}{#1}',1],
      ga:['\\begin{gather}#1\\end{gather}',1],
      d:['\\ds\\frac{d}{dx}\\left(#1\\right)',1],
      frac: ['\\genfrac{} {} {2} {0} {#1}{#2}', 2],
      powfrac: ['\\genfrac{} {} {2} {2} {#1}{#2}', 2],
      m:'-',
      ttip: ['\\class{tip-top}{\\mathtip{#1}{\\begin{gather}#2\\end{gather}}}', 2],
      rtip: ['\\class{tip-right}{\\mathtip{\\left.#1\\right\\}}{\\begin{gather}#2\\end{gather}}}', 2],
      ltip: ['\\class{tip-left}{\\mathtip{#1}{\\begin{gather}#2\\end{gather}}}', 2],
      btip: ['\\class{tip-bot}{\\mathtip{\\underbrace{#1}}{\\ga{#2}}}', 2],
      btipa: ['\\class{tip-bot}{\\mathtip{\\underbrace{#1}}{\\begin{aligned}#2\\end{aligned}}}', 2],
      slope:['\\frac{\\pu{#4}- \\g{#2}}{\\lb{#3} - \\r{#1}}',4],
      ds: '\\displaystyle',
      sf:'\\slope{x_1}{y_1}{x_2}{y_2}',
      ca: String.raw`\put{current amount}\p{=}\p{\lbt{starting amount}}\p{\cdot }\p{e}^{\p{(\ot{growth rate})}\p{(\gt{time passed})}}`,
      cda: String.raw`\put{current amount}=\p{\lbt{starting amount}}\p{\cdot} \p{e}^{\p{\r{-}}\p{(\ot{decay rate})}\p{(\gt{time passed})}}`,
      p: ['\\class{invisible}{#1}',1],
      hi: ['\\class{him}{#1}',1],
      i: ['\\ds\\int#1\\,dx',1],
      C: '\\p{\\g{+C}}',
      ipi: [String.raw`\b{\left\{\t{variable part of $\i{f'(x)}$ with $#1$ plugged in for $x$}\right\}}`,1],
      ipit: [String.raw`\b{\left\{\t{variable part of $\i{f(x)}$ with $#1$ plugged in for $x$}\right\}}`,1],
      tb:[String.raw`\colorbox{textbox}{$#1$}`,1],
      ie:['\\ds{\\int_{#1}^{#2}#3}\\,dx',3],
      iep:['\\ds\\p{\\int_{\\p{#1}}^{\\p{#2}}\\p{#3}\\,dx}',3],
      ev:['\\hspace{6px}\\Rule{1.25pt}{15pt}{10pt}\\textcolor{white}{\\Rule{1.5pt}{15pt}{10pt}}_{#1}^{#2}',2],
      evp:['\\p{\\hspace{6px}\\Rule{1.25pt}{15pt}{10pt}\\textcolor{white}{\\Rule{1.5pt}{15pt}{10pt}}_{\\p{#1}}^{\\p{#2}}}',2]
    },window.ExtraMacros ||{})
  },
  chtml: {
    scale: 1,                      // global scaling factor for all expressions
    minScale: .5,                  // smallest scaling factor to use
    mtextInheritFont: false,       // true to make mtext elements use surrounding font
    merrorInheritFont: false,      // true to make merror text use surrounding font
    mtextFont: '',                 // font to use for mtext, if not inheriting (empty means use MathJax fonts)
    merrorFont: 'serif',           // font to use for merror, if not inheriting (empty means use MathJax fonts)
    unknownFamily: 'serif',        // font to use for character that aren't in MathJax's fonts
    mathmlSpacing: false,          // true for MathML spacing rules, false for TeX rules
    skipAttributes: {},            // RFDa and other attributes NOT to copy to the output
    exFactor: .5,                  // default size of ex in em units
    displayAlign: 'center',          // default for indentalign when set to 'auto'
    displayIndent: '0',             // default for indentshift when set to 'auto'
    displayOverflow: 'linebreak',

    linebreaks: {                  // options for when overflow is linebreak
      inline: true,                   // true for browser-based breaking of inline equations
      width: '100%',                  // a fixed size or a percentage of the container width
      lineleading: 1,                // the default lineleading in em units
      LinebreakVisitor: null,         // The LinebreakVisitor to use
    },
  },
  startup: {
    ready() {
      const { MacroMap } = MathJax._.input.tex.SymbolMap;
      const { Configuration } = MathJax._.input.tex.Configuration;
      const BaseMethods = MathJax._.input.tex.base.BaseMethods.default;

      // new MacroMap('bold-chars', {
      //   '=': ['Macro', String.raw`\mathrel{\vcenter{\rlap{\Rule{2ex}{3px}{0px}}\raise9px{\Rule{2ex}{3px}{0px}}}}`],
      //   '-': ['Macro', String.raw`\mathrel{\vcenter{\Rule{20px}{2px}{0px}}}`],
      //   '+': ['Macro', String.raw`\mathrel{\vcenter{\rlap{\kern7px\Rule{2px}{9px}{7px}}\Rule{16px}{2px}{0px}}}`]
      // }, BaseMethods);

      Configuration.create('bold-chars', { handler: { character: ['bold-chars'] } });

      const { TooltipData } = MathJax._.output.common.Wrappers.maction;
      TooltipData.postDelay = 10;   // delay in milliseconds

      MathJax.startup.defaultReady();

      MathJax.tex2mml(String.raw`
            \definecolor{orangee}{RGB}{237, 125, 49}
            \definecolor{redd}{RGB}{232,9,0}
            \definecolor{bluee}{RGB}{0,77,255}
            \definecolor{purplee}{RGB}{152,102,255}
            \definecolor{goldd}{RGB}{204, 153, 0}
            \definecolor{pinkk}{RGB}{244, 136, 189}
            \definecolor{lightbluee}{RGB}{0, 176, 240}
            \definecolor{textbox}{RGB}{217, 217, 217}
            \definecolor{lightGray}{RGB}{128, 128, 128}
            \definecolor{greenn}{RGB}{40, 180, 99}`);
    }
  }
});
delete window.ExtraMacros;

(function () {
  var script = document.createElement('script');
  script.src = 'https://cdn.jsdelivr.net/npm/mat...@4.0.0-alpha.1/es5/tex-mml-chtml.js';
  script.async = true;
  document.head.appendChild(script);
})();

Davide Cervone

unread,
May 28, 2023, 3:13:49 PM5/28/23
to mathja...@googlegroups.com
MathJax does not provide a means for you to do that.  It would probably be possible by override enough of the TeX input jax internals, but I don't have the time (or the inclination, really) to work that out.  It's a pretty non-standard approach to equation numbering.

You can, however, set how much space to use at the right of the equation numbers (via the tagIndent option in the tex block of your configuration).  You can also put the tags on the left (via the tagSide tex option) and use left-aligned equations (via the displayAlign option in the options block), and can set an indentation for the left-aligned equations (via the displayIndent option in the options block).  Perhaps that is sufficient for your needs.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/16eced80-f2e4-4480-a666-75ce19253dcfn%40googlegroups.com.

Andrew Murdza

unread,
May 28, 2023, 7:43:43 PM5/28/23
to MathJax Users
I added tagIndent: "1.4em", after tags: 'ams' but the the equation number is still on the far left. tagSide: 'left' works as expected (but I don't need that)
EqNumTooFarLeft.png

Davide Cervone

unread,
May 28, 2023, 8:04:21 PM5/28/23
to mathja...@googlegroups.com
Sorry, I misremembered things:  tagIndent is the minimum amount of space between the tag and the equation, not the indentation from the margin.

You might be able to use the tagformat package to face additional space after (or before) the tag, but that would also affect the references (there is a new tagRef() option in the next version of v4 which could be used to handle that separately).

For now, there is no easy way to get what you are asking for.

Davide


Andrew Murdza

unread,
May 28, 2023, 8:05:32 PM5/28/23
to MathJax Users
I'll wait until tagRef comes out then.

Andrew Murdza

unread,
Dec 5, 2023, 8:04:07 PM12/5/23
to MathJax Users
After a while I decided I want to make the equation numbers on the far right now, but somehow I had previously changed it to make it only a little to the right. Unfortunately I can't figure out how to restore the normal behavior. This is my mathjax config file:

import {customColors} from "./helper.js";

window.MathJax = Object.assign({
loader: { load: ['[tex]/color','[tex]/cancel','[tex]/unicode','[tex]/mathtools','[tex]/textcomp'] },

tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
packages: { '[+]': ['bold-chars', 'my-active', 'color', 'cancel', 'unicode','mathtools','textcomp'] },
maxBuffer: 10 * 1024,

tags: 'ams',
macros: Object.assign({
//fractions
frac: ['\\p{\\genfrac{} {} {2} {0} {#1}{#2}}', 2],
powfrac: ['\\p{\\genfrac{} {} {2} {1} {#1}{#2}}', 2],

//environments
a: ['\\begin{aligned}#1\\end{aligned}', 1],
fla: ['\\begin{flalign*}#1\\end{flalign*}', 1],
ga:['\\begin{gathered}#1\\end{gathered}',1],
cases:['\\begin{cases}#1\\end{cases}',1],
eq: ['\\begin{equation}\\label{#1}#2\\end{equation}',2],

//other
pa:['\\p{\\left(#1\\right)}',1],
so:['\\cancel{#1}',1],
quotes:['\\unicode{x201C}#1\\unicode{x201D}',1],
ds: '\\displaystyle',

//colors non-text
b: ['\\textcolor{bluee}{#1}', 1],
bk: ['\\textcolor{blackk}{#1}', 1],
cdb:['\\textcolor{cadet}{#1}',1],

g: ['\\textcolor{greenn}{#1}', 1],
go: ['\\textcolor{goldd}{#1}', 1],
greyOut:['\\textcolor{lightGray}{#1}',1],
lb: ['\\textcolor{lightbluee}{#1}', 1],
mg:['\\textcolor{mediumGray}{#1}',1],//for tooltips
o: ['\\textcolor{orangee}{#1}', 1],
pk: ['\\textcolor{pinkk}{#1}', 1],
pu: ['\\textcolor{purplee}{#1}', 1],
r: ['\\textcolor{redd}{#1}', 1],
w: ['\\class{white}{#1}', 1],

//dollar
dol:'\\$',

//pause
p: ['\\class{invisible}{#1}',1],
pt: ['\\class{word}{\\p{#1}}',1],//change to ['\\class{word}{\\p{\\t{#1}}}',1] after parser is fixed
ptextbf: ['\\class{word}{\\p{\\textbf{#1}}}',1],
pgt: ['\\class{word}{\\p{\\gt{#1}}}',1],
pbt: ['\\class{word}{\\p{\\bt{#1}}}',1],
pbkt: ['\\class{word}{\\p{\\bkt{#1}}}',1],
prt: ['\\class{word}{\\p{\\rt{#1}}}',1],
pgot: ['\\class{word}{\\p{\\got{#1}}}',1],
ppkt: ['\\class{word}{\\p{\\pkt{#1}}}',1],
pot: ['\\class{word}{\\p{\\ot{#1}}}',1],
pcbdt: ['\\class{word}{\\p{\\cdbt{#1}}}',1],
lbrac:'\\p{\\{}',
rbrac:'\\p{\\}}',

//parsing issues
pn:['{#1}',1],

//avoid -- becoming + and +- becoming -
m:'-',
pms:'+-',

//tooltips
btip: ['\\p{\\class{tip-bot}{\\mathtip{\\mg{\\underbrace{\\bk{#2}}}}{\\ga{#1}}}}', 2,''],
btipg: ['\\p{\\class{tip-bot}{\\mathtip{{\\mg{\\underbrace{\\bk{\\ga{#1}}}}}}{\\ga{#2}}}}', 2],

//text and colored text
t:['\\text{#1}',1],
tm:'\\t{-}',
sot:['\\so{\\t{#1}}',1],
bt: ['\\b{\\t{#1}}', 1],
bkt: ['\\bk{\\t{#1}}', 1],
cdbt:['\\cdb{\\t{#1}}',1],
gt: ['\\g{\\t{#1}}', 1],
got: ['\\go{\\t{#1}}', 1],
greyOutT:['\\greyOut{\\t{#1}}',1],
lbt: ['\\lb{\\t{#1}}', 1],
ot: ['\\o{\\t{#1}}', 1],
pkt: ['\\pk{\\t{#1}}', 1],
put: ['\\pu{\\t{#1}}', 1],
rt: ['\\r{\\t{#1}}', 1],
wt: ['\\w{\\t{#1}}', 1],

op:['\\operatorname{\\t{#1}}',1],
arccot:'\\op{arccot}',
arcsec:'\\op{arcsec}',
arccsc:'\\op{arccsc}',

//color boxes
gb: ['\\,\\bbox[10px, border: 6px solid LimeGreen]{#1}',1],
ob: ['\\,\\bbox[10px, border: 6px solid DarkOrange]{#1}',1],
// bb: ['\\,\\bbox[10px, border: 6px solid CornflowerBlue]{#1}',1],
bb: ['\\,\\bbox[4px, border: 4px solid CornflowerBlue]{#1}',1],

//limits
limfu:['\\lim\\limits_{#1\\to#2}',2],
limlc:['\\limfu{#1}{#2^{\\bf\\Large\\p{\\r{-}}}}',2],
limrc:['\\limfu{#1}{#2^{\\bf\\Large\\g{+}}}',2],
linf:'\\limfu{x}{\\infty}',

//lines+slope
sf:'\\slope{x_1}{y_1}{x_2}{y_2}',
sfinfo:'\\slopeNoColor{\\btipg{\\r{x_1}}{\\r{\\t{the first }x\\t{ value}}}}{\\btipg{\\go{y_1}}{\\go{\\t{the' +
' first' +
' }y\\t{ value}}}}{\\btipg{\\b{x_2}}{\\b{\\t{the second }x\\t{ value}}}}{\\btipg{\\pu{y_2}}{\\pu{\\t{the' +
' second }y\\t{ value}}}}',
slope:['\\slopeNoColor{\\r{#1}}{\\go{#2}}{\\b{#3}}{\\pu{#4}}',4],
slopeNoColor:['\\frac{#4\\p{-}#2}{#3\\p{-}#1}',4],
psf:['y-\\b{#3}=\\r{#1}(x-\\go{#2})',3],
psfTip:['y\\m\\btipg{\\b{#3}}{\\b{y_1}}=\\btipg{\\r{#1}}{\\r{m}}(x\\m\\btipg{\\go{#2}}{\\go{x_1}})',3],
psfdef:'\\psf{m}{x_1}{y_1}',

//integrals
i: ['\\ds\\int#1\\,\\t{d}x',1],
ie:['\\ds{\\int_{#1}^{#2}#3}\\,\\t{d}x',3],
iu: ['\\ds\\int#1\\,\\t{d}#2',2],
ieu:['\\ds{\\int_{#1}^{#2}#3}\\,\\t{d}#4',4],
iep:['\\ds\\p{\\int_{\\p{#1}}^{\\p{#2}}\\p{#3}\\,\\t{d}x}',3],
ev:['\\hspace{6px}\\bk{\\Rule{1.25pt}{15pt}{10pt}}\\w{\\Rule{1.5pt}{15pt}{10pt}}_{#1}^{#2}',2],
evp:['\\p{\\hspace{6px}\\bk{\\Rule{1.25pt}{15pt}{10pt}}\\w{\\Rule{1.5pt}{15pt}{10pt}}_{\\p{#1}}^{\\p{#2}}}',2],

ipi: [String.raw`\b{\left\{\t{variable part of $\i{f'(x)}$ with $#1$ plugged in for $x$}\right\}}`,1],
ipit: [String.raw`\b{\left\{\t{variable part of $\i{f(x)}$ with $#1$ plugged in for $x$}\right\}}`,1],
C: '\\p{\\g{+C}}',

//textboxes
tbs:['\\,\\bbox[10px, border: 1.5px solid Cyan]{#1}\\,',1],//String.raw`\colorbox{textbox}{$#1$}`
tb:['\\quad\\tbs{#1}',1],
//group selections
hb:['\\,\\bbox[5px, border: 1.5px dashed Cyan]{\\b{#1}}',1],
hbr:['\\,\\bbox[5px, border: 1.5px dashed Red]{\\r{#1}}\\,',1],
hbg:['\\,\\bbox[5px, border: 1.5px dashed Green]{\\g{#1}}\\,',1],
hbo:['\\,\\bbox[5px, border: 1.5px dashed Orange]{\\o{#1}}\\,',1],
hbgo:['\\,\\bbox[5px, border: 1.5px dashed Gold]{\\go{#1}}\\,',1],
hbpu:['\\,\\bbox[5px, border: 1.5px dashed Magenta]{\\pu{#1}}\\,',1],

//text size
bigtext:['\\class{bigtext}{#1}',1],
smalltext:['\\class{smalltext}{#1}',1],
do:'\\$',

//current amount equation
ca: String.raw`\put{current amount}\p{=}\p{\lbt{starting amount}}\p{\cdot }\p{e}^{\p{(\ot{growth rate})}\p{(\gt{time passed})}}`,
cda: String.raw`\put{current amount}=\p{\lbt{starting amount}}\p{\cdot} \p{e}^{\p{\r{-}}\p{(\ot{decay rate})}\p{(\gt{time passed})}}`,

//MA 141 only
eps: '\\p{\\varepsilon}',
R: '\\p{\\mathbb{R}}',
iff: '\\p{\\Longleftrightarrow}',

// and:String.raw`~~\text{and}~~`,
// recip: ['\\frac{1}{#1}', 1],
// h: ['\\frac{#1}{2}', 1],
// yu: ['\\pu{#1}', 1],
// yk: ['\\pk{#1}', 1],
// yut: ['\\put{#1}', 1],
// ykt: ['\\pkt{#1}', 1],
// d:['\\ds\\frac{d}{dx}\\left(#1\\right)',1],
// ttip: ['\\class{tip-top}{\\mathtip{#1}{\\begin{gathered}#2\\end{gathered}}}', 2],
// rtip: ['\\class{tip-right}{\\mathtip{\\left.#1\\right\\}}{\\begin{gathered}#2\\end{gathered}}}', 2],
// ltip: ['\\class{tip-left}{\\mathtip{#1}{\\begin{gathered}#2\\end{gathered}}}', 2],
// btipn: ['#1', 2],
// hi: ['\\class{him}{#1}',1],
},window.ExtraMacros ||{}),
},
// chtml: {
// scale: 1,//1.25 // global scaling factor for all expressions
// minScale: 0.5, // smallest scaling factor to use
// mtextInheritFont: false, // true to make mtext elements use surrounding font
// merrorInheritFont: false, // true to make merror text use surrounding font
// mtextFont: '', // font to use for mtext, if not inheriting (empty means use MathJax fonts)
// merrorFont: 'serif', // font to use for merror, if not inheriting (empty means use MathJax fonts)
// unknownFamily: 'serif', // font to use for character that aren't in MathJax's fonts
// mathmlSpacing: false, // true for MathML spacing rules, false for TeX rules
// skipAttributes: {}, // RFDa and other attributes NOT to copy to the output
// exFactor: 0.5, // default size of ex in em units
// displayAlign: 'center', // default for indentalign when set to 'auto'
// displayIndent: '0', // default for indentshift when set to 'auto'
// // displayOverflow: 'linebreak',
// //
// // linebreaks: { // options for when overflow is linebreak
// // inline: true, // true for browser-based breaking of inline equations
// // width: '100%', // a fixed size or a percentage of the container width
// // lineleading: 1, // the default lineleading in em units
// // LinebreakVisitor: null, // The LinebreakVisitor to use
// // },
// },
startup: {
ready() {
const { MacroMap } = MathJax._.input.tex.SymbolMap;
const { Configuration } = MathJax._.input.tex.Configuration;
const BaseMethods = MathJax._.input.tex.base.BaseMethods.default;

let map= {};
addPauseStr(map,33,true);
for(let i=40;i<43;i++){
addPauseStr(map,i,true);
}
addPauseStr(map,43,true,true);
addPauseStr(map,44,true);
// addPauseStr(map,45,true,true);
// for(let i=43;i<46;i++){
// addPauseStr(map,i,true,true);
// }
// map["-"]=["Macro","\\mathrel{{}\\p{\\textminus}{}}"]
for(let i=46;i<58;i++){
addPauseStr(map,i,true);
}
addPauseStr(map,91,true);
addPauseStr(map,93,true);
addPauseStr(map,58,true,true);
addPauseStr(map,59,true);
for(let i=60;i<63;i++){
addPauseStr(map,i,true,true);
}
addPauseStr(map,63,true);
for(let i=65;i<91;i++){
addPauseStr(map,i);
}
for(let i=97;i<123;i++){
addPauseStr(map,i);
}
new MacroMap('bold-chars', map, BaseMethods);
// new MacroMap('bold-chars', {":":["Macro","\\r{\\mmlToken{mi}{\\mathrel{\\vcenter{{}:{}}}}}"]}, BaseMethods);

// new MacroMap('my-active', {
// 'a': ['Macro', '\\pu{\\mmlToken{mi}{a}}'],
// 'b': ['Macro', '\\b{\\mmlToken{mi}{b}}']
// }, BaseMethods);
// new MacroMap('bold-chars', {
// '=': ['Macro', String.raw`\bk{\mathrel{\vcenter{\rlap{\Rule{2ex}{2px}{0px}}\raise9px{\Rule{2ex}{2px}{0px}}}}}`],
// '-': ['Macro', String.raw`\bk{\mathrel{\vcenter{\Rule{20px}{2px}{0px}}}}`],
// '+': ['Macro', String.raw`\bk{\mathrel{\vcenter{\rlap{\kern7px\Rule{2px}{9px}{7px}}\Rule{16px}{2px}{0px}}}}`]
// }, BaseMethods);

//Configuration.create('my-active', { handler: { character: ['my-active'] } });//'bold-chars' (had to remove
Configuration.create('bold-chars', { handler: { character: ['bold-chars'] } });//'bold-chars' (had to remove
// this because it wasn't working with both my-active and bold-chars

const { TooltipData } = MathJax._.output.common.Wrappers.maction;
TooltipData.postDelay = 10; // delay in milliseconds

const CommandMap = MathJax._.input.tex.SymbolMap.CommandMap;
const TexError = MathJax._.input.tex.TexError.default;

const CheckDimen = function (dimen) {
if (dimen === '') return '';
if (dimen.match(/^\s*([-+]?(\.\d+|\d+(\.\d*)?))\s*(pt|em|ex|mu|px|mm|cm|in|pc)\s*$/)) {
return dimen.replace(/ /g, '');
}
throw new TexError('BadImageDimen', 'Bad dimension for image: %1', dimen);
};
new CommandMap('img', {img: 'Img'}, {
Img(parser, name) {
const arg = parser.GetBrackets(name, '');
const def = {
valign: '',
width: '',
height: ''
};
if (arg.match(/[,=]/)) {
for (const pair of arg.split(/\s*,\s*/)) {
const [key, ...value] = pair.split(/\s*=\s*/);
if (!def.hasOwnProperty(key)) throw new TexError('UnknownKey', 'Unknown parameter "%1" in %2', key, name);
def[key] = CheckDimen(value.join('='));
}
} else {
def.valign = CheckDimen(arg);
def.width = CheckDimen(parser.GetBrackets(name, ''));
def.height = CheckDimen(parser.GetBrackets(name, ''));
}
def.src = parser.GetArgument(name);
if (!def.valign) delete def.valign;
if (!def.width) delete def.width;
if (!def.height) delete def.height;
parser.Push(parser.create('token', 'mglyph', def));
}
});
Configuration.create('img', {handler: {macro: ['img']}});

MathJax.startup.defaultReady();
MathJax.tex2mml(customColors+addPauseToCommand('sqrt',1,[''])+addPauseToCommand('cancel',1)+
addPauseToCommandNoArg('infty','to','lim','cdot','pm','pi','sin','cos','tan','cot','sec','csc','theta','arcsin','arccos','arctan',
'arccot','arcsec','arccsc','m','tm','do','eps','iff','R','int')
);
}
}//definecolor{lightbluee}{RGB}{0, 176, 240}
});
delete window.ExtraMacros;

function addPauseStr(map,i,number,operator){
let char=String.fromCharCode(i);
map[char]=['Macro', (operator?'\\mathrel{{}':'')+
(number?'\\p{\\unicode{'+char.charCodeAt(0)+'}}':'\\p{\\mmlToken{mi}{'+char+'}}')+(operator?'{}}':'')]
}

//defs has length 1
function addPauseToCommand(command,n,defs){
defs=defs==null?[]:defs;
let str='';
let str1='';
for(let i=0;i<defs.length;i++){
str+='[#'+(i+1)+']'
str1+='['+defs[i]+']'
}
for(let i=0;i<n;i++){
str+='{#'+(i+1+defs.length)+'}'
}
return '\\let\\old'+command+'\\'+command+' \\renewcommand{\\'+command+'}'+(n>0?'['+(n+defs.length)+']':'')+str1+'{\\p{\\old'+command+str+'}}'
}
function addPauseToCommandNoArg(...strs){
let str1='';
for(let str of strs){
str1+=addPauseToCommand(str,0)
}
return str1;
}

Andrew Murdza

unread,
Dec 5, 2023, 8:11:57 PM12/5/23
to MathJax Users
I figured it out. My math was in $...$ instead of $$...$$
Reply all
Reply to author
Forward
0 new messages