explaingit

connorferster/handcalcs

5,812CSSAudience · researcherComplexity · 2/5Setup · easy

TLDR

A Python library for Jupyter notebooks that renders math calculations as hand-written-style equations, showing the symbolic formula, then the numbers substituted in, then the result, making engineering calculations easy to review and audit.

Mindmap

mindmap
  root((handcalcs))
    What It Does
      Render math steps
      Symbol then numbers
      Final result shown
    Usage Modes
      Cell magic render
      Function decorator
      Streamlit apps
    Output Options
      LaTeX rendering
      PDF export
      Raw LaTeX via tex
    Audience
      Engineers
      Technical reviewers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add %%render to a Jupyter notebook cell to automatically display engineering calculations as formatted step-by-step equations without writing LaTeX by hand.

USE CASE 2

Apply the @handcalc() decorator to a Python function to show readable calculation output inside a Streamlit web app.

USE CASE 3

Export a completed calculation notebook as a PDF for engineering documentation or client sign-off.

USE CASE 4

Use %%tex to convert a Python math expression to raw LaTeX and paste it directly into a technical report.

Tech stack

PythonJupyterLaTeXStreamlit

Getting it running

Difficulty · easy Time to first run · 5min

PDF export requires a LaTeX environment such as TeX Live or MiKTeX installed on the system.

In plain English

Handcalcs is a Python library that takes mathematical calculations written in Jupyter notebooks and displays them the way a person would write them by hand: first the symbolic formula, then the numbers substituted in, then the final result. If you write something like c = 2*a + b/3 in a notebook cell and use handcalcs, it renders as a formatted equation showing the formula with letters, then with the actual numbers plugged in, then the answer. This makes it much easier for a reviewer to check the work step by step without guessing where the numbers came from. The library is aimed at engineers and technical professionals who document calculations in Jupyter notebooks and want clean, readable output without writing LaTeX by hand. Because handcalcs shows the numeric substitution explicitly, calculations become significantly easier to audit. There are two main ways to use it. The first is as a Jupyter cell magic: adding %%render at the top of a cell causes handcalcs to automatically render all the calculations in that cell as LaTeX. The second is as a Python decorator, @handcalc(), which you apply to a function definition. The decorator approach also works outside Jupyter, for example inside a Streamlit web application. A %%tex command lets you convert a Python expression directly into raw LaTeX text if you want to copy the output into another document or system. Several configuration options can be set globally, including the number of decimal places shown, the decimal separator character, whether to display scientific notation, and how many columns to use when showing parameters. Custom symbol mappings are also supported. Completed notebooks can be exported as PDFs if a LaTeX environment is installed on the system. The project wiki documents compatibility with other calculation-related libraries. Handcalcs is available on PyPI and can be installed with pip.

Copy-paste prompts

Prompt 1
Show me how to use the %%render magic in a Jupyter notebook cell with handcalcs to display a structural beam deflection formula, showing symbol, substitution, and result.
Prompt 2
I want to use the @handcalc() decorator to display calculations in a Streamlit app. Give me a minimal working example with two input sliders and a formula.
Prompt 3
How do I configure handcalcs globally to show 3 decimal places, use a comma as the decimal separator, and display results in scientific notation?
Prompt 4
How do I export a handcalcs Jupyter notebook to a PDF? What LaTeX environment do I need installed on macOS or Windows?
Prompt 5
I want handcalcs to render my variable sigma_yield as the Greek letter sigma with a y subscript. How do I add a custom symbol mapping?
Open on GitHub → Explain another repo

← connorferster on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.