Giter VIP home page Giter VIP logo

Comments (3)

dpvc avatar dpvc commented on June 9, 2024

The default MathJax-TeX fonts in v2 don't include upright versions of the Greek letters, bold or otherwise, so in order to accomplish this, you would need to use one of the other fonts. The STIX font does include the needed characters, so you could use that. Because the v2 CommonHTML output only supports MathJax-TeX, you would need to use either the older HTML-CSS output, or the SVG output renderer.

Here is a MathJax configuration that defines a version of \symbf that could be used to get bold upright Greek letters:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  "HTML-CSS": {
    fonts: ["STIX-Web"]
  },
  SVG: {
    font: "STIX-Web"
  },
  TeX: {Augment: {
    Definitions: {macros: {symbf: 'Symbf'}},
    Parse: {prototype: {
      csMathchar0mi: function (name, mchar) {
        var MML = MathJax.ElementJax.mml;
        var def = {};
        if (Array.isArray(mchar)) {def = mchar[1]; mchar = mchar[0]}
        this.Push(this.mmlToken(MML.mi(MML.entity("#x"+mchar)).With(def)));
      },
      Symbf: function (name) {
        var MML = MathJax.ElementJax.mml;
        var math = this.ParseArg(name);
        this.Push(MML.mstyle(math).With({mathvariant: "bold"}));
      }
    }}
  }}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/unpacked/MathJax.js?config=TeX-AMS_SVG"></script>

The csMathchar0mi function is overriden to not include an explicit mathvariant="italic" that is in the original version, so that that mstyle element's mathvariant will be applied. This shouldn't hurt anything else, I think.

from mathjax.

wangzhen89 avatar wangzhen89 commented on June 9, 2024

Thanks! I am completely clueless about Mathjax, HTML, and JavaScript. But your codes run for me!
But how to set the default output as HTML-CSS so that I don't have to right-click on the formula and select it.
Really appreciated.

from mathjax.

dpvc avatar dpvc commented on June 9, 2024

The example I have above uses SVG output, which should work for you. If you want to use HTML-CSS, then you have to change TeX-AMS_SVG to TeX-AMS_HTML.

It looks like bookdown has TeX-MML-AM_CHTML as the default in some of its templates (e.g., here, so you have to edit that to be TeX-AMS_HTML. It also looks like there may be some sort of mathjax variable that can be set to the URL of the MathJax you want to load. If you can change that value to

https://cdn.jsdelivr.net/npm/[email protected]/unpacked/MathJax.js?config=TeX-AMS_HTML

that should also do it.

from mathjax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.