Show HN: CalcuLaTeX, a pretty-printing calculator language

  • Hey HN, I created CalcuLaTeX because I was frustrated with my workflow for chemistry and physics homework. Generally, I'd use the Python REPL as a calculator and type each problem into LaTeX to turn it in. CalcuLaTeX merges these two steps and makes it easier to reason about calculations by real time visual feedback.

    I've posted on r/rust as well (https://www.reddit.com/r/rust/comments/lqn5aa/calculatex_a_p...), and there seems to be interest in using it for scientific papers and such.

    The only alternative I know of is PTC MathCAD, which is quite powerful and definitely worth looking into. However, it's quite expensive and Windows only.

    The main repo (a Rust library and basic CLI) can be found here: https://github.com/mkhan45/CalcuLaTeX

    The website repo using WASM and very hacky JS can be found here: https://github.com/mkhan45/CalcuLaTeX-Web

  • FYI you might find the GNU units(1) tool useful, which has a huge catalog of units and understands about the same set of math operations as a scientific calculators. From the demo I actually thought this was using GNU units in the background.

  • This is awesome!

    Is there a way to get the LaTeX source with the completed calculation (so that you can copy/paste the whole thing in your local LaTeX installation and, well, hand in your homework)? (sort of a "middle" tab)

  • Wordmat is a free, open source extension to MS Word which gives you access to a full CAS from Word.

    http://www.eduap.com/wordmat/

    https://github.com/Eduap-com/WordMat

  • That's wonderful! When I used to do my math and physics homework, I used Mathematica as a calculator. It has built-in LaTeX formatting available (right click, Copy As > LaTeX). But likewise Mathematica is expensive and proprietary software so it doesn't appeal to everyone.

  • This is awesome! Does it do other conversions than weight? mol/lengths/surface/volume/energy?

  • This is cool! I think it can be really useful.

    My main suggestion is better error handling: make it so that when a calculation is invalid, it shows the error where the result would be (e.g. red text with the error message) instead of failing to compile the whole script.

  • Very cool!

    What made you choose LaTeX for the tool?

    It seems like it wouldn't be too hard (maybe?) to get a proper algebra engine to assign variables. Currently you can do `x = 10` but you can't do `x / 2 = 5`. I feel like this would be very helpful since you're using this for scientific calculations.

    It could then be possible to extend that further and leave the variable undefined if it doesn't (yet) have enough information to solve it. Then it could theoretically be used to solve simultaneous equations.

  • This is very cool. It looks much easier to use than the collection of Makefiles and build scripts I cobbled together in college.

    One thing that’d make this even more awesome is the ability to drop in a data table and have it show up as a graph. The scripts I built in college allowed me to drop a CSV file into a directory and have it automatically turned into an EPS graph that I could use in LaTeX. It made for pretty easy, but very good looking reports.

  • This is awesome. It reminds me of the iOS app Calca[1], which is similar.

    [1] http://calca.io/

  • I'm so glad you made this! I'm also very upset that this didn't exist 10 years ago when I really needed it. Well done!

  • You might like Frink! https://frinklang.org

  • I think an alternative would be Sympy in a Jupyter notebook.

  • Ti-89 is a great option, since you can also get the nice formatting while you're doing exams

  • This is really fun. Nicely done! I love the output of LaTeX but never liked writing it.

  • Very cool! The output looks nice, will definitely give this a whirl for some blog posts.

  • Very cool, auto-conversion is really awesome, I think I found a bug though:

    5 kg + 5 kg = 10 kg

    but

    5 kg + 6 kg = 11.000 kg

  • I use Marker markdown editor + MathJax + embedded JavaScript to achieve similar results.

  • Hey, definitely check out Blockpad (https://blockpad.net). It does calculations with units, integrated with documents, spreadsheets, and drawing. Speaking from the Blockpad team here, would love to hear your experience.

    We have Windows app and beta web app. Also Mac app coming soon. It's free for students and otherwise still inexpensive.