Custom equation numbering with appendix letters
I have been experimenting with MathJax to try to get Equations in the main text to get the format of s.eq, where 's' indicates the section number and 'eq' indicates the equation number. I have successfully implemented this formatting with the following code:
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
window.MathJax = {
section: -1,
loader: {load: ['[tex]/tagformat']},
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']], //allow inline math
displayMath: [['$$','$$']],
tagSide: 'right', //location of equation numbers
tags: 'all',
packages: {'[+]': ['tagformat', 'sections', 'autoload-all']},
tagformat: {
number: (n) => MathJax.config.section + '.' + n
}
},
startup: {
ready() {
const Configuration = MathJax._.input.tex.Configuration.Configuration;
const CommandMap = MathJax._.input.tex.SymbolMap.CommandMap;
new CommandMap('sections', {
nextSection: 'NextSection',
setSection: 'SetSection',
}, {
NextSection(parser, name) {
MathJax.config.section++;
parser.tags.counter = parser.tags.allCounter = 0;
},
SetSection(parser, name) {
const n = parser.GetArgument(name);
MathJax.config.section = parseInt(n);
}
});
Configuration.create(
'sections', {handler: {macro: ['sections']}}
);
MathJax.startup.defaultReady();
}
}
};
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
I would like the formatting for the Equation to change to a format of L.eq, where L is the letter of the corresponding appendix and eq is the equation number (e.g., A.1, A.2, B.1, B.2, etc.). I have not succeeded so I figured I would try asking here.