
Handcalcs: Write calculations in Python, rendered automatically as Latex - cmferster
https://github.com/connorferster/handcalcs
======
cmferster
This is a library that I use daily in my work as a design engineer for quickly
writing and printing calculations. My company has agreed that I may publish it
as free and open source.

In the engineering world, often times Excel is king. However, it is not
transparent: you type a formula in a cell and 1) the formula only contains
cell references (unless you define cell names) and 2) the formula is hidden.
For accountability, you have to separately type the formula in an adjacent
cell so you can print your sheet out as a report or calc sheet. However, the
formula you typed is just text: the resulting value has no relationship with
the formatted formula you typed out and you have to change both to update.
This makes maintenance cumbersome.

I wanted the formula I typed to be the same as the formatted representation of
the formula I typed -- change the representation and the result changes.
SMathStudio and MathCAD do this but you still have to layout formulas on the
sheet and, most importantly, none of these software packages show the
numerical substitution, critical for quickly checking correctness of
calculations. I wrote handcalcs to address this problem.

To use: run Jupyter and use the cell magic, %%render, then just type in your
calculations. Run the cell to see them all rendered out in Mathjax or Katex.

While it is designed to work in Jupyter, it also has a decorator interface for
use in other environments that render Latex (e.g. Streamlit).

The intended audience for handcalcs is engineers, estimators, teachers,
students, or anyone else that tends to need to perform documented
calculations. However, I am guessing that this may be useful to many others in
ways I do not know.

Open to feedback and suggestions for enhancement!

~~~
randyzwitch
Thanks for sharing! I re-posted it here on the Streamlit forum as well,
hopefully you'll get more feedback there as well:

[https://discuss.streamlit.io/t/dynamically-rendering-
latex-i...](https://discuss.streamlit.io/t/dynamically-rendering-latex-in-
streamlit/4047/2)

