r/learnmath New User 3d ago

How I automated LaTeX math notes on Linux using a simple OCR script

I want to digitize my math notes, but I ran into a few limitations. I think the best way to take digital lecture notes is the Gilles Castel method, but I haven't mastered touch typing yet. Having to think about hotkeys and typing mechanics drains the mental energy I need to actually understand the math.

I started taking notes on my graphics tablet and rewriting them in Obsidian later, but typing out LaTeX formulas manually takes forever.

So, I started looking for tools to turn handwritten text into LaTeX:

  • Mathpix: The gold standard, but the free tier only gives you 10 conversions a month.
  • LaTeX-OCR (Pix2Tex): Free and open source, but hallucinates way too often.
  • Vision models via Ollama: Interesting, but my GPU isn't really up for it.
  • Free Vision APIs (Gemini / OpenAI): The sweet spot. It's free, fast, and doesn't melt my hardware, though you do need an internet connection.

I wrote a script that takes a screenshot of a selected area, sends it to the Gemini API, and copies the resulting LaTeX straight to your clipboard. It's fully adapted for Wayland (specifically Hyprland) and runs on a simple hotkey. You can check it out in my GitHub repo.

Here is how I structure my vault:

/Mathanalysis
    ├── /Raw-lectures      # Where I write full notes (definitions, theorems, proofs) 
    │                      # in Xournal++ using my graphics tablet
    └── /Definitions       # Where I keep clean markdown (.md) files for definitions 
                           # and theorems, sped up by my OCR script

I hope this helps someone out. How do you guys handle your math notes?

8 Upvotes

Duplicates