Search code examples
font-sizemathjax

MathJax Font Size


In MathJax, I am able to adjust the font size using the answer here (i.e. shown below). Is there a way to adjust the font size of the normal text too without dollar signs around it too? For example, when I type the following: Let $f(x)=x^2$.

The text size around the word "Let" would be small and $f(x)=x^2$ would be much larger. I want to scale the text of the words as well, and I am not sure how to do so.

chtml: {scale: 1.5},

svg: {scale: 1.5},


Solution

  • In regular Latex, you could do Let $f(x)=x^2$.

    However remember that, as the name suggests, MathJax doesn't aim to make all of Latex available to the web but focuses on the math part of Latex (and also AsciiMath and MathML of course). A key thing to remember here is that MathJax actually uses the math delimiters to find where there are content to typeset and when you do Let $f(x)=x^2$, MathJax doesn't do anything about the Let since it is outside the math delimiters.

    Nonetheless, there are ways to use regular text in Latex math mode too. For example by means of \text{} so in your case, you could accomplish what you want with $\text{Let } f(x)=x^2$

    Now, simply setting the text size of the surrounding content will make all of the Latex bigger:

    <p style="font-size: 1.5em;">$\text{Let } f(x)=x^2$</p>
    <p style="font-size: 2.5em;">$\text{Let } f(x)=x^2$</p>
    <p style="font-size: 5em;">$\text{Let } f(x)=x^2$</p>
    

    If you want a bigger horizontal space between the math and the Let, you can add a horizontal spacer:

    <p>$\text{Let}\hspace{2mm} f(x)=x^2$</p>
    

    I have prepared a sandbox which you can play around with, also try to uncomment the scale part of the configuration to see this factor in play (however, I usually use font height and not scale to control size): Sandbox

    Some things to remember:

    • Example uses MathJax 3, there might be small differences in comparison to version 2.
    • Example uses the HTML output processor (as in your example), if you load a different MathJax script, you might be outputting svgs instead and then some options won't have impact, so always check these things thoroughly when something doesn't work.
    • $...$ is not a standard pair of delimiters so it has to be explicitly configured, otherwise MathJax won't recognize it as inline Latex math.
    • MathJax automatically does one round of initial typesetting, if you want to update content dynamically, you have to explicitly instruct MathJax to typeset again.

    Good luck!