I know that I can specify delimiters like so
MathJax.Hub.Config({
"tex2jax": {
displayMath: [["$$", "$$"], ["\\(", "\\)"]],
inlineMath: [["$", "$"]]
}
});
My question is whether it is possible to assign different properties / stylesheets to different delimiters? In my case I want formulas surrounded with $$
to be centered (which seems to be the default) and formulas surounded with \(
and \)
to be left aligned.
There may be a way to modify tex2jax
processor and add new types of display with their own delimiters
, but there's an easier way to achieve pretty much the same result, using classes
and styles
that you can easily add to the config
object. Like this for example, you only need to add class left to the MathJax
elements you want aligned left.
MathJax.Hub.Config({
"tex2jax": {
displayMath: [
["$$", "$$"],
["\\(", "\\)"]
],
inlineMath: [
["$", "$"]
]
},
displayAlign: "",
"HTML-CSS": {
styles: {
".left .MathJax_Display": {
"text-align": "left"
}
}
}
});
<script type='text/javascript' src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<p class="left">$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$</p>
<p>$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$</p>
This requires that you put your MathJax between tags.
EDIT:
You can also change the default styles, so you could override some of .MathJax_Display properties the same way. Like this:
MathJax.Hub.Config({
"tex2jax": {
displayMath: [
["$$", "$$"],
["\\(", "\\)"]
],
inlineMath: [
["$", "$"]
]
},
displayAlign: "",
"HTML-CSS": {
styles: {
".left .MathJax_Display": {
"text-align": "left"
},
".MathJax_Display":{
"text-align": "right"
}
}
}
});
<script type='text/javascript' src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<p class="left">$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$</p>
<p>$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$</p>