# Sans-serif fonts in LaTeX labels for Jupyter widgets?

3 messages
Open this post in threaded view
|

## Sans-serif fonts in LaTeX labels for Jupyter widgets?

 The documentation on layout and styling of Jupyter widgets mentions that Label widget can also render LaTeX equations: http://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Styling.html#LatexOn my machine, these equations render in a serif font by default. Is it possible to change the default font set to use sans-serif fonts, similar to matplotlib's?      matplotlib.rcPararams['mathtext.fontset'] = 'stixsans' Cheers, Johann _______________________________________________ IPython-dev mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/ipython-dev
 Thanks for your reply. Pardon my ignorance, I am not entirely familiar with Jupyter internals. At which point is the MathJax configuration set, and how to override this without changing system defaults, i.e. user-specific? The wiki by Davide reads: For example, you could tell the HTML-CSS output jax to use the MathJax sans-serif font, when possible, in place of its seriffed font. The following accomplishes that:  placed before the script that loads MathJax.js would tell the HTML-CSS (and the SVG) output jax to use the appropriate sans-serif fonts as the first choices for the normal, bold, and italic mathvariants, effectively making variables be italic sans-serif and numbers being upright sans-serif. So what is the script that loads MathJax.js for the jupyter notebook? I could only find a reference to that in a template file, python2.7/dist-packages/notebook/templates/noteboook.html I tried pasting the above code into ~/.ipython/profile_default/static/custom/custom.js but it has no effect. So at what point (and where) is MathJax loaded in the jupyter notebook startup, and how to change the defaults? Thanks, Johann On 14/02/17 19:58, Jason Grout wrote: Good question. In theory, since we use MathJax for the rendering, this would be possible on a local notebook server by modifying the MathJax config in a custom.js file (see http://docs.mathjax.org/en/latest/options/HTML-CSS.html?highlight=stix and http://docs.mathjax.org/en/latest/font-support.html). You could set the preferredFont to null, and use one of the web fonts, for example. It looks like Davide (author of MathJax) has talked about using sans serif fonts before: https://github.com/mathjax/mathjax-docs/wiki/Can-MathJax-use-font-xxxx%3F. He might have an updated answer if you ask on the MathJax mailing list. Thanks, Jason On Tue, Feb 14, 2017 at 9:00 AM Johann Rohwer <[hidden email]> wrote: The documentation on layout and styling of Jupyter widgets mentions that Label widget can also render LaTeX equations: http://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Styling.html#Latex On my machine, these equations render in a serif font by default. Is it possible to change the default font set to use sans-serif fonts, similar to matplotlib's?      matplotlib.rcPararams['mathtext.fontset'] = 'stixsans' Cheers, Johann _______________________________________________ IPython-dev mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/ipython-dev _______________________________________________ IPython-dev mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/ipython-dev  -- Johann M. Rohwer Professor of Systems Biology, and Chairperson: Dept. of Biochemistry Stellenbosch University Private Bag X1, 7602 Matieland SOUTH AFRICA Tel +27-21-8085843 Fax +27-21-8085863 [hidden email] http://www.jjj.sun.ac.za --  _______________________________________________ IPython-dev mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/ipython-dev