jupyter-book: Fail to build pdf with pdflatex when notebook is in a subdirectory
Describe the bug
Given the template project, when “notebooks.ipynb” is moved to a subdirectory and _toc updated accordingly, the PDF failed to build due to the output image being not found by Latex.
Latex error message:
'LaTeX Warning: File `{_build/jupyter_execute/notebooks_2_0}.png' not found on input line 385.'
Note that the output image is properly generated by the notebook, but in the proper sub-directory: _build/jupyter_execute/examples/notebooks_2_0.png
Building the HTML works as expected.
To Reproduce
- Start from the basic example
jupyter-book create mynewbook/ - Move the
notebooks.ipynbinto a subdirectory:
cd mynewbook; mkdir examples; move notebooks.ipynb examples
- Adjust _toc accordingly:
- file: content
sections:
- file: markdown
- file: examples/notebooks
jb build --builder pdflatex newbookwill trigger the error
Expected behavior
The image file path in the generate latex source files should mirror the execution structure such that the generated images are found, and the PDF should be generated w/o errors.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (16 by maintainers)
@AakashGfude I have confirmed that my issue is different and have created a new issue that includes details and a minimal example: https://github.com/executablebooks/jupyter-book/issues/1636
@AakashGfude OK. The problem is caused by having my “root” files be in their own subdirectory. That is, this structure results in the images being referenced in the wrong locations:
whereas moving the copy of the intro directory out to the main directory works as expected:
@AakashGfude Thanks for your help! I believe you are correct. As an experiment, I copied a few of my directories and ran with --builder pidflatex, and it didn’t give me any more errors. The Chapters were numbered incorrectly (every section labeled 0.x instead of just x), but at least I can compile. Now the problem is that it is not easy for me to flatten my hierarchy because I have multiple files with the same names in the subdirectories. But I can roll some Python to get it done until that issue is fixed.
I’ll try to find the right issue to post to.
Thanks for following up. This is the repository I am having trouble with:
https://github.com/jmshea/Foundations-of-Data-Science-with-Python
The warning in the previous seems to be from the ImageCollector class of sphinx.
thanks for reporting this @closega.
It looks like the full path isn’t getting written by the
sphinxlatex writer. @AakashGfude and I will look into this issue.