betatim / notebook-as-pdf

Save Jupyter Notebooks as PDF
BSD 3-Clause "New" or "Revised" License
370 stars 73 forks source link

Add lower level headings to the export #17

Closed firasm closed 3 years ago

firasm commented 4 years ago

Hello! Thanks for a fantastic extension, it really works quite well and is very seamless.

As you mention in your blog post, lower level headings might be coming soon to this extension:

In a future version lower level headings might be included in the table of contents. This would give you a more detailed view of the notebook structure but also more clutter in the table of contents. Maybe a better solution is to allow people to insert "bookmarks" into the notebook. Each of these bookmarks would then be a table of contents entry.

I thought I'd open an issue requesting this feature as it would be super useful for me. I use jupyter notebooks for teaching and having a nice non-paginated PDF export of a notebook would be really handy!

firasm commented 4 years ago

RE above, I've also opened an issue in the jupyterbook repo about possibly integrating this export method there.

Use-case

Below are two PDF exports from an example jupyter book that is not mine (ThreatHunter Playbook):

  1. Standard Jupyterbook PDF export

  2. Using notebook as PDF extension to export

betatim commented 4 years ago

What do you think of including (only) h1 and h2 tags?

The reason i am hesitant to add "all headings" is that I don't enjoy the pdf table-of-contents UX when you have lots of levels of "folding". It makes it super hard to see things and read the titles without making the TOC part of the UI wider.

Another option I just thought of is to not use the "nesting" feature of a PDF TOC but instead prefix the headings with something like ` (nothing) forh1, · forh2, ·· forh3`, etc. So an ASCII character to indicate "nesting" level.

firasm commented 4 years ago

You're right - it gets unwieldy past a certain depth.

It's probably a lot more effort, but I like how sphinx handles this by having a maxdepth parameter. So in this case, it could be an optional argument, with the default set at a reasonable H2 or H3 ?

betatim commented 3 years ago

Level 2 headings are now included (see aaa8565044c8673305af801a2160802132407a95).

firasm commented 3 years ago

Amazing! Nice work!