mathsf?

Help
2009-05-12
2013-04-29
  • John Palmieri
    John Palmieri
    2009-05-12

    Is the font mathsf implemented in jsMath? It doesn't seem to be there by default, but is there an extension or a font which will add it? (This question came up on the sage-support mailing list.)

     
    • No, there is no mathsf at this point.  There are two possible solutions that I can see.

      The cheap but easy one is to do a definition like the following:

          \def\mathsf#1{\style{font-family:sanserif}{\hbox{#1}}}

      or

          jsMath.Macro('mathsf','\\style{font-family:sanserif}{\\hbox{#1}}',1);

      if you include it in a JavaScript file.  Some disadvantages:  it will always be at the normal text size (so won't get smaller for super- or sub-scripts, for example), and it will use the browser's default sans-serif font, not a TeX font, so it might not match the rest of the TeX output as well.  There may also be some spacing issues, as jsMath doesn't really know the sizes of the characters.  But it is easy to do and may be sufficient for your needs.

      The other approach is to make a new jsMath "extra font" for mathsf, like the ones for the other extra fonts (msam10, etc).  The tools for doing this are on the jsMath website at

          http://www.math.union.edu/locate/jsMath/authors/making-fonts.html

      but you will have to figure out which TeX font you want to use for the \mathsf font.  Probably cmss10 would do.

      Davide

       
    • OK, I built the cmss10 font files and put them on the extra-fonts download page at

          http://www.math.union.edu/~dpvc/jsMath/download/extra-fonts/

      where you can download the image fonts to install on your server, and the TTF files for your clients.  Loading the cmss10 font will cause the \mathsf command to be defined.  It is also possible to make the \mathsf command be predefined to load the cmss font when it is first used (so you don't have the overhead of loading the cmss font when it is not used).  To do this, use the commands

          jsMath.Macro("mathsf","{\\cmss #1}",1);
          jsMath.Extension.Font("cmss");

      Hope that takes care of your needs.

      Davide

       
      • John Palmieri
        John Palmieri
        2009-05-14

        That's great, thanks a lot!