spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
450 stars 130 forks source link

LaTeX warning: multiple pdfs w ith page group included in a single page #662

Open mgeier opened 2 years ago

mgeier commented 2 years ago

Other latex warnings:

[25 <./python_logo.pdf> <./main-logo.pdf

pdfTeX warning: pdflatex (file ./main-logo.pdf): PDF inclusion: multiple pdfs w
ith page group included in a single page
> <./fe1ba2728605169d4270646e0702b6ef37f4aad5.png>] [26 <./6e42ca0abdf1647b0e5b
794e9605d81a09e28d28.png>] [27]

But I guess the "multiple pdfs" are python_logo.pdf and main-logo.pdf (which are auto-generated from SVG files with rsvg-convert).

Maybe the converter settings could be changed to avoid this?

Do you know what "with page group" means?

I did not as I don't practice graphics inclusions often enough... turns out this tex.sx question i.e. https://tex.stackexchange.com/questions/76273/multiple-pdfs-with-page-group-included-in-a-single-page-warning has by luck some quite informative answer.

So whenever you include 2 pdfs in the same page you may encounter the problem, depending how the pdf's were produced... one gets indeed the warning from using

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\noindent\includegraphics{{python_logo}.pdf}

\noindent\includegraphics{{main-logo}.pdf}

\end{document}

test file (refereed to as testincludegraphics.tex below).

I tested that adding

\ifdefined\pdfsuppresswarningpagegroup
   \pdfsuppresswarningpagegroup=1 % cf https://tex.stackexchange.com/a/78020
\fi

does let the warning go away. It seems from some other answers at the tex.sx question that although PDFTeX does a bad job at emitting most of the time the warning for no real reason in some cases though the output has problems and warning is justified.

I tested with luatex and there seems to be no warnings with my test file. I then made the mistake to test above file with xetex (xelatex testincludegraphics) and

xdvipdfmx:fatal: pdf_link_obj(): passed invalid object.

No output PDF file written.
(see the transcript file for additional information)
Error 256 (driver return code) generating output;
file testincludegraphics.pdf may not be valid.
Transcript written on testincludegraphics.log.

This already happens with the above test file reduced to trying to include either one of the two files so is another issue.

Sorry for gory details, I hate this too, but only to be complete

Anyway it looks as if something is fishy with file python_logo.pdf at least Ghostscript complains.

And a xelatex run breaks with error status 1 when one tries to use \includegraphics{{python_logo}.pdf}.

Sorry for long, I hate this too when it turns out this way (and I will not try to report this "upstream"). As has been recently aptly commented by some passer-by:

You guys are doing some crazy work there. But is this not insane? Are there no proper solutions to getting SVGs into PDFs in freakin' 2022?

Originally posted by @jfbu in https://github.com/spatialaudio/nbsphinx/issues/657#issuecomment-1206097179