# How to create ASCII equations

**URL:** https://discourse.julialang.org/t/how-to-create-ascii-equations/99180
**Category:** Modelling & Simulations
**Tags:** question, modelingtoolkit, latexify
**Created:** [May 21, 2023, 6:43am UTC](https://discourse.julialang.org/t/how-to-create-ascii-equations/99180 "2023-05-21T06:43:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [May 21, 2023, 6:43am UTC](https://discourse.julialang.org/t/how-to-create-ascii-equations/99180/1 "2023-05-21T06:43:21Z")

</div>

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

```julia
   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…

---

<div class="post-metadata">

### Author: ![woclass](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woclass/32/212699_2.png) [@woclass](https://discourse.julialang.org/u/woclass)
#### Post date: [May 21, 2023, 7:01am UTC](https://discourse.julialang.org/t/how-to-create-ascii-equations/99180/2 "2023-05-21T07:01:28Z")

</div>

LaTeX =\> ASCII equ.

[https://asciitex.sourceforge.net/](https://asciitex.sourceforge.net/)

Math expr =\> ASCII/Unicode equ.

> **[GitHub - ArthurSonzogni/Diagon: Interactive ASCII art diagram generators....](https://github.com/ArthurSonzogni/Diagon#command-line-interface)**
>
> Interactive ASCII art diagram generators. :star2:. Contribute to ArthurSonzogni/Diagon development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [May 21, 2023, 12:10pm UTC](https://discourse.julialang.org/t/how-to-create-ascii-equations/99180/3 "2023-05-21T12:10:16Z")

</div>

```julia
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! 🙂

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 21, 2023, 12:46pm UTC](https://discourse.julialang.org/t/how-to-create-ascii-equations/99180/4 "2023-05-21T12:46:33Z")

</div>

> [@ufechner7](#):
>
> Not written in Julia and a bit hard to install

Since [`utftex` (`libtexprintf`)](https://github.com/bartp5/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](https://github.com/JuliaStrings/LaTeXStrings.jl), to provide a nice multi-line `text/plain` format for `display`.

_Update:_ there is already a JLL package [LibTeXPrintf\_jll](https://juliahub.com/ui/Packages/LibTeXPrintf_jll/0RkPb/1.14.2+0) created [for use by Latexify.jl](https://github.com/JuliaPackaging/Yggdrasil/pull/5524) a few months ago, and Julia wrappers called [LibTexPrintf.jl](https://github.com/Suavesito-Olimpiada/LibTeXPrintf.jl)! See also [Integrate with LibTeXPrintf.jl · Issue #232 · korsbo/Latexify.jl · GitHub](https://github.com/korsbo/Latexify.jl/issues/232)

```julia
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

```

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [May 21, 2023, 8:33pm UTC](https://discourse.julialang.org/t/how-to-create-ascii-equations/99180/5 "2023-05-21T20:33:06Z")

</div>

Thanks for finding this package!
