Giter Site home page Giter Site logo

Demo of tagFormat about mathjax-demos-web HOT 7 CLOSED

mathjax avatar mathjax commented on August 14, 2024
Demo of tagFormat

from mathjax-demos-web.

Comments (7)

Miniland1333 avatar Miniland1333 commented on August 14, 2024
MathJax = {
  tex: {
     macros: {
        test: ["{"+front+" #1}",1]
     },
     tags: "all",
     tagFormat: function (n) {
        return `Equation ${n}`;
     }
  }
};

from mathjax-demos-web.

dpvc avatar dpvc commented on August 14, 2024

I think what you want is

MathJax = {
  tex: {
     packages: {'[+]': ['tagFormat']},   // add it to the default packages
     macros: {
        test: ["{"+front+" #1}",1]
     },
     tags: "all",
     tagFormat: {
        number: function (n) {
          return `Equation ${n}`;
       }
    }
  }
};

You can also specify tag, id, and url functions. The defaults are:

    tagFormat: {
        number: (n) => n.toString(),
        tag:    (tag) => '(' + tag + ')',
        id:     (id) => 'mjx-eqn-' + id.replace(/\s/g, '_'),
        url:    (id, base) => base + '#' + encodeURIComponent(id),
    }

I hope that clears it up for you.

Sorry for not getting back to you sooner; I only just saw the message today (for some reason, I wasn't signed up to get automatic emails for this tracker!).

from mathjax-demos-web.

Miniland1333 avatar Miniland1333 commented on August 14, 2024

From the console: MathJax(?): Invalid option "tagFormat" (no default value).

MathJax = {
  tex: {
     packages: {"[+]": ["tagFormat"]},
     macros: {
        test: ["{"+front+" #1}",1]
     },
      tags: "all",
      tagFormat: {
          number: function (n) {
                    return `Equation ${n}`;
                   }
      }
  }
};

I think this is functionally equivalent to the code above, so I am not sure what is still incorrect. If it matters, I am using https://github.com/mathjax/mj3-demos/blob/master/mathjax3/tex-chtml.js as the javascript file since you had it precompiled for the demos and it seemed to be working just fine there. Maybe I have to specially compile in order to include tagFormat?

from mathjax-demos-web.

dpvc avatar dpvc commented on August 14, 2024

This probably means you haven't loaded the tagFormat extension. Try

MathJax = {
  loader: {
     load: ['[tex]/tagFormat']
  },
  tex: {
     packages: {"[+]": ["tagFormat"]},
     macros: {
        test: ["{"+front+" #1}",1]
     },
     tags: "all",
     tagFormat: {
         number: function (n) {
             return `Equation ${n}`;
         }
      }
  }
};

from mathjax-demos-web.

Miniland1333 avatar Miniland1333 commented on August 14, 2024

Finally had a chance to test the loader and it worked! Do you think the documentation needs any updating to include this example of loading and using tagFormat?

from mathjax-demos-web.

dpvc avatar dpvc commented on August 14, 2024

The documentation for v3 is still being written, and yes, tagFormat should be included in that.

from mathjax-demos-web.

Miniland1333 avatar Miniland1333 commented on August 14, 2024

Thanks!

from mathjax-demos-web.

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.