Comments (13)
I have ran across this issue with this when testing out my PGplot macro (which uses pgfplots). If I have points outside the range of the axes, those points affect the final size of the image, but are not included in the image causing the blank space as you described.
Though when testing out your problem, I notice the issue only on my 2.18 server, but not on my development server (which the image is generated correctly). Do you notice this same behavior, that this only occurs on 2.18? The two servers have identical versions of texlive and dvisvgm, so unsure why one server has extra space and one server doesn't. I also think I only ever saw the issue when testing my PGplot macro when using it for problems on my 2.18 server and not when testing it with develop.
from pg.
That is interesting because it may help us track down where this is coming from. But for me on my develop server, I still have this issue.
Out of curiosity, when you see this happen, has it always been excess space either below or to the left (not above or to the right?)
from pg.
I don't recall exactly where the excess area was, I was more focused on getting a working problem so I had my code limit the domain/codomain to match the axes view to avoid the issue. But I did some more testing, and it does appear the image will always appear in the top right (so bottom left is where the blank area is).
Here is an example that might be easier to play with, you can just move points inside and outside the axes range.
DOCUMENT();
loadMacros(qw(PGstandard.pl PGML.pl PGlateximage.pl));
$refreshCachedImages = 1;
$image = createLaTeXImage();
$image->texPackages(["pgfplots"]);
$image->svgMethod('dvisvgm');
$image->BEGIN_LATEX_IMAGE
\begin{tikzpicture}
\begin{axis}[ymin=-5,ymax=5,xmin=-5,xmax=5]
\addplot[] coordinates {(50,-50) (-100,100)};
\end{axis}
\end{tikzpicture}
END_LATEX_IMAGE
BEGIN_PGML
[!image!]{$image}{600}
END_PGML
ENDDOCUMENT();
For instance if I make points appear off grid in the upper/right, the image is generated correctly. \addplot[] coordinates {(-5,-5) (100,100)};
, but if I move the bottom/left out of the axes range, the extra space is created, \addplot[] coordinates {(-50,-50) (100,100)};
I figured out why it was working on my develop server, I was still using the default pdf2svg
. Changing this to dvisvgm
did create the same issue, so I added $image->svgMethod('dvisvgm')
to the problem to ensure the correct method to cause the issue was being used.
from pg.
I dug into the code a bit, and forced the .tex file to stick around. Here is the actual tex file that is being used to generate the output:
\documentclass{standalone}
\def\pgfsysdriver{pgfsys-dvisvgm.def}
\usepackage[svgnames]{xcolor}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ymin=-5,ymax=5,xmin=-5,xmax=5]
\addplot[] coordinates {(-50,-50) (100,100)};
\end{axis}
\end{tikzpicture}
\end{document}
The main difference I noticed was the line \def\pgfsysdriver{pgfsys-dvisvgm.def}
. With that line I get this issue when manually using latex
+ dvisvgm
to create the image. Removing that line, I no longer see the issue. I don't know exactly what this pgfsys-dvisvgm.def
is doing, but something about that driver is causing the issue.
from pg.
When I try locally to latex
a tex file with the \def\pgfsysdriver{pgfsys-dvisvgm.def}
line, the result is blank. That is, if I open the DVI (and I don't think I have a dvi reader, so it gets auto-converted to PDF) it's just blank. Commenting out that line, it goes back to what it should be.
I found this:
https://tex.stackexchange.com/questions/695802/incorrect-tikzpicture-size-when-using-dvisvgm-output-driver-pgf-tikz
But given that I am just getting blank DVIs from local latex
execution, I'm not able to try out the solution there.
from pg.
@Alex-Jordan I didn't actually look at the .dvi
, only the resulting .svg
. I too see that with the \def\pgfsysdriver{pgfsys-dvisvgm.def}
and viewing the image.dvi
with xdvi
that I don't see anything (blank image), but I do see the image after conversion to .svg
, with incorrect clipping.
from pg.
The line \def\pgfsysdriver{pgfsys-dvisvgm.def}
is what makes it work correctly with dvisvgm
. Without that there will be lots of other problems with the generated svg images.
There does seem to be a bug though as @Alex-Jordan's link shows. That was filed as an issue at pgf-tikz/pgf#1275, and a pull request that fixes it was merged. So in future releases of dvisvgm
this will be fixed.
from pg.
If you want to fix this on your system, then change line 130 of /usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-dvisvgm.def
to \raise-\pgf@ya\hbox{\ifpgf@sys@svg@inpicture\else\special{dvisvgm:bbox \pgf@sys@tonumber\pgf@picmaxx\space\pgf@sys@tonumber\pgf@picmaxy}\special{dvisvgm:bbox lock}\fi\box#1\ifpgf@sys@svg@inpicture\else\special{dvisvgm:bbox unlock}\fi}%
. At least that is the file and line number on Ubuntu 22.04.
from pg.
By the way, you will always see a blank dvi when using the pgfsys-dvisvgm.def
pgf system driver. That is because everything is converted to postscript specials that can be correctly dealt with by dvisvgm
. Postscript specials don't give output in dvi, but are perfectly valid in a dvi file. The dvi files created with that pgf system driver are not intended to be used directly. They are meant to be processed by dvisvgm
.
from pg.
That edit worked on my local system, and now I get an SVG that has proper bounding where I previously did not.
Are you saying the the latest dvisvgm
version does not have the correction, but somewhere a develop branch has it? I am wondering if TeXLive 2024 will have it. And wondering if the 2.19 installation/upgrade instructions should suggest installing a particular version of dvisvgm
or latex distribution.
from pg.
I don't think the fix is in dvisvgm
, but in the pgf
backend being used by pgfplots
. On Debian, the package that controls the file pgfsys-dvisvgm.def
that is edited is texlive-pictures
, which is part of TeXLive, so the fix should come with newer versions of TeXLive.
Would it be worth adding a comment about this around the configuration to use dvisvgm
vs pdf2svg
configuration option?
from pg.
Yes, the fix is actually not in dvisvgm
itself, but in the pgfsys-dvisvgm.dev
file (which is in the texlive-pictures
package on Ubuntu) as @somiaj said.
The fix has been committed to the master branch of https://github.com/pgf-tikz/pgf (which is probably their develop branch).
from pg.
We could do something similar to what we do for the imagemagick policy file, and that we used to do for the issue with UTF-8 encoding with XMLRPC::Lite. Make a patch that is applied in the docker build, and also add instructions to the webwork 2.19 installation manual as to how to apply that patch.
from pg.
Related Issues (20)
- Bug when a matrix Math Object is reused as an answer HOT 10
- PGML.pl has lines that should have been removed. HOT 1
- checkboxlist within a RadioMultiAnswer HOT 4
- Using upToConstant with complex numbers HOT 4
- keyboard issue with GraphTool HOT 8
- inconsistency in multiple choice macros HOT 4
- run-perltidy deletes .bak files
- Error answers now are escaped when they shouldn't be. HOT 1
- variables declared with `my` lead to errors HOT 1
- student answers get spaces normalized
- iframeResizer, feedback popover, and mqeditor HOT 16
- Updating AnswerFormatHelp.pl HOT 5
- Viewing all correct answers at the same time HOT 4
- PTX "image" tag getting changed to "img" HOT 5
- error with brace and x HOT 9
- PG editor not decoding as expecting HOT 1
- macros/graph/PGnauGraphics.pl doesn't use unique name, which can break tests. HOT 1
- CheckboxList reveals the correct answers HOT 3
- MathQuill toolbar placement in a relatively positioned parent - bug when in an RTL course. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg.