Author Topic: About MathJax and LaTeX  (Read 857 times)

Victor Ivrii

  • Administrator
  • Elder Member
  • *****
  • Posts: 1332
  • Karma: 0
    • View Profile
    • Personal website of Victor Ivrii
About MathJax and LaTeX
« on: July 27, 2015, 05:55:58 AM »
This forum uses Mathjax http://www.mathjax.org/ (javascript LaTeX renderer, successor to jsMath)

Someone who is interested in $\LaTeX$ could look at

http://www.ctan.org/tex-archive/info/mil/mil.pdf -  book by George Grätzer: Math into LaTeX
and
http://www.ctan.org/tex-archive/info/Math_into_LaTeX-4/Short_Course.pdf -  book by George Grätzer: More Math into LaTeX

(links lead to "samples" which is large enough to be useful but are not  complete books).

and in MathJax particulars

http://wiki.math.toronto.edu/TorontoMathWiki/index.php/JsMath/MathJax_(TeX_for_Web)

http://www.mathjax.org/docs/tex.html


PS. To hook up MathJax I hacked SMF 2.0 forum but it introduced a bug: preview stopped working (hangs up) in all web browsers except those which are based on Webkit http://en.wikipedia.org/wiki/WebKit, most notably Apple Safari, Google Chrome and KDE Konqueror (currently I don't have access to Konqueror). These browsers are recommended strongly for posting on forum.

In particular, preview does not work on Firefox and probably on MSIE. Reading works fine with all  browsers.


I noticed that some people insert inside of MathJax Greek characters rather than their LaTeX codes γ instead of \gamma. It works but breaks portability as a real plain vanilla LaTeX would not accept this (ok, one can do it in LaTeX albeit loading inputenc and fontenc packages with the corresponding switches). However a Greek mathematician writing in Greek would use γ in the text and \gamma in math formulae.

The second unhealthy idea is to use MathJax for formatting text outside of math. Forum and Wiki have their own mechanisms to make text bold, italic, coloured etc and these mechanisms should be used in text (but not in formula, as it would break MathJax).


One needs to remember that MathJax is not a LaTeX (no pagination, sectioning, tables, graphics, etc - all this is handled by html) but it is "sufficiently" complete for math snippets. Lack of \intertext is annoying.

Also one should remember that  parsing goes this way
\begin{equation*}
\boxed{\text{Forum source}} \;\xrightarrow{Forum}\; \boxed{\text{html source}}\; \xrightarrow{MathJax}\;\boxed{\text{what you see}}
\end{equation*}
and forum formatting commands inside of MathJax break it; and the same for wiki. The same for many html formatting commands.



It is important to produce clean rather than messy code. Don't use eqnarray - it is obsolete, buggy, deprecated. Use align instead.

You should type operatornames as macros \sin, \cos, ... . What about those which are not defined, like \erf. If on the page you use it often, define:
Code: [Select]
\newcommand{\erf}{{\operatorname{erf}}}

\newcommand{\erf}{{\mathrm{erf}}} -- why? because \operatorname command provides a proper spacing after.

Which fonts are available in MJ in our configuration
\mathrm{A,a}    $\mathrm{A,a}$     roman
\mathsf{A, a}     $\mathsf{A,a}$      sanserif
\mathbf{A, a}     $\mathbf{A, a}$     bold
\mathit{A,a}       $\mathit{A,a}$     italic
\mathfrak{A, a}   $\mathfrak{A, a}$    fraktur
\mathbb{Z}         $\mathbb{Z}$        blackboard (only caps)
\mathcal{A}        $\mathcal{A}$        calligraphic (only caps)
\mathscr{A}        $\mathscr{A}$        script (only caps)

Commands without "math" work (f.e. \rm) but they are deprecated as currently some of these command in LaTeX also exist in text mode like \textrm and the results may differ.
« Last Edit: September 11, 2016, 01:44:05 AM by Victor Ivrii »