Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LatexLens

License: MIT Python 3.11+ Platform: macOS

A macOS desktop resident tool that recognizes LaTeX/math expressions from any screen region and generates research-oriented explanations — local OCR + optional LLM analysis.

Snip a math region → recognize LaTeX → explain it (research/paper/coding/review/homework mode) → save to markdown.

How it works

screen snip ──▶ pix2tex OCR ──▶ LaTeX ──▶ rule-based / LLM explainer ──▶ markdown + clipboard
                                  │
                                  └─ optional: send image + OCR + context to LLM for deeper analysis
  • Local OCR by default (pix2tex), no API key needed to start
  • Optional LLM enhancement (OpenAI) for complex symbols, Chinese context, and use-case-level explanation
  • Falls back to local rule-based analysis if the API key is missing or the call fails

Features

  • Manual snip input: drag a screen region and run math OCR
  • Background resident app: system tray icon + global hotkeys
  • Immediate floating preview: after snip, show result panel near the selected area
  • Research-oriented explanation format: scenarios + core idea + hypotheses + 3-step experiment plan + risk boundaries
  • Task mode switching in tray: Research / Paper / Coding / Review / Homework
  • Optional LLM enhanced analysis (image + OCR + context)
  • Auto-save each result to markdown and copy LaTeX to clipboard

Quick Start

pip install -r requirements.txt
python run.py

Python 3.11+ recommended.

Default Hotkeys

  • Snip capture: <cmd>+<shift>+s
  • Show last result summary: <cmd>+<shift>+l
  • Quit app: <cmd>+<shift>+q

Editable in default_config.yaml.

LLM Enhanced Analysis (optional)

export OPENAI_API_KEY="your_api_key_here"
# default_config.yaml
llm:
  enabled: true
  provider: "openai"
  model: "gpt-4.1"
  use_structured_output: true

If the API fails or the key is missing, the app automatically falls back to local rule-based analysis. With use_structured_output, LatexLens requests strict JSON-schema responses for stable formatting.

Output

Results are saved to outputs/result_YYYYMMDD_HHMMSS.md, each containing the source mode, recognized LaTeX, and the explanation/notes.

Notes

  • On macOS, global hotkeys and screen capture require Accessibility and Screen Recording permissions.
  • pix2tex depends on the PyTorch stack and may take time to initialize the first time.
  • For better OCR quality, snip tightly around the expression area.
  • Context extraction uses tesseract if installed; Chinese OCR quality depends on installed language packs (e.g. chi_sim, chi_tra).

Author

aznikline — see also nanoagent (source-first AI agent learning) and alpha-mining-system (quant factor mining).

License

MIT License © 2026 aznikline

About

macOS desktop tool: snip a screen region, recognize LaTeX via OCR, explain it (local rules + optional LLM)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages