handcalcs#
Python calculations, written out the way you would write them by hand.
handcalcs turns ordinary Python calculation code into a formatted calculation: the symbolic formula, then the formula with every value substituted in, then the result. Because the substitution step is shown, anyone can check the calculation by hand.
a = 2.5 # Side a, in m
b = 4.0 # Side b, in m
c = sqrt(a**2 + b**2) # Hypotenuse
$$\begin{aligned} a &= 2.5 \quad\text{(Side a, in m)} \\ b &= 4 \quad\text{(Side b, in m)} \\ c &= \sqrt{a^{2} + b^{2}} = \sqrt{2.5^{2} + 4^{2}} = 4.717 \\ &\quad\text{(Hypotenuse)} \end{aligned}$$
The same parsed calculation can be sent to different renderers: Markdown and LaTeX for Jupyter and documents, HTML for web pages, plain text for terminals and logs, a live Excel worksheet, and a Word document with editable equations. You can restyle the built-in renderers or write your own.
Where do you want to go?#
Install handcalcs and render your first calculation in Jupyter or a Python script.
Markdown, LaTeX, HTML, plain text, Excel or Word: what each produces and when to use it.
The %%render cell magic, the HandCalcs object, or the @handcalc decorator.
Tested recipes: precision, checks, notation, equation numbers, Word and PDF reports, web apps.
Add colors to the HTML output, change Markdown and LaTeX tokens, add symbols.
How rendering works, the methods you override, and worked examples.
Set up a development environment, find your way around the source, run the tests.
Looking for a specific function, option or # hc: command? See the
reference.