I have been using Org-mode for largely everything including for maths text.

Although I have gotten pretty good at writing LaTeX snippets, I have a lot of trouble reading it. I much prefer the syntax and conventions of AsciiMath.

AsciiMath is also supported by MathJax, but obviously doesn't render when placed inside slashbrackets (I export to HTML). I was wondering whether someone knew of any option or syntax that would let me use AsciiMath rather than LaTeX?

4 Answers 4


Not a complete answer, but I'm interested too. Some possiblities:

  • Embedded Calc can transform a snippet back and forth between multiple markup styles including LaTeX, so if you produce the LaTeX snippet by that method in the first place, you should be able to transform it 'back' into a more readable ad-hoc ASCII format.
    • However, the use-cases clash. Calc is for actually calculating stuff as far as possible, so it will opportunistically simplify expressions down to something you may not want when typesetting e.g. a pedagogical document. You also cannot add fluff lacking machine-parsable meaning, such as \quad.
  • Somehow plug in ASCIIMathML.js during export. Here is a way to plug in a different .js script, which may help us as prior art: https://orgmode.org/worg/org-tutorials/org-jsmath.html
  • Instead of AsciiMath, the ancient eqn could work. This is an executable on your system that can generate MathML. As prior art, a fork of the ox-odt exporter can replace the latex syntax with Starmath in $math$ blocks. Starmath is very similar to eqn, but I don't know if it can make MathML, so you could potentially drop in eqn instead here. However, this exports to ODT, not HTML, so some assembly needed. Source: https://emacsnotes.wordpress.com/2021/12/22/use-starmath-not-latex-not-mathml-when-exporting-org-mode-files-to-libreoffice/

To get this

Org HTML export with MathJax and AsciiMath

do this

#+options: toc:nil num:nil
#+title: Roots of a Quadratic Equation
#+subtitle: /Typeset using =AsciiMath= and =MathJax=/

#+options: tex:asciimath

#+html_head_extra: <script type="text/x-mathjax-config">

#+html_head_extra: MathJax.Hub.Config({
#+html_head_extra:   asciimath2jax: {
#+html_head_extra:     delimiters: [
#+html_head_extra:       ["\\(", "\\)"],
#+html_head_extra:       ["$$", "$$"],
#+html_head_extra:       ["\\[", "\\]"],
#+html_head_extra:       ["\\begin{*}", "\\end{*}"],
#+html_head_extra:       ["\\begin{displaymath}", "\\end{displaymath}"],
#+html_head_extra:       ["\\begin{asciimath}", "\\end{asciimath}"],
#+html_head_extra:       ["\\begin{equation}", "\\end{equation}"],
#+html_head_extra:     ],
#+html_head_extra:   },
#+html_head_extra: });
#+html_head_extra: </script>

#+html_head_extra: <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/latest.js?config=AM_CHTML"></script>

*Roots of a Quadratic Equation*

The two roots of the quadaratic equation \(ax^2+bx+c=0\) are $$(-b+sqrt(b^2-4ac))/(2a)$$ and $$(-b-sqrt(b^2-4ac))/(2a)$$.

*Finding Roots of a Quadratic Equation*

The process of /"completing the square"/ makes use of the algebraic identity

    #+name: asquare
    #+caption: A Polynomial Identity
    x^2 + 2hx + h^2 = (x+h)^2

which represents a well-defined algorithm that can be used to solve any quadratic equation.

Starting with a quadratic equation in standard form,

   #+name: quadratic
   #+caption: A Quadratic Equation
   ax^2 + bx + c = 0

1. Divide each side by $$a$$, the coefficient of the squared term.

       #+NAME: step1
       x^2+( b / a )x+( c / a ) = 0

2. Subtract the constant term $$c / a$$ from both sides.

       #+NAME: step2
       $$x^2+( b / a )x = -( c / a )$$

3. Add the square of one-half of $$b / a$$, the coefficient of $$x$$, to both sides. This /"completes the square"/, converting the left side into a perfect square, as in [[asquare]].

       $$x^2 + 2( b / ( 2a ) )x = -( c / a )$$

       #+NAME: step3
       $$x^2 + 2( b / ( 2a ) )x + ( b / ( 2a ) )^2 = -( c / a ) + ( b / ( 2a ) )^2$$

4. Write the left side as a square and simplify the right side if necessary.

   #+NAME: step4
           ((x + b / ( 2a ))^2  , = ,  - ( c / a ) + ( b^2 / ( 4a^2 ))),
           (                    , = ,  (-4ac + b^2) / ( 4a^2 )        )

5. Produce two linear equations by equating the square root of the left side with the positive and negative square roots of the right side.

   #+NAME: step5
           ( (x + b / ( 2a )) , = , +- sqrt( ( -4ac + b^2 ) / ( 4a^2 ) )),
           (                  , = ,  +- ( sqrt( -4ac + b^2 ) / ( 2a ) ) )

6. Solve each of the two linear equations.

    #+NAME: step6
            ( x , = ,  -b / ( 2a ) +- ( sqrt( -4ac + b^2 ) / ( 2a ) )),
            (   , = ,  ( -b +- ( sqrt( -4ac + b^2 )  ) ) / ( 2a )    )

You can convince yourself that it is indeed AsciiMath at work here.

See How to use AsciiMath, instead of LaTeX, to typeset Math equations in HTML export


If you just want asciimath in html export, this seems sufficient:

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/latest.js?config=AM_CHTML"></script>

`sum_(i=1)^n i^3=((n(n+1))/2)^2`

That renders as enter image description here

for me.

The backticks aren't recognized as org-syntax, so you could conceivably run into org-syntax and asciimath syntax conflicts. I think you can avoid them like this @@html:sum_(i=1)^n i^3=((n(n+1))/2)^2@@.

I guess it might be possible to get an image preview too, but that would probably require making some kind of dedicated org link, or writing some minor mode.


The blog post https://mzimmerm.github.io/2017/04/a-test-blog#org89ae06c, mentions that

An important prerequisite to get Math Formulas using ASCIIMath working in org export, is to customize org-export-with-sub-superscripts to 'do not interpret. This can also be set per file using option #+OPTIONS: ^:nil`

The article doesn't provide enough context about ASCIIMath setup. The part that is confusing to me is the mention of org2jekyll-create-draft, and I wonder if org2jekyll does some special handling for AsciiMath.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.