Latex (MathJax) Font options

Hey,

I am looking to publish some plots which includes LaTeX characters in legends, axis titles etc…

I notice that the fonts used by the default Mathjax config in the generated HTML is STIX-Web, while I was hoping to change this to Latin-Modern.

Currently, for HTML plots, I do this by editing the HTML file in a separate script to change the font string. But, I have no clue how to manage this while exporting as PDF. I know its a minor quirk of mine, but could anyone let me know if there is a way around this.

Cheers.

UPDATE: I managed a workaround for now for the font changes in the PDF files. This was by manually ediiting inject.js in plotly-graph component of the orca package to include MathJax’s font config options.

Also as a word of note, the STIX-Web default is a good idea to cover a wider set of characters, but this workaround is for those folks who are looking for consistency while publishing. FYI, MathJax only supports upto a certain amount of fonts.

Cheers.

1 Like

Dear 4shsn

I want to use plotly to export pdfs, and I meet the same problem.
I found the inject.js file in pkgs/plotly-orca-1.3.1-1/lib/orca_app/resources/app/src/component/plotly-graph/inject.js. But I don’t know how to include MathJax’s font config options.

Could you show me some details, please~~

Thanks a lot

1 Like

I was not able to get the inject.js method to work, but a partial workaround is to surround your text with \mathsf{yourtext} or \text{yourtext}

I also found this

Can MathJax use font xxxx? · mathjax/MathJax-docs Wiki (github.com)

It is possible to specify a font for an individual character via

\style{font-family:Arial}{x} + \style{font-family:Arial}{1}

But when I tried, MathJax would just parse it as text.