How to create ASCII equations

In the documentation of ModelingToolkit I find a lot of ASCII equations, e.g.

   k
───────
sT + 1

Is there a way to generate this ascii art automatically? I looked at latexify, but I did not find an option to generate ASCII equations…

1 Like

LaTeX => ASCII equ.

https://asciitex.sourceforge.net/

Math expr => ASCII/Unicode equ.

2 Likes
ufechner@ufryzen:~$ utftex '\frac{1}{s²+2s+1}'
   1
───────
s²+2s+1

Not written in Julia and a bit hard to install, but works nicely now! Thank you! :slight_smile:

2 Likes

Since utftex (libtexprintf) is written as a pure C library, it should hopefully be straightforward to package on Yggdrasil and provide a Julia wrapper.

Indeed, it might be nice to add as an optional dependency for LaTeXStrings.jl, to provide a nice multi-line text/plain format for display.

Update: there is already a JLL package LibTeXPrintf_jll created for use by Latexify.jl a few months ago, and Julia wrappers called LibTexPrintf.jl! See also Integrate with LibTeXPrintf.jl · Issue #232 · korsbo/Latexify.jl · GitHub

julia> using LibTeXPrintf

julia> stexprintf(raw"\frac{1}{s²+2s+1}")
"   1\n───────\ns²+2s+1"

julia> println(ans)
   1
───────
s²+2s+1

julia> texprintf(raw"\frac{1}{s²+2s+1}")
   1
───────
s²+2s+1
12 Likes

Thanks for finding this package!