on using MathJax and inline math etc

Paul's Avatar

Paul

09 Apr, 2012 10:32 AM

A slight update of this comment originally posted a year ago. Now it should read as ...

This is just a suggestion for people who want to adjust the MathJax behavior to their need and do not want to reply on the choices made in multi markdown.. If you add anywhere in your document (top or bottom being the most obvious) an explicit HTML header (example below) the Marked will use the Mathjax behavior of your choice.
Do not forget in Preference to set up the way you want MathJax to work (default or custom processors work equally well).

Hope this helps
Paul
%%%% My headers are inserted at the bottom of my docs after a blank line

HTML header should be at the start of a new line of course

        HTML header:  <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
        <script>
        MathJax.Hub.Config({
            config: ["MMLorHTML.js"],
            extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
            jax: ["input/TeX"],
            tex2jax: {
                inlineMath: [ ['$','$'], ["\\(","\\)"] ],
                displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
                processEscapes: false
            },
            TeX: {
                TagSide: "right",
                TagIndent: ".8em",
                MultLineWidth: "85%",
                equationNumbers: {
                   autoNumber: "AMS",
                },
                unicode: {
                   fonts: "STIXGeneral,'Arial Unicode MS'" 
                }
            },
            showProcessingMessages: false
        });
    </script>
  1. Support Staff 1 Posted by Brett on 09 Apr, 2012 02:48 PM

    Brett's Avatar

    Adding this to the knowledgebase, thanks for the tip!

  2. 2 Posted by Paul on 09 Apr, 2012 08:40 PM

    Paul's Avatar

    On 09 Apr 2012, at 16:48, Brett wrote:
    Hi Brett,
    This maybe not be in your main line of preoccupation, so skip if you do not care.
    There still remain many irritating problems with mixing markdown and mathjax (or more precisely pure LaTeX which is the basis of MathJax). Fletcher made many reasonable choices but one may not agree with them. In two words if I can surmise his philosophy he decided to leave markdown untouched and force TeX users to add a lot of unnatural escape characters in TeX code.
    If one uses his full multimarkdown machine it is fine as he developed nice tools to produce genuine either LaTeX documents
    or compliant HTML from a single multimarkdown doc. But for heavy users of TeX in webpages it is quite cumbersome and a bit of an overkill.
    For example having two successive _ (underscores) for indices in TeX messes up things or using the "\\" new line in equations is as problematic. In a home grown tweak of markdown this is easy to solve but it removes the beauty of the Marked out of the box solution.
    The best I think would be to leave users choose between to versions of Markdown, both provided by Marked. One would be the usual one, the other would just remove very little form Markdown (for example _ would loose its meaning which is fine since there is already a replacement with * which is an ordinary character in TeX) but allow plain TeX as supported by MathJax.
    In a real math or physics post there is much more TeX markup than HTML markup so that approach makes sense I think (but of course is of no interest for most users of Markdown).
    As you see this MathJax chapter is not quite closed.
    Anyway thanks for a lovely App
    Best
    Paul

  3. Support Staff 3 Posted by Brett on 09 Apr, 2012 09:52 PM

    Brett's Avatar

    I know very little of TeX or Mathjax. Does "Markdown Compatibility Mode" in preferences not have any effect on these issues?

    -Brett

  4. 4 Posted by Andrew Shaw Car... on 27 Mar, 2013 10:18 PM

    Andrew Shaw Care's Avatar

    If you simply want to enable inline math with Marked (using '$' as the boundary character) you can add the following snippet to the end of your Markdown document:

    HTML header:

  5. 5 Posted by Andrew Shaw Car... on 27 Mar, 2013 10:21 PM

    Andrew Shaw Care's Avatar

    To amend my previous comment, the snippet should look as follows:

    HTML header:<script>MathJax.Hub.Config({tex2jax:{inlineMath:[['$','$']]}});</script>

  6. 6 Posted by Paul on 28 Mar, 2013 08:20 AM

    Paul's Avatar

    Hi,
    thanks. Actually I use the following HTML header (see below) and either using my own tinkered version of mardown or the default one provided with Marked.app it still has never worked. Everything else is fine i.e. display math.
    Any comments or further advice of what I may be doing wrong ?
    cheers
    Paul

    HTML header: <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
                MathJax.Hub.Config({
                    config: ["MMLorHTML.js"],
                    extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
                    jax: ["input/TeX"],
                    tex2jax: {
                        inlineMath: [ ['$','$'], ["\\(","\\)"] ],
                        displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
                        processEscapes: false
                    },
                    TeX: {
                        TagSide: "right",
                        TagIndent: ".8em",
                        MultLineWidth: "85%",
                        equationNumbers: {
                           autoNumber: "AMS",
                        },
                        unicode: {
                           fonts: "STIXGeneral,'Arial Unicode MS'"
                        }
                    },
                    showProcessingMessages: false
                });
            </script>

  7. Support Staff 7 Posted by Brett on 28 Mar, 2013 12:41 PM

    Brett's Avatar

    If that's your verbatim header, you'd want to end the first script tag and
    start a new one before the config script. A script tag with a src attribute
    shouldn't have contents.

  8. 8 Posted by Paul on 30 Mar, 2013 12:30 AM

    Paul's Avatar

    Thanks, that was useful.
    So now I am back at the old situation :
    with the default Marked Mathjax config I have perfect inlined equations but bad multiple display equations
    (the old problem that \\ which is "new equation" in some multi equation environments inLatex like "align" (actually ams latex is bad syntax for markdown).
    With my modified markdown multi equations are perfect but inline eqs. are not recognized.
    I have learned to live with it.

    Best

    Paul

  9. 9 Posted by Paul on 30 Mar, 2013 12:43 AM

    Paul's Avatar

    Actually it does work now (with me version of markdown) ! Thanks guys for prodding me to look at it again.
    The problem was a missing blank line between the end of the Latex code and the beginning of the HTML header instructions!!
    cheers
    Paul

  10. 10 Posted by Paul on 21 Apr, 2013 06:03 PM

    Paul's Avatar

    I updated my the first comment to reflect todays status taking the suggestion of Brett.
    Using the header, Mathjax now works perfectly well with straight TeX.
    Great.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac