Many of computer algebra systems date back to the times when GUI machines were rare and expensive, if were present at all. Thus command line was a standard interface. Unfortunately text terminal doesn’t fit very well for displaying mathematical expressions which demand for rich typesetting. To represent math formulas CAS’s resorted to some kind of ASCII art:
inf 1 ==== / n n \ [ x log (x) > I ---------- dx / ] gamma(n x) ==== / n = 0 0
That’s the output of Maxima. Some of the systems went further and don’t restrict themselves to plain ASCII. Axiom can produce such a nice output:
2 x - %A ┌──┐ ┌┐ %e \│%A │ ──────────── d%A └┘ tan(%A) + 2
Even now most CAS’s retain command line interface, for example Mathematica 8’s terminal session:
In[14]:= Pi*(a+b^2/(Exp[12]+3/2 ">2)) 2 b Out[14]= (a + -------) Pi 3 12 - + E 2
The same technique was also spread in Usenet see whim.org for a collection of notes some of which appeared at sci.math
. I was even able to find “Guidelines for Using ASCII to Write Mathematics”.
If you are looking for a standalone application to render LaTeX to ASCII the only one I’ve found is tex2mail
, more than a decade old Perl script. Much water has flowed under the bridge since then and old character encodings were replaced by Unicode, namely UTF-8. Unicode provides lot’s of math-related symbols and naturally one wants to employ this abundant to allow for prettier output of math formulas in terminal.
I’ve tried to enhance tex2mail by turning it to tex2unicode. To some extent I’ve succeeded:
┌──────┐ ┌─┐ 3 4 │ 2 6 4 ⌠ \│a x ┌─┐ 3 x \│1 - x + x - 3 x ⎮ ───────── dx = \│a ────────────────────────────────── ⌡ ┌──────┐ ┌──────┐ │ 2 ⎛ 2 ⎞ │ 2 2 \│1 - x ⎝ 3 x - 12 ⎠ \│1 - x - 9x + 12 ⎡ 1 ⎤n lim ⎢ 1 + ─ ⎥ = e n --> oo ⎣ n ⎦ n n ⌠1 x ──┐oo ⌠1 x (log x) ⎮ x dx = > ⎮ ────────── dx. ⌡0 ──┘n=0 ⌡0 n! ┬─┬oo ⎛ 1 ⎞ ⎛ ┬─┬oo 1 ⎞-1 1 1 6 │ │ ⎜ 1-── ⎟ = ⎜ │ │ ───── ⎟ = ───────────────── = ──── = ── ≈ 61% ┴ ┴p ⎜ 2 ⎟ ⎜ ┴ ┴p -2 ⎟ 1 1 ζ(2) 2 ⎝ p ⎠ ⎝ 1-p ⎠ 1 + ── + ── + ∙∙∙ π 2 2 2 3
Unfortunately things turned out to be more complicated with other LaTeX commands. The problem is that some symbols like ‘⟶’ should be wider than others. It undermines the whole concept of monospace formatted output. To make things worse the output depends both on the font and the software. Gedit and gnome terminal treat the same string differently. Actually the only reliable symbols to enrich ASCII art are form box-drawing Unicode block.
Making a long story short. Since I don’t really need a full featured LaTeX-to-Monospace-Unicode renderer, I’ll just post what I did by now:
If you are not content with certain LaTeX commands, for example ‘\otimes’ or ‘\to’ it is really easy to improve them. So don’t hesitate and adjust it for your needs. The license is whatever it was for tex2mail.in file in PARI/GP project, where I took it from. I guess it is GPLv2.
Those are really beautiful, very nice work :)
Having grown up browsing sci.math, ASCII math seems like the most natural thing in the world to me, and I can hardly imagine ASCII math *not* being part of a mathematician’s arsenal: how do you write emails to colleagues without ascii math?
Reblogged this on nebusresearch and commented:
I had forgotten the challenges of doing more than the most basic mathematics expressions in ASCII art, and had completely forgotten there were tools that tried to make it a bit easier. Enteropia here’s put forth a script which ought to make it a bit easier to go from LaTeX into an ASCII representation, and I have the feeling I’m going to want to find this again later on, so I’d best make some kind of link I can locate when I do.
Very interesting stuff!
The link for the script is dead, could you provide a new one? Thank you!
Done, though quickly, so check if it actually works, not sure that was the right version.
Unfortunately the link is dead again. Could you perhaps post it to GitHub?
You can try the link again.
Could you post the link again, and moreover, could I host the script on github linking back here and saying you’re the real author?
nvm it worked :-) but the github thing remains though
Pingback: Using Ascii / Unicode for mathematical equations - Nevin Manimala's Blog
Given that even in 2020, the only options are ASCIITeX, CADDVI, and tex2mail (I’d love to include teX4ht but it yields absolute nonsense), it would be super useful if we could get this file onto github, so that anyone who wants to improve something about it can do so, submit a PR, and over the course of a few years, end up with a much better tex2mail script.