-
-
Notifications
You must be signed in to change notification settings - Fork 77
Description
There may be an issue with the dvisvgm
flow for creating an svg from PGlateximage.pl
. My server is using dvisvgm
version 3.0.3, which is what came with TeXLive 2023. If I run the following problem, the SVG of the image has lots of excess space under the actual image. (The SVG source has width='217.624508pt' height='1907.534988pt'
, so clearly that height is way off.)
I have built the PDF and PNG from the same source, and there is no issue like this. So it's either the DVI itself or the conversion from DVI to SVG where this excess space is introduced.
The excess space doesn't come out of nowhere either. It's because the domain for the plot starts at 0.01, where the function's output is -100. The excess space down there seems to be about right if you wanted to include (0.01,-100) in the plot. Even though that should be cropped out. You can play with where the plot domain starts, making it further from 0, and eventually the excess space goes away once the start of the plot actually begins at y=-8.
Weird thing: you do not get this behavior if you turn it all upside down. That is, change the ymax
to positive 8, and change the function to 1/x, and you will not see this behavior with excess space above the graph. @drgrice1 showed something similar today but there was excess space to the left of the graph. It suggests that maybe part of what's going on has to do with some plotted node with negative coordinates not being properly accounted for when it's time to crop stuff out of the DVI.
DOCUMENT();
loadMacros(qw(PGstandard.pl PGML.pl PGlateximage.pl));
$image_1 = createLaTeXImage();
$image_1->texPackages(["pgfplots"]);
$image_1->BEGIN_LATEX_IMAGE
\begin{tikzpicture}
\begin{axis}[ymin=-8]
\addplot[domain=0.01:3] {-1/x};
\end{axis}
\end{tikzpicture}
END_LATEX_IMAGE
BEGIN_PGML
[!image!]{$image_1}{600}
END_PGML
ENDDOCUMENT();
Note: independent of PG/WeBWorK, I tried to build a DVI and SVG using
\documentclass[12pt]{standalone}
\usepackage[]{xcolor}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ymin=-8]
\addplot[domain=0.01:3] {-1/x};
\end{axis}
\end{tikzpicture}
\end{document}
and the same latex
and dvisvgm
that WW uses. But I can't reproduce the issue this way (the SVG source does not have absurd height.) I'm not entirely sure the above .tex is what PG builds from though.