# LaTeX rendering in the Julia REPL

**URL:** <https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473>\
**Category:** General Usage\
**Created:** [July 22, 2020, 5:05am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473 "2020-07-22T05:05:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeneralPoxter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/generalpoxter/32/17695_2.png) [@GeneralPoxter](https://discourse.julialang.org/u/GeneralPoxter)\
**Post date:** [July 22, 2020, 5:05am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/1 "2020-07-22T05:05:58Z")

</div>

I watched the Latexify demonstration at JuliaCon [here](https://www.youtube.com/watch?v=wpV0Nz-93Hk).

It seems from the video that simply entering something like `latexify("x/y")` into the terminal will result in output that looks like proper LaTeX.

However, when I tried on my terminal I ended up with this:  
 ![Screenshot from 2020-07-22 01-00-51](https://global.discourse-cdn.com/julialang/original/3X/9/e/9e281b8b680f6961aff67adb92d86e7020bece57.png)

My version of the Julia REPL appears to simply display the raw version of the LaTeX, and also does so even when I try using `show`. Has something changed between then and now, or am I not displaying it properly?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 22, 2020, 5:09am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/2 "2020-07-22T05:09:04Z")

</div>

AFAIK there’s no way to display proper LaTeX inside terminal emulator without rendering it out as some sort of image and then display with some image protocol.

It works in IJulia (Jupyter Notebook) though.

---

<div class="post-metadata">

**Author:** ![GeneralPoxter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/generalpoxter/32/17695_2.png) [@GeneralPoxter](https://discourse.julialang.org/u/GeneralPoxter)\
**Post date:** [July 22, 2020, 5:14am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/3 "2020-07-22T05:14:53Z")

</div>

Thanks for your reply.  
I was worried that was the only option though, since I was afraid making Jupyter Notebook a prerequisite to my package would decrease user-friendliness and ease of use.  
I’ll think about it though.

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [July 22, 2020, 10:10am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/4 "2020-07-22T10:10:53Z")

</div>

I recently added a `render` function to latexify.jl. It’s still very much a beta-feature, but the idea is to generate an image with the relevant equation and open it in a new window.

I don’t have any completely satisfactory solutions for the REPL but this is better than nothing.

---

<div class="post-metadata">

**Author:** ![GeneralPoxter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/generalpoxter/32/17695_2.png) [@GeneralPoxter](https://discourse.julialang.org/u/GeneralPoxter)\
**Post date:** [July 22, 2020, 11:33pm UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/5 "2020-07-22T23:33:23Z")

</div>

Are there any requirements for `render`? Would using it just look something like `render(latexify("x/y"))`?

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [July 23, 2020, 7:38am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/6 "2020-07-23T07:38:11Z")

</div>

`render(latexify("x/y"))`, or my own favourite, `latexify("x/y") |> render` is correct usage. For it to work, however, you will need to have LuaLaTeX installed (+ some fairly basic packages). One day, I might make it more liberal such that it can use latex or pdflatex instead but currently it is pretty crude.

The code can (at the time of writing) be found [here](https://github.com/korsbo/Latexify.jl/blob/master/src/utils.jl#L19).

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 12, 2021, 9:56am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/7 "2021-04-12T09:56:09Z")

</div>

@korsbo, is this working in Julia’s 1.6.0 REPL?

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [April 12, 2021, 10:07am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/8 "2021-04-12T10:07:37Z")

</div>

well, there is no support for displaying rich media in any arbitrary REPL. `render` in Latexify.jl will, however, try to create an image from the maths and open that in an external viewer. It also works nicely with the VSCode plotpane if you’re in VSCode.

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [April 12, 2021, 10:10am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/9 "2021-04-12T10:10:15Z")

</div>

there is also [GitHub - MichaelHatherly/MathJaxRenderer.jl: Render LaTeX equations with MathJax offline.](https://github.com/MichaelHatherly/MathJaxRenderer.jl)

its still very new but it’s something that I’ve been eyeballing as a potential replacement for the `render` function inside Latexify.jl.

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [April 12, 2021, 10:19am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/10 "2021-04-12T10:19:04Z")

</div>

is there some reason why you specify 1.6? Any new features in that REPL that I’ve missed?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 12, 2021, 10:20am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/11 "2021-04-12T10:20:44Z")

</div>

No special reason, thank you.  
Trying to visualize in VS Code this amazing [post](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/107) showing a continued fraction.  
Quick attempts using Latexify.jl have not succeeded, yet.

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [April 12, 2021, 10:50am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/12 "2021-04-12T10:50:26Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/c/c/cc3a9f205162dff3d30455fc664b0cc8c7130384.png)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 12, 2021, 11:10am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/13 "2021-04-12T11:10:59Z")

</div>

@korsbo, excellent.  
Thank you for your time showing the way.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 12, 2021, 11:24am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/14 "2021-04-12T11:24:42Z")

</div>

@korsbo, fyi, in order to plot to an external Plots.jl window, found this useful:

```julia
using Latexify, Plots; gr()
plot(framestyle = :none) 
title!(latexify(ex), titlefontsize=10) # adjust font size

```

![Plots_gr_GKS_QtTerm_Latex_continued_fraction](https://global.discourse-cdn.com/julialang/original/3X/8/f/8fc48c366f131a595047719fc292a03afe7d2479.png)

There should be a better way though, that automatically adjusts the font size.

---

<div class="post-metadata">

**Author:** ![miguelraz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miguelraz/32/631_2.png) [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Post date:** [April 12, 2021, 11:36am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/15 "2021-04-12T11:36:39Z")

</div>

There is also [https://github.com/simonschoelly/KittyTerminalImages.jl](https://github.com/simonschoelly/KittyTerminalImages.jl), with LaTeX rendering on their TODOs.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [April 12, 2021, 11:54am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/16 "2021-04-12T11:54:41Z")

</div>

Why not over-engineer it? 😛

```julia
using RecipesBase, LaTeXStrings
@recipe function f(::Type{LaTeXString}, s::LaTeXString)
       framestyle := :none
       titlefontsize --> 10
       title := s
       legend := false
       ([0],[0])
end

using Plots
plot(L"x^7-3x+4")

```

probably also better to make it an annotation than a title, then it won’t look as strange in plotly, for instance.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [March 18, 2022, 10:13am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/17 "2022-03-18T10:13:03Z")

</div>

Got an error in 1.7.2

```julia
julia> latexify("x/y") |> render
ERROR: MethodError: no method matching render(::LaTeXStrings.LaTeXString, ::MIME{Symbol("image/pdf")})
Closest candidates are:
  render(::LaTeXStrings.LaTeXString; kwargs...) at ~/.julia/packages/Latexify/v4lfi/src/utils.jl:59
  render(::LaTeXStrings.LaTeXString, ::MIME{Symbol("juliavscode/html")}; kwargs...) at ~/.julia/packages/Latexify/v4lfi/src/utils.jl:101
  render(::LaTeXStrings.LaTeXString, ::MIME{Symbol("application/pdf")}; debug, name, command, open) at ~/.julia/packages/Latexify/v4lfi/src/utils.jl:106
  ...
Stacktrace:
 [1] render(s::LaTeXStrings.LaTeXString; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Latexify ~/.julia/packages/Latexify/v4lfi/src/utils.jl:60
 [2] render
   @ ~/.julia/packages/Latexify/v4lfi/src/utils.jl:60 [inlined]
 [3] |>(x::LaTeXStrings.LaTeXString, f::typeof(render))
   @ Base ./operators.jl:966
 [4] top-level scope
   @ REPL[3]:1

```

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [March 18, 2022, 10:14am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/18 "2022-03-18T10:14:12Z")

</div>

This one work

```julia
render(latexify("x/y"), MIME(Symbol("application/pdf")))

```

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [March 18, 2022, 11:00am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/19 "2022-03-18T11:00:24Z")

</div>

Yes, that’s the default from Latexify `v0.15.13`.

---

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [May 30, 2022, 4:00am UTC](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473/20 "2022-05-30T04:00:08Z")

</div>

might it ever be possible to render latex within the actual code ?

To write something like

`@render x = a/b`

And after the line is executed, it displays `x = a/b` as a Latex equation over two lines.

Then if the line causes an error or if you click on it, it goes back to the underlying code, for editing.

[Next page](https://discourse.julialang.org/t/latex-rendering-in-the-julia-repl/43473.md?page=2)
