AllenDowney / ModSimPy

Text and supporting code for Modeling and Simulation in Python
https://allendowney.github.io/ModSimPy/
MIT License
823 stars 1.76k forks source link

Convert notebooks to LaTeX #56

Closed AllenDowney closed 3 years ago

AllenDowney commented 3 years ago

I am opening this issue to document my thinking about how to generate the LaTeX version of the book, and to solicit comments.

As of Version 4, the source of the books is the Jupyter notebooks. I use JupyterBook to generate the HTML version, which is hosted here on GitHub.

For publication, I would like to generate a LaTeX version.

I considered using nbconvert to convert from ipynb to tex, but the LaTeX that gets generated would be hard to work with.

A better option seems to be using nbconvert to generate Markdown and then use Pandoc to generate LaTeX.

Pandoc gets pretty close, with these command-line arguments:

--listings --top-level-division=chapter

But I will probably still have to do some post-processing:

  1. The LaTeX files PanDoc generates are complete documents with frontmatter, etc. To convert these files to chapters that can be included in a top-level document, I'll have to strip some lines from the beginning and end.

  2. Currently the images don't survive the translation process.

It seems like it will take some effort to get this working, so before I go too far down this path, I want to consider alternatives.

I welcome comments from anyone who reads this, but I'd like to ask @hamelsmu and @jph00 in particular to take a look. With your experience with fastdoc, you might have suggestions. Thanks!