Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF build broken by inclusion of image taller than page height in an admonition #5936

Closed
jfbu opened this issue Jan 12, 2019 · 1 comment
Closed

Comments

@jfbu
Copy link
Contributor

jfbu commented Jan 12, 2019

Problem

PDF build is broken if inside an admonition (warning, caution, attention, danger, error) there is an included image file which a requested height close to or larger than the total text area in a page.

Procedure to reproduce the problem

Test
====

.. attention::

   .. image:: rimg.*
      :height: 1000px

With this image rimg.png:

rimg

(or any image at least about twice taller than wide, so that the Sphinx cap on maximal width to \linewidth does not modify requested height, bigger than text height)

Error logs / results

PDF build crashes after spitting out close to 5000 empty pages.

! TeX capacity exceeded, sorry [input stack size=5000].
\@ifundefined #1->\ifcsname #1
                              \endcsname \@ifundefin@d@i \else \@ifundefin@d...
l.89 \end{sphinxadmonition}
                           
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on FOO.log.
=== TeX engine is 'pdfTeX'
Latexmk: Index file 'FOO.idx' was written
Latexmk: Errors, so I did not complete making targets

Expected results

The image is either resized or split to not create errors.

Comment

The problem comes from framed.sty : an image can not be split in LaTeX (one can lie to LaTeX about its actual size however, but then it will collide with following paragraph) and an over-sized image is first moved to next page, then framed.sty realizes there is not enough room, the image is again moved to next page, etc... creating infinite loop until some TeX memory is exhausted.

It is not possible to split the image from inside LaTeX, but it is possible to include it multiple times and clip each inclusion to successive horizontal slices. In recent pdftex/xetex this will not increase PDF filesize. However, this is definitely complicated method. See this tex.sx question I posted on a TeX/LaTeX forum.

More reasonable is to modify \sphinxincludegraphics which is the Sphinx provided wrapper of LaTeX \includegraphics to force a maximal image height compatible with standing alone on one page (with the framing). Already, \sphinxincludegraphics forces the width to not exceed \linewidth, so this keeps the same spirit.

Environment info

  • OS: Mac
  • Python version: 3.6.6
  • Sphinx version: 1.8
  • TeXLive 2018
@jfbu jfbu added this to the 1.8.4 milestone Jan 12, 2019
@jfbu
Copy link
Contributor Author

jfbu commented Jan 12, 2019

Sorry, completely forgot to say this issue originates in spatialaudio/nbsphinx#276. There it arises in a non-Sphinx LaTeX environment, but this environment uses framed.sty analogously to what Sphinx does for code-blocks and admonitions ( of the attention type).

PR spatialaudio/nbsphinx#277 fixes this by using a variant of \sphinxincludegraphics making sure the height of included image will not be too big.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant