How connorferster/handcalcs works
handcalcs turns executed Python calculations into hand-formatted LaTeX, primarily through Jupyter cell magics or a function decorator. Both paths gather calculation source and computed values, then use the LaTeX renderer to classify and format expressions; Jupyter displays the result while the decorator returns rendered text with values. The package also supports SymPy cell conversion, configurable rendering, and an HTML exporter. The core rendering internals are sampled only in part, so the graph keeps their stages together rather than asserting unverified helper-to-helper calls.
Main entry points: render.py Cell magics · decorator.py Function decorator · handcalcs.py LaTeX renderer · __init__.py HTML exporter
Components 16
User interfaces
- Cell magics
src/handcalcs/render.py - Function decorator
src/handcalcs/decorator.py - Scope capture
src/handcalcs/decorator.py - SymPy conversion
src/handcalcs/sympy_kit.py
Calculation rendering
- LaTeX renderer
src/handcalcs/handcalcs.py - Cell classification
src/handcalcs/handcalcs.py - LaTeX formatting
src/handcalcs/handcalcs.py
Configuration
- Config API
src/handcalcs/global_config.py - Config defaults
src/handcalcs/config.json
Export and integrations
- HTML exporter
src/handcalcs/handcalcs_html/__init__.py - HTML templates
src/handcalcs/handcalcs_html/classic
Other components
- Notebook user
- Python caller
- IPython
- nbconvert
- LaTeX output
Connections 14
- Notebook user → Cell magics: runs magic
- Cell magics → IPython: executes cell
- Cell magics → SymPy conversion: converts SymPy
- Cell magics → LaTeX renderer: renders source and values
- LaTeX renderer → Cell classification: classifies cell
- Cell classification → LaTeX formatting: formats lines
- LaTeX formatting → LaTeX output: produces LaTeX
- Cell magics → LaTeX output: displays or prints
- Python caller → Function decorator: calls function
- Function decorator → Scope capture: captures values
- Function decorator → LaTeX renderer: renders source and scope
- Config API → Config defaults: saves options
- HTML exporter → nbconvert: extends exporter
- HTML exporter → HTML templates: loads templates