JuliaPlots / MakieTeX.jl

TeX integration in Makie
MIT License
86 stars 12 forks source link

Compile all latex strings at once #38

Open greimel opened 2 years ago

greimel commented 2 years ago

You can compile all latexstrings at once. This produces a multipage pdf.

\documentclass[multi=env]{standalone}
\usepackage{amsmath}
\usepackage{standalone}

\begin{document}

\begin{env}
$x \in X$
\end{env}

\begin{env}
blaaaa
\end{env}

\begin{env}
$X \in XXX$
\end{env}

\end{document}

You can then get the respective page using

function pdf2svg(pdf::Vector{UInt8}; page=1, kwargs...)
     pdftocairo = Poppler_jll.pdftocairo() do exe
         open(`$exe -f $page -l $page -svg - -`, "r+")
     end

     write(pdftocairo, pdf)

     close(pdftocairo.in)

     return read(pdftocairo.out, String)
 end

This should speed up compilation at lot.

asinghvi17 commented 2 years ago

I do that already for vectors of latexstrings :) but because of the eager nature of the rendering, it's not so easy to batch them. For example, axis tick labels are batched such that all x tick labels are compiled in the same document, and all y tick labels are compiled in a different document.