jupyter-book
jupyter-book copied to clipboard
Make code block full width when building book PDF from HTML
Describe the bug
context I am building a book written in MyST. How can I make the code block full width when building book PDF?
expectation This is what the HTML looks like. The code blocks are in full width.
bug
This is what the PDF looks like when built with pyppeteer
. The code blocks are in center alignment, not full width
Reproduce the bug
- Build book HTML with
jupyter-book build .
-
pip install pyppeteer
-
jupyter-book build . --builder pdfhtml
List your environment
No response
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
I think this is an issue with Jupyter book rather than puppeteer. I just created a minimal Jupyter book example with the following command. The HTML looks fine, but when printing the HTML to PDF using Chrome, the code blocks are not in full width.
jupyter-book create mynewbook/
It took me an hour to debug and, finally, I figured it out. The issue is caused by the {code-cell}
directive in MyST. The code blocks in PDF will render correctly if the {code-cell}
directive is not being used.
Just realized that removing the {code-cell}
directive will result in the cell not being recognized as a code cell in the notebook paired with MyST through Jupytext.
thanks for digging through the layers @giswqs.
@AakashGfude it appears there is a styling issue with code-cell
. Do you think this is an issue with the directive or is this caused by sphinx-book-theme
and added styling to it in the html perhaps?
Any updates on this issue? Thanks.
This issue seems resolved with Jupyter-book v0.15.1