# Can LaTeXStrings display arrays and DataFrames with LaTeX characters?

**URL:** <https://discourse.julialang.org/t/can-latexstrings-display-arrays-and-dataframes-with-latex-characters/55281>\
**Category:** Visualization\
**Tags:** latex\
**Created:** [February 14, 2021, 11:43pm UTC](https://discourse.julialang.org/t/can-latexstrings-display-arrays-and-dataframes-with-latex-characters/55281 "2021-02-14T23:43:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Barmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_barmann/32/20389_2.png) [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)\
**Post date:** [February 14, 2021, 11:43pm UTC](https://discourse.julialang.org/t/can-latexstrings-display-arrays-and-dataframes-with-latex-characters/55281/1 "2021-02-14T23:43:08Z")

</div>

I’ve recently discovered the package [LaTeXStrings](https://github.com/stevengj/LaTeXStrings.jl), and am very impressed with it. I was wondering if this package makes it possible to display LaTeX strings within arrays and DataFrames. For example, suppose I have a DataFrame containing a column of strings such as “\alpha\_{BC}^{n}”, “\beta\_{DF}^{m}”, “\gamma\_{G}^{k}”. Is there a way to make these strings display in LaTeX format when the DataFrame is printed?

I was trying to get this to work for arrays, but couldn’t figure it out. I tried

```julia
vars = ["\\alpha_{BC}^{n}", "\\beta_{DF}^{m}", "\\gamma_{G}^{k}"]
tex_vars = ["L%$v" for v in vars]
println(tex_vars)

```

which produced

```julia
LaTeXString[L"$\alpha_{BC}^{n}$", L"$\beta_{DF}^{m}$", L"$\gamma_{G}^{k}$"]

```

rather than actually rending LaTeX characters, as I had hoped. Is it possible to make this work? If so, can this also work for a DataFrame for which some (but not all) entries are strings of LaTeX code?

---

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [February 15, 2021, 12:22am UTC](https://discourse.julialang.org/t/can-latexstrings-display-arrays-and-dataframes-with-latex-characters/55281/2 "2021-02-15T00:22:43Z")

</div>

Julia itself also has [tab completion](https://docs.julialang.org/en/v1/stdlib/REPL/#Tab-completion) giving [unicode](https://docs.julialang.org/en/v1/manual/unicode-input/) characters.  
This will print nicely in the following example, but [unicode](https://docs.julialang.org/en/v1/manual/unicode-input/) doesn’t currently cover all subscripts (e.g. subscript capitals).

```julia
DataFrame(s=["αⁿ", "βⁿ", "γᵏ"])

```

---

<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:** [February 15, 2021, 3:11am UTC](https://discourse.julialang.org/t/can-latexstrings-display-arrays-and-dataframes-with-latex-characters/55281/3 "2021-02-15T03:11:01Z")

</div>

> [@Michael\_Barmann](#):
>
> I’ve recently discovered the package [LaTeXStrings](https://github.com/stevengj/LaTeXStrings.jl), and am very impressed with it.

You shouldn’t be — LaTeXStrings actually does hardly anything. All of the LaTeX rendering is done by your `display` environment (e.g. Jupyter); LaTeXStrings mainly just makes equations easier to type without escaping backslashes. (I wrote LaTeXStrings.)

> [@Michael\_Barmann](#):
>
> Is there a way to make these strings display in LaTeX format when the DataFrame is printed?

You’d need to [add a `show` method](https://docs.julialang.org/en/v1/manual/types/#man-custom-pretty-printing) that outputs the DataFrame to a type like `text/markdown` that Jupyter (or whatever environment you are using) can render with embedded LaTeX equations.
