Software to render formulas to ASCII art

8.1k Views Asked by At

I guess all computer algebra systems have command line interfaces which render formula as 2D monospace "ascii art". But the only standalone tool to render TeX to 2D I know is tex2mail (comes with PARI/GP).

Are there other standalone programs or libraries for that task, preferably making advantage of various Unicode symbols? Or maybe there is a CAS capable for that.

What I'm talking about:

FriCAS:

            ┌──┐
       x   \│%A
     ┌┐  %e
     │   ─────── d%A
    └┘       2
           %A

tex2mail:

         +-+                              
     ,- \|x   2                              
     | e    /x    dx                              
    -'                 

Maxima:

     /   sqrt(x)
     [ %e
     I --------- dx
     ]     2
     /    x

Those are meant to represent:

$$\int \frac{e^{\sqrt x}}{x^2} \, dx$$

2

There are 2 best solutions below

3
On BEST ANSWER

I've edited a bit tex2mail to use Unicode for output. Here are the results:

                                      ┌──────┐             
          ┌─┐  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 

The look depends hugely on the fonts and the browser. If you are interested in the script here is the link.

0
On

A lot of the answers here mention tools that output to ASCII but if you're open to using Unicode then I found this really nice script: https://github.com/Pomax/tex2utf. But do note that from a quick glance over the repository the author doesn't seem keen on maintaining or fixing any issues with this script (who can blame him, it's written in perl).

Example

Input:

g(x) = \int_1^{1/x} \frac{1}{t} f \cdot \left ( \frac{1}{t} \right ) dt

Output:

        ╭ 1/x 1      ╭ 1 ╮
g(x) =  |     ─ f  · │ ─ │ dt
        ╯ 1   t      ╰ t ╯

For comparison: $$g(x) = \int_1^{1/x} \frac{1}{t} f \cdot \left ( \frac{1}{t} \right ) dt$$