LaTeX rendering in the Julia REPL

especially now that github markdown supports latex. If you do ?ModuleName and there are no docstrings, you get the readme. If the repl .md could render latex that would be cool

GitHub markdown supports what now? That’s very exciting.

I’m not sure what it would mean for the repl to render LaTeX, it’s not something that I would expect to be possible in most terminal emulators. Maybe a layer that translates \mu into ΞΌ, (i.e. a tex2utf8 engine) but that seems like you’d be crossing the river for water.

1 Like

Or simplify it :wink:

using Latexify
render(latexify("4+5/(3-sqrt(36))"), MIME("juliavscode/html"))
ERROR: MethodError: no method matching display(::MIME{Symbol("juliavscode/html")}, ::String)

OS is Windows and MathJax is installed ?

Test MathJax:
Point with mouse at the output and click right mouse-button, then the MathJax contextmenu should
be displayed.

That is not the repl. It appears to be some IDE.

I made something that does this for LaTeX bits of docstrings.


julia> using Markdown

julia> using MarkdownLaTeXRender

julia> md"Hey ``\sum \mathbb{x}^2-\frac{1}{2}\sigma``"
  Hey βˆ‘ 𝕩² βˆ’ ΒΉ/β‚‚Οƒ
1 Like

Looks like VS code

1 Like

That’s also an (the same?) IDE. Still not the repl.

FWIW, one tool I know that does have the ability to show mathematical formulas in the terminal is maxima:

(%i1) integrate(f(x) / x, x, -1, 1);
                                  1
                                 /
                                 [    f(x)
(%o1)                            I    ---- dx
                                 ]     x
                                 /
                                  - 1

I have absolutely no idea how they do this, and whether it would be doable to get inspiration from the maxima code to have something similar in Julia.

1 Like

A nice solution to the original question is LibTeXPrintf.jl by @suavesito:

julia> texprintln("a = \\sum_i \\frac{1}{i}")
    ⎲ 1
a = ⎳ ─
    ⁱ i

It also accepts LaTeXStrings.

4 Likes

Cool. This works pretty well with Handcalcs.jl. I want to integrate a terminal mode with this.


julia> b = 5
5

julia> h = 15
15

julia> texprintln(
       @handcalcs begin
       Ix = b * (h)^3/12
       Iy = h * (b)^3/12
       end
       )
            b β‹…hΒ³   5 β‹…15Β³
       Ix = ───── = ────── = 1406.25
              12      12
$           h β‹…bΒ³   15 β‹…5Β³          $
 [10pt]Iy = ───── = ────── = 156.25
              12      12

Maybe there is a way to parse out the $ and the [10pt]. That would be nice.

2 Likes