mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.11k stars 1.16k forks source link

Implement `\updownarrows` and `\downuparrows` #3243

Open Dimitar5555 opened 3 months ago

Dimitar5555 commented 3 months ago

Currently MathJax has support for \upuparrows and \downdownarrows but not for \updownarrows and \downuparrows which is quite inconsistent. I haven't found alternatives (apart from \uparrow\downarrow...).

dpvc commented 3 months ago

The glyph needed for the \updownarrows and \downuparrows are not the the MathJax TeX fonts used by MathJax v3 and below. This is because the Mathjax TeX fonts are based on the TeX Computer Modern fonts and the AMS symbol fonts, which do not include the characters you are looking for. Those seem to be available in the mathabx TeX package, which includes many glyphs that are not in the MathJax TeX fonts.

One of the new features in MathJax v4 (now in beta release) is the availability of 10 new fonts (plus the original MathJax TeX fonts), and these have much greater character coverage, though MathJax does not predefine a macro for every possible character. You can define those yourself, as needed. For example, you could use

\newcommand{\updownarrows}{\U{20C5}}

to define the macro in a particular page, or use the configuration

MathJax = {
  tex: {
    macros: {
      updownarrows: ['Macro', '\\U{21C5}']
    }
  }
}

in order to pre-define when MathJax starts up. This uses the command \U that is introduced in v4 in order to obtain the needed character.

In version 3 you can use

\newcommand{\updownarrows}{\mathrel{\unicode{x21C5}}}

to accomplish the same goal. You can do a similar configuration to pre-define the macro. Note, however, that in v3 and below, the needed glyph is not in the MathJax fonts, so MathJax will try to obtain one from the fonts installed on your system. That may not match the rest of the math very well, and will vary from user to user depending on what fonts they have installed.

Dimitar5555 commented 3 months ago

Thank you for the information! I'm writing my notes in .md files in a private Github repo. Github uses MathJax to render them on their site but it doesn't recognise \newcommand and it also ignores \unicode due to recent events.

dpvc commented 3 months ago

Yes, GitHub did don't include \newcommand, and had some problems with their implementation (though they have improved on that). There are other Markdown engines that do handle MathJax much better (and allow \newcommand and such), so you might consider trying one of those. For example, pandoc can translate Markdown to HTML, PDF, LaTeX, and a variety of formats. That is a mature and well-supported product, but there are many other Markdown programs that integrate MathJax.

dpvc commented 3 months ago

PS, you can, of course, enter the Unicode characters ⇅ and ⇵ directly into an expression in order to get these symbols as well (without the need for a macro) as a last resort.