--- title: LaTeX Editor emoji: 📄 colorFrom: blue colorTo: purple sdk: gradio sdk_version: 5.12.0 app_file: app.py pinned: false license: mit --- # LaTeX Editor A real-time LaTeX editor with instant PDF preview, optimized for speed and concurrency. ## Features - **Live Preview**: See your PDF update as you type (500ms debounce) - **Syntax Highlighting**: Full LaTeX syntax highlighting with Dracula theme - **Fast Compilation**: ProcessPoolExecutor for parallel compilations - **Caching**: LRU cache skips recompilation for identical content - **Resizable Panels**: Drag the divider to adjust editor/preview ratio - **Zoom Controls**: Zoom in/out on the PDF preview ## Local Development 1. Install TeX Live: ```bash # macOS brew install --cask mactex # Ubuntu/Debian sudo apt-get install texlive-latex-base texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra ``` 2. Install Python dependencies: ```bash pip install -r requirements.txt ``` 3. Run the server: ```bash python app.py ``` 4. Open http://localhost:7860 ## Deployment on Hugging Face Spaces The `packages.txt` file automatically installs TeX Live packages when deployed to HF Spaces. ## Architecture ``` ┌─────────────────┐ WebSocket ┌──────────────────────┐ │ Browser │◄──────────────────►│ FastAPI Server │ │ - CodeMirror │ │ - WebSocket Handler │ │ - PDF.js │ │ - ProcessPoolExec │ └─────────────────┘ │ - LRU Cache │ └──────────┬───────────┘ │ ▼ ┌──────────────────────┐ │ pdflatex │ │ (parallel workers) │ └──────────────────────┘ ``` ## Tech Stack - **Backend**: FastAPI + uvicorn - **Frontend**: Vanilla JS + CodeMirror 5 + PDF.js - **Compilation**: pdflatex (TeX Live)