You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to convert PDF file: the SVG's nesting depth is too high #6051
To work around #6035, I created a package that should've solved all of my problems and I could just move on. But now apparently my diagram has too much stuff in it (but it's basically a cetz canvas wrapper), and it gives me this error:
error: Failed to convert PDF file: The SVG's nesting depth is too high..
@LaurenzV confirmed that it should be considered a bug (and I agree). I use Typst to create an image that is used in a Typst document that should compile without a hitch. Typst + Typst shouldn't give an error.
Cc @johannes-wolf (just so you are aware of such an issue)
I'm pretty lucky with this one. I used place(figure(box(image()))) pattern before, but thankfully, if I remove the box() call, then it doesn't error anymore, and guess what? With cetz I can make a rect wrapper around all canvas content, and it doesn't increase the nesting. So I used the group(name: "g", stuff); rect("g.south-west", "g.north-east") pattern and it works like a charm!
As a result, the new 3 PNG images add 7.51 MiB to the document file + are not sharp + increase page loading time, but the new 3 SVG images add only 1.88 MiB + are razor-sharp + make pages load fast.
So in the end, I indeed was able to make my plan work, and all it took is a DOT language parser and plotter written in pure Typst. Unfortunately, the time it takes to compile my diagrams is about 0.5 s/diagram, which is 3 s for 6 of them. Which gives me about 4.8 s of total compilation time for my PDF document. I guess it's acceptable, as currently it's probably by far the best option anyway (for my relatively simple diagrams).
P.S. Since I have screenshots in those pages, their size is still not very lean, but I can't really do anything about it, at least right now. Maybe I'll compress them in the future (or maybe they are already compressed enough).
Activity
Andrew15-5 commentedon Mar 12, 2025
The MRE for CeTZ would be something like this:
Andrew15-5 commentedon Mar 12, 2025
I'm pretty lucky with this one. I used
place(figure(box(image())))pattern before, but thankfully, if I remove thebox()call, then it doesn't error anymore, and guess what? With cetz I can make a rect wrapper around all canvas content, and it doesn't increase the nesting. So I used thegroup(name: "g", stuff); rect("g.south-west", "g.north-east")pattern and it works like a charm!As a result, the new 3 PNG images add 7.51 MiB to the document file + are not sharp + increase page loading time, but the new 3 SVG images add only 1.88 MiB + are razor-sharp + make pages load fast.
So in the end, I indeed was able to make my plan work, and all it took is a DOT language parser and plotter written in pure Typst. Unfortunately, the time it takes to compile my diagrams is about 0.5 s/diagram, which is 3 s for 6 of them. Which gives me about 4.8 s of total compilation time for my PDF document. I guess it's acceptable, as currently it's probably by far the best option anyway (for my relatively simple diagrams).
P.S. Since I have screenshots in those pages, their size is still not very lean, but I can't really do anything about it, at least right now. Maybe I'll compress them in the future (or maybe they are already compressed enough).