Closed asinghvi17 closed 2 years ago
- weird gray border at the edge of any LTeX
Did you check what happens after processing the pdf in Makie?
To me it seems that all pdfs have a gray frame when opening on macos. After importing to inkscape that frame is gone.
Hmm, good point - will have to test that. As I recall it did not.
Looks like there are rotation issues in the PNG backend, which is really strange, and image rendering isn't working at all. I'm not comfortable merging this without figuring the PNG issues out, but if anyone wants to use it only for PDFs, feel free.
With CairoMakie (rendered direct from surface)
SVG looks bad here but fine on my Mac, somehow.
With GLMakie (rendered to image and plotted), it doesn't show up at all:
OK, I still have some boundingbox issues but otherwise it looks fine. See the following images:
As of https://github.com/JuliaPlots/MakieTeX.jl/pull/25/commits/5d0c7f86d432b861998f5a3a127bb6cc4bad2a23, I was rendering directly from Poppler on cairo_draw. However: Poppler apparently forgets about the page at some point, so I am now trying to add a Glib object reference to CachedTeX. If that doesn't work, then I'll switch back to Cairo surfaces.
This should now be ready for anyone who wants to try it! The external API is essentially the same, with two new features.
MakieTeX.MAKIETEX_RENDER_UNSAFE[] = true
to use an experimental Poppler direct renderer. It works well on CairoMakie PDFs and GLMakie but horribly otherwise. It also somehow "forgets" (possibly Poppler garbage collection) the document content after more documents are loaded, so be sure you don't have too much tex with this!Also, text!
has been overridden for TeXDocument as well, so you can directly plot text / tikz using those.
As a stopgap, I brute-forced the Poppler issue by reloading the pdf at each CairoMakie render.
@greimel, thanks for the suggestion of tectonic
! It seems to work pretty well as a fallback, and it does basic TikZ as well! I think that with this, we can successfully call MakieTeX platform-independent!
With the text hijacking, I can do this:
fig = Figure()
l1 = Label(
fig[1, 1], L"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}";
tellwidth = false, tellheight = true
)
ax1 = Axis(
fig[2, 1];
xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
ylabel = L"\displaystyle \Phi(\vec x) = f(\vec x) + g(V)",
ylabelpadding = 15
)
heatmap!(ax1, Makie.peaks())
fig
Two problems: note the large whitespace gap on the left (caused, I think, by a bad boundingbox in teximg
) and the weird x tick labels. The x tick label issue is just because of asynchronous updates, which I am not entirely sure how to handle.
Essentially, the ticks just take too long to render; because of that, there is some asynchronicity between the positions and the markers. I would have to implement a pipeline such that the cached tex and positions go together - maybe by forcing the user to pass Vector{Tuple{CachedTeX, Point3f}}
?
Theming is fully integrated!
julia> fig = with_theme(theme_dark()) do
fig = Figure(fontsize = 12, resolution = (300, 300))
ax = Axis(
fig[1,1];
xlabel = LaTeXString("time (\$t\$) in arbitrary units"),
ylabel = LaTeXString("here we go fellas"),
title = LaTeXString(raw"A \emph{convex} function $f \in C$ is \textcolor{red}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}"),
xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
xlabelpadding = 12,
ylabelpadding = 12,
)
# plot to the axis
heatmap!(ax, Makie.peaks(); colormap = :inferno)
fig
end
Currently, there are two issues with this:
Otherwise, it works and is probably faster than the current master.