A web-based LaTeX editor and compiler that allows users to write, edit, and compile LaTeX documents in real-time with PDF preview. Built with Docker for easy deployment and includes support for image uploads, custom LaTeX datasets, and pre-loaded default assets.
This work is inspired by SwiftLaTeX, an innovative browser-based LaTeX editor. We've built upon the foundation of SwiftLaTeX and added several additional features to enhance the user experience:
- Enhanced Scroll Mode / Non Stop Mode: Improved PDF viewing with better scroll handling and navigation
- Enhanced Image Support: Better integration for .jpg image uploads and processing
- Default Asset Management: Automatic loading of common LaTeX packages, styles, and resources from ZIP archives
- Improved Console Output: More detailed compilation logs and error reporting
- Optimized Docker Deployment: Streamlined containerization for easier deployment and scaling
Live demonstration of LaTeX editing and compilation in the browser
- Real-time LaTeX editing with syntax highlighting
- Instant PDF compilation and preview
- Image support - Upload and include .jpg images in your LaTeX documents
- Dataset upload - Upload entire folders containing .tex and .jpg files
- Default Assets System - Automatically loads common LaTeX packages, styles, and resources
- Download compiled PDFs directly from the browser
- Responsive design with split-screen editor and PDF viewer
- Default template - Start coding immediately without file uploads
- Docker
- Docker Compose
- Git
git clone https://github.com/srikanth-mk/wasmtex-playground.git
cd wasmtex-playgrounddocker-compose up --buildThis will start two services:
- LaTeX Compiler Service on port
5002 - Static File Server on port
8002
Open your web browser and navigate to:
http://localhost:8002
wasmtex-playground/
├── texlive-ondemand/ # LaTeX compilation service
│ ├── Dockerfile
│ ├── wsgi.py
│ ├── requirements.txt
│ └── neopdftex.fmt # Pre-compiled LaTeX format
│ └── app.py
| └── app.cer
│ └── sign.bat
│ └── pykpathsea_pdftex.cpython-38-x86_64-linux-gnu.so # Pre-compiled module
│ └── pykpathsea_pdftex.c
│ └── kpathsea_pdftex_setup.py
├── docker-compose.yml
├── index.html # Main LaTeX editor interface
├── PdfTeXEngine.js # LaTeX compilation engine
├── neopdftex.wasm # Pre-compiled from wasm-builder
├── neopdftex.js # Pre-compiled from wasm-builder
├── default-assets.zip # Default LaTeX packages and resources (optional)
└── README.md
- Start typing LaTeX code in the left editor panel
- Click "Compile" to generate the PDF
- View the PDF in the right panel
- Download the compiled PDF using the "Download PDF" button
The editor comes with a default "Hello World" LaTeX template:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
Hello World!
\end{document}You can modify this template and compile it directly without uploading any files.
The application automatically loads common LaTeX resources from a default-assets.zip file when available:
- LaTeX packages (.sty files)
- Document classes (.cls files)
- Bibliography files (.bib files)
- Images and graphics (.jpg, .png, .pdf, .eps, .svg)
- Additional LaTeX templates (.tex files)
- Automatic Loading: When the page loads, the system automatically fetches and extracts
default-assets.zip - Status Indicator: The asset status shows loading progress and success/failure
- Memory Integration: All assets are loaded into the LaTeX compiler's memory filesystem
- Reload Option: Use "Reload Default Assets" button to refresh assets
-
Create a ZIP file named
default-assets.zipcontaining your common LaTeX resources:default-assets.zip ├── custom.sty # Custom style files ├── company-logo.png # Common images ├── references.bib # Bibliography files ├── template.tex # Template files └── fonts/ └── custom-font.ttf # Font files -
Place the ZIP file in the same directory as
index.html -
Access in LaTeX: All files are available by filename in your LaTeX documents:
\documentclass{article} \usepackage{custom} \includegraphics{company-logo.png} \bibliography{references} \begin{document} Your content here... \end{document}
- Loading...: Assets are being fetched and extracted
- ✓ Loaded X files from ZIP: Successfully loaded assets
- ✗ Failed to load ZIP: Error occurred (check console for details)
- Click "Choose Files" and select a folder containing:
.texfiles (LaTeX source).jpgfiles (images to include)
- The main .tex file will be automatically loaded into the editor
- All images will be available for inclusion in your LaTeX document
- Click "Compile" to generate the PDF
- Create Format: Click "Create Format" to optimize compilation speed
- Console Output: View compilation logs and error messages
- Real-time Editing: Make changes and recompile instantly
- Asset Management: Monitor and reload default assets as needed
- Port: 5002
- Purpose: Handles LaTeX compilation using TeXLive
- Features:
- Full TeXLive installation
- Python-based compilation service
- Pre-compiled format for faster processing
- Port: 8002
- Purpose: Serves the web interface and static files
- Features:
- Lightweight Python HTTP server
- Read-only volume mounting
- Auto-restart capability
- Serves default-assets.zip when available
- Clone the repository:
git clone https://github.com/srikanth-mk/wasmtex-playground.git
cd wasmtex-playground- Start the services:
docker-compose up --build- Make changes to the HTML/JavaScript files
- Refresh the browser to see changes (static files are served directly)
To create your own default assets package:
-
Create a folder with your LaTeX resources:
mkdir default-assets cd default-assets # Add your .sty, .cls, .bib, image files, etc.
-
Create the ZIP file:
zip -r ../default-assets.zip . -
Place in project root alongside
index.html -
Test the loading by opening the application and checking the asset status
If you need to modify the LaTeX compilation service:
- Edit files in the
texlive-ondemand/directory - Rebuild the container:
docker-compose up --build texlive-ondemandService not starting:
- Check if ports 5002 and 8002 are available
- Ensure Docker and Docker Compose are installed and running
Compilation errors:
- Check the console output for detailed error messages
- Ensure your LaTeX syntax is correct
- Verify that all referenced images are uploaded or available in default assets
PDF not displaying:
- Check browser console for JavaScript errors
- Ensure the LaTeX compilation was successful (status 0 or 1)
- Try refreshing the page
Default assets not loading:
- Ensure
default-assets.zipexists in the same directory asindex.html - Check the asset status indicator for error messages
- Verify the ZIP file is not corrupted
- Check browser console for detailed error logs
View service logs:
# All services
docker-compose logs
# Specific service
docker-compose logs texlive-ondemand
docker-compose logs static-server# Stop all services
docker-compose down
# Stop and remove volumes
docker-compose down -vYou can modify the ports in docker-compose.yml:
- Change
5002:5002to use a different port for the LaTeX service - Change
8002:8002to use a different port for the web interface
The Docker image includes texlive-full, which provides comprehensive LaTeX package support. Additional packages can be included via the default assets system or by modifying the Dockerfile in the texlive-ondemand/ directory.
The default assets system can be customized by:
- Modifying the ZIP file structure and contents
- Adding more file types to the loading logic
- Customizing the asset status display
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly (including default assets functionality)
- Submit a pull request
For issues and questions:
- Check the troubleshooting section above
- Review the console output for error messages
- Check the asset status indicator for loading issues
- Create an issue in the repository
wasmtex compiles PdfTeX engines into WebAssembly. We recommend the pdfTeX engine as it supports UTF-8 and Opentype fonts out of box. As a result, the locale linebreaking may not function as expected. This issue is easy to fix: we just need to initialize the ICU library with the correct dataset. If you just need to handle English, the PdfTeX is also a nice option. It is less compilcated, thus faster and less buggy.
- Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git
- Enter that directory
cd emsdk
- Fetch the latest version of the emsdk (not needed the first time you clone)
git pull
- Download and install the 3.1.46 SDK tools.
./emsdk install 3.1.46
- Make the latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate install 3.1.46
- Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh
- Compile PdfTeX
cd wasm-builder/pdftex.wasm
make
Happy LaTeX editing! 📝✨
