A web-based interactive presentation system for teaching LaTeX with live compilation capabilities. This project transforms your traditional LaTeX workshop into an engaging, hands-on experience where students can edit and compile LaTeX code directly in the browser.
- π― Interactive Slides: Web-based presentation using Reveal.js
- β‘ Live LaTeX Compilation: Real-time rendering with your existing
render_snippetfunction - π¨ Syntax Highlighting: Beautiful code display with Prism.js
- π± Responsive Design: Works on desktop, tablet, and mobile
- πΎ Auto-save: Student edits persist in browser localStorage
- β¨οΈ Keyboard Shortcuts: Ctrl+Enter to compile code
- π§ System Health Checks: Visual indicators for LaTeX tool availability
Frontend (Port 3000) Backend (Port 5000)
βββββββββββββββββββββββ βββββββββββββββββββββββ
β HTML/CSS/JS β HTTP β Flask API β
β - Reveal.js slides βββββββΆβ - render_snippet() β
β - Code editors β β - LaTeX compilation β
β - Live compilation β β - PDF β PNG β
βββββββββββββββββββββββ βββββββββββββββββββββββ
- Python 3.7+
- LaTeX distribution (MacTeX, TeX Live, or MiKTeX)
- PDF conversion tools (poppler-utils or ImageMagick)
-
Clone or set up the project structure (already done!)
-
Run the setup script:
./setup.sh
-
Start the workshop:
./run_workshop.sh
-
Open your browser to http://127.0.0.1:3000
If you prefer to run the servers separately:
# Terminal 1: Backend
./start_backend.sh
# Terminal 2: Frontend
./start_frontend.shThe interactive slides cover these modules:
- Document Setup - Basic LaTeX structure
- Mathematical Equations - Inline and display math with siunitx
- Professional Tables - Data presentation with booktabs
- Figures and Graphics - Figure templates and referencing
- Analysis Section - Calculations and error analysis
- Final Assembly - Overleaf integration instructions
Each module includes:
- βοΈ Editable code examples
- πΌοΈ Live rendering preview
- π‘ Interactive demonstrations
- π Teaching notes and tips
POST /api/compile- Compile LaTeX snippetGET /api/readiness- Check LaTeX tools availabilityGET /api/health- Health check
GET /- Main slides interfaceGET /static/*- Static assets (CSS, JS, images)
Edit templates/index.html and add new <section> elements:
<section>
<h3>Your New Module</h3>
<div class="latex-editor">
<textarea id="editor-new">Your LaTeX code here</textarea>
</div>
<div class="latex-controls">
<button class="compile-btn" onclick="compileLatex('editor-new', 'output-new')">
Compile & Render
</button>
</div>
<div class="latex-output" id="output-new">
<span class="loading">Click "Compile & Render" to see the output</span>
</div>
</section>Edit the BASE_PREAMBLE in backend/app.py:
BASE_PREAMBLE = r"""
\\documentclass[11pt]{article}
\\usepackage[margin=1in]{geometry}
\\usepackage{amsmath,amsfonts,amssymb}
\\usepackage{siunitx}
\\usepackage{booktabs}
\\usepackage{graphicx}
\\usepackage[hidelinks]{hyperref}
\\usepackage{microtype}
% Add your custom packages here
"""Modify static/css/custom.css for visual customizations.
- Student enters LaTeX code in browser
- JavaScript sends code to Flask backend
- Backend creates temporary directory
- LaTeX document assembled with preamble
pdflatexcompilation (with optional bibliography)- PDF converted to PNG via pdftoppm or ImageMagick
- PNG returned as base64 to frontend
- Image displayed in browser
- Compilation errors: LaTeX log displayed to user
- Missing tools: System status indicators
- Network issues: Graceful fallback messages
- Timeout protection: 30-second limits on compilation
- LaTeX compilation runs in temporary directories
- File cleanup after each compilation
- Input sanitization for safety
- Local-only access by default
"Backend unavailable"
- Ensure backend server is running on port 5000
- Check firewall settings
"LaTeX compilation failed"
- Verify pdflatex installation:
pdflatex --version - Check LaTeX syntax in error log
"PDF conversion failed"
- Install poppler-utils:
brew install poppler(macOS) - Or install ImageMagick:
brew install imagemagick
"Permission denied"
- Make scripts executable:
chmod +x *.sh - Check write permissions in temp directory
Run the readiness endpoint to verify your setup:
curl http://127.0.0.1:5000/api/readinessLaTeX Workshop (Web-based)/
βββ backend/
β βββ app.py # Flask API server with render_snippet
βββ static/
β βββ css/
β β βββ custom.css # Custom styling
β βββ js/
β βββ latex-slides.js # Frontend JavaScript
βββ templates/
β βββ index.html # Main slides template
βββ temp/ # Temporary compilation files
βββ requirements.txt # Python dependencies
βββ server.py # Frontend Flask server
βββ setup.sh # Setup script
βββ start_backend.sh # Backend startup
βββ start_frontend.sh # Frontend startup
βββ run_workshop.sh # Combined startup
βββ README.md # This file
This workshop system is built around your existing render_snippet function and can be extended with:
- Additional LaTeX modules
- Enhanced error reporting
- Student progress tracking
- Template export features
- Integration with Overleaf API
Created for educational use in physics lab report template building workshops.
Happy teaching with interactive LaTeX! πβ¨