Skip to content

Chapter format (Peanutbook)

Each Peanutbook chapter file should follow this structure at the beginning. The build toolchain uses it to generate chapter title pages and running headers.

Required Structure

Each chapter markdown file must follow this exact structure at the beginning:

# Chapter N: Chapter Title

*Subtitle text in italic*

> Quote text here
- Author Name | Title, Organization, Year

**Code Summary**

- `code_element`: Description of the code element
- `another_code`: Another description
- ... (list 10 most important classes or functions used in the chapter)

Format Rules

  1. Chapter Header (Line 1):
  2. Format: # Chapter N: Chapter Title
  3. Must start with # (H1 heading)
  4. Include chapter number and full title

  5. Subtitle (Line 3):

  6. Format: *Subtitle text in italic*
  7. Single line, wrapped in asterisks for italic
  8. Should be a brief, descriptive subtitle

  9. Quote Section (Lines 5-6):

  10. Line 5: Blockquote with > followed by quote text
  11. Line 6: Author attribution with - (dash), format: - Author Name | Title, Organization, Year
  12. Quote should be inspirational or relevant to the chapter

  13. Code Summary (Lines 8-19):

  14. Header: **Code Summary** (bold)
  15. List format: -code_element: Description
  16. Use backticks around code elements
  17. List approximately 10 most important classes or functions used in the chapter
  18. Each item should be concise and descriptive

  19. Main Content (Line 21+):

  20. Regular chapter content starts after the Code Summary section
  21. All standard markdown formatting applies

Example

# Chapter 1: Vector Spaces and Inner Products

*From geometric intuition to abstract algebra*

> Mathematics is the art of giving the same name to different things.
- Henri Poincaré | Mathematician, Physicist, 1854-1912

**Code Summary**

- `np.dot()`: Computes dot product of two vectors
- `np.linalg.norm()`: Computes vector norm (default L2)
- `np.outer()`: Computes outer product of two vectors
- `np.cross()`: Computes cross product (3D only)
- `np.inner()`: Computes inner product (generalized dot product)
- `np.angle()`: Computes angle between vectors
- `np.proj()`: Projects one vector onto another
- `np.orthogonal()`: Checks if vectors are orthogonal
- `np.unit_vector()`: Normalizes vector to unit length
- `np.gram_schmidt()`: Performs Gram-Schmidt orthogonalization

## Introduction

The main content of the chapter starts here...

Notes

  • The quote and code summary sections are automatically extracted by bubble-extract-chapter-title for PDF generation
  • Do not modify the structure of these sections after they are set up
  • The code summary should reflect the actual content of the chapter
  • For chapters that don't use code, you can omit the Code Summary section or list mathematical concepts instead

Integration with Build System

The chapter format is processed by: - bubble-extract-chapter-title: Extracts the title, subtitle, quote, and code summary to generate chapter title pages - bubble-convert: Uses the extracted information when converting chapters to PDF - bubble-build: Includes the chapter title pages when building the complete book

See the Quick start for information on how to use the build system.