I'm writing a book using a Jupyter notebook for each chapter. I also generate pdf and html versions using nbconvert and bookbook.
I would like to be able to do two things:
- Control the fonts used in the notebooks
- Use a common set of Latex macros in all the notebooks
It seems to me that both of these could be accomplished cleanly if it were possible to have the notebook load a specific .css file and a specific .js file on startup.
Workarounds that I'm not satisfied with:
- Modify the global custom.js for jupyter/ipython. This will change the appearance of all my notebooks, and won't work for other people who read the book.
- Loading .css and .js files via commands in a notebook cell. I'm currently doing this for the CSS, but it's hacky since the notebook looks wrong when it loads, and then suddenly changes appearance when you execute the cell. It also exposes code that the reader shouldn't have to deal with. For javascript, I haven't been able to get this approach to work at all. If I could, that would at least be a step forward.
- Define latex macros inside math delimiters in a notebook cell. This would require modifying every notebook whenever a new macro is added. It also breaks when converting to PDF, and (again) exposes to the reader things that they shouldn't need to deal with.
It seems to me that it would be reasonable to allow notebook metadata to specify a CSS file and a JS file to be loaded on startup. I'm also willing to write an nbextension, but I haven't been able to figure out how to do so or whether such a thing could solve my problems.
I'd be very grateful for any help from the Jupyter experts, or others who have tried to deal with this issue.