Understand handcalcs rendering behavior and limitations
mainCore Behavior
handcalcs renders arithmetical calculations written in Python code into LaTeX. It is not a general-purpose Python-to-LaTeX converter.
Key Limitations
- Single-line statements only:
handcalcsparses individual lines of Python within a cell. It does not parse the cell as a whole. Multi-line statements likeforloops,withstatements, or function definitions will not render. - Iteration support: Rendered iterations (e.g., showing the steps of a
forloop) are not supported. To handle iterations, perform the loop in a non-rendered cell and render the final result in a subsequent cell. - Collection types:
listanddicttypes may not render correctly. Usetupleor one-dimensionalnumpyarrays (vectors) for collection-based arguments (e.g.,sum((23, 123, 45))).
Arithmetic Operator Mapping
| Python Operator | LaTeX Rendering |
|---|---|
+ | + |
- | - |
* | \cdot (dot operator) |
/ | Fraction |
** | Superscript |
% | \mod (mod function) |
// | Not supported (use math.floor instead) |