# Specific fractions w/ LaTeXStrings

I am not fully satisfied with the text I can produce with LaTeXStrings.
Some (/many) commands only produce a question mark.

Which LaTeX commands are available?
Is it possible to load LaTeX packages?

LaTeX has support for context specific fractions like \dfrac{}{} and \tfrac{}{} but also \sfrac{}{}.

With the nicefaction package there is even \nicefrac{}{}.

Is any of this available?
How could I find out the limits of the LaTeXString implementation? (Without just crawling through the source code)

I think this issue: Support \displaystyle · Issue #36 · stevengj/LaTeXStrings.jl · GitHub will answer your question.

Quoting the part I think is relevant:

LaTeXStrings does not do any formatting. The only thing it does is allow you to easily construct strings containing LaTeX equations without have to do lots of escapes.

In short it’s not LS that limits what you see, it’s what interprets the LS (e.g. MathJax if you use something like Pluto). So to fix your issue, you have to figure out what is rendering the LS in your case and how/if you can pass additional settings to it.

2 Likes

Thanks. That’s what I was expecting.

Can anyone give me a hint on how Plots with the GR backend would interpret LaTeXStrings? (Sort of a as a direction before I go down into the rabbit hole)

I’d assume this gets either to the GR side or even to the display terminal (in gnuplot terms).
So would it differ if I view it in a GKS QtTerm or save the figure as PNG or PDF?

I don’t know enough of Plots/GR to answer satisfactorily.

One note that you could maybe use either the PGF backend or actually just use PGFPlotsX for full latex support (the latter also happens to be very fast btw).

Linking a related post and some code to play with below, FWIW.

Not all the LaTeX fraction options you’ve listed seem to be available in Plots gr() renderer.

using LaTeXStrings, Plots; gr(size=(200,100))
plot(lims=(-1,1), framestyle=:none)
annotate!(-1, 0, L"\dfrac{3}{2}")
annotate!(0, 0, L"e^{\frac{1}{2} + c}")
annotate!(1, 0, L"\frac{3}{2}")


GR uses its own latex-like function in C (?) to do this, basically the backend behind the backend rolls its own TeX.

If it’s important to you to get the full range of TeX I recommend pgfplots().

1 Like

This file and its siblings contain the code for GR’s tex-handling.

1 Like