Chapters can exist as stand-alone documents in different formats:
traditional LaTeX-style PDF report,
web pages with various various fancy stylings (e.g., Sphinx, Bootstrap) and possibility for multi-media elements,
blog posts (not exemplified here, but straightforward),
wiki (if you do not need mathematical typesetting).
Chapters can be flexibly assembled into a traditional LaTeX-based PDF book for a traditional publisher, or a fancy ebook.
The book and the individual chapter documents may have different layouts.
Active use of preprocessors (Preprocess and Mako) makes it easy to have different versions of the chapters, e.g., a specialized version for a course and a general version for the world book market).
DocOnce has support for important elements in teaching material: eye-catching boxes (admonitions), quizzes, interactive code, videos, structured exercises, quotes.
Study guides or slides can easily be developed from the running text and stored along with the chapters. These can be published as LaTeX Beamer slides, reveal.js slides, and IPython notebooks.
Implementation of point 1 and 2 is not trivial and requires some rules that might not feel natural at first sight in the setup. Writing a book soon becomes a technically and mentally complex task, just like developing a software system. For the latter people have invented a lot of sophisticated technologies and best practices to deal with the complexity. The present setup for books is a similar collection of my own technologies and best practices, developed from writing thousands of pages. In particular, the setup has been successfully used for the large-scale 900-page Springer book "A Primer on Scientific Programming with Python" by the author (individual chapters of this book can be examined online in "various ebook formats": "http://hplgit.github.io/primer.html/doc/pub/looplist/index.html") as well as for books in the works.
To use this setup, just clone the repository and you have the
directory structure, the scripts, and example files to get started with
a book project at
once! The source files for this book (especially in
doc/src/chapters/rules) constitute nice demonstrations for learning
about basic and advanced DocOnce writing techniques.