TexMex

Live LaTeX preview for VS Code, with real-time peer collaboration. No LaTeX installation required — TexMex downloads and manages its own compiler.
Features
- No setup: no TeX Live or MiKTeX to install — the compiler downloads itself on first use
- Live preview: renders as you type, with a one-click preview button on any
.tex file
- Peer collaboration: real-time multi-user editing over WebSockets
- PDF export: one click to save the compiled document
- Private: compiles entirely on your machine, nothing is sent anywhere
Requirements
- VS Code 1.85.0+, and an internet connection the first time you compile (~10-22MB one-time download). No Node.js or LaTeX distribution needed.
Installation
Quick Install (Recommended)
- Download the latest
.vsix file from Releases
- Open VS Code
- Press
Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (macOS)
- Click the
... menu → Install from VSIX...
- Select the
.vsix file
- Click Install
From VS Code Marketplace
- Open VS Code
- Press
Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (macOS)
- Search for "TexMex"
- Click Install
Usage
Basic Workflow
- Open a
.tex file
- Press
Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
- Type "TexMex: Open Live Preview" and press Enter
- The preview will open in a side panel
- First time only: TexMex downloads its bundled LaTeX engine (~10-22MB) and shows progress in a notification. This happens once and is cached for all future use.
- As you edit and save, the preview updates automatically. If a document uses a LaTeX package that hasn't been fetched yet, it's downloaded automatically on that compile and cached for next time.
Downloading PDF
- With the preview open, click the Download button in the toolbar
- Choose where to save the PDF file
- The PDF will be saved to your chosen location
Peer Collaboration
Starting a Collaborative Session
- Run command: TexMex: Create Peer Session
- A session ID will be generated and copied to your clipboard
- Share this session ID with your collaborators
Joining a Collaborative Session
- Get the session ID from your peer
- Run command: TexMex: Join Peer Session
- Enter the session ID
- You'll be connected and changes will sync in real-time
How It Works
- WebSocket Server: A local peer collaboration server runs automatically when the extension loads
- Real-time Sync: All changes are broadcast to connected peers instantly
- No Setup Required: Everything runs locally — no external services needed
- Auto Reconnect: Seamless reconnection if the connection drops
Configuration
You can customize TexMex through VS Code settings (.vscode/settings.json or global settings):
{
"texmex.updateDelay": 1000, // Delay before preview updates (ms)
"texmex.enablePeerWork": true, // Enable peer collaboration (WebSocket)
"texmex.peerServerPort": 3000, // Port for peer collaboration server
"texmex.useSystemLatex": false, // Advanced: use your own LaTeX install instead of the bundled engine
"texmex.systemLatexPath": "pdflatex" // Only used when useSystemLatex is true
}
Configuration Details
| Setting |
Type |
Default |
Description |
texmex.updateDelay |
number |
1000 |
Delay in milliseconds before updating preview after changes |
texmex.enablePeerWork |
boolean |
true |
Enable WebSocket peer collaboration features |
texmex.peerServerPort |
number |
3000 |
Port for the internal peer collaboration server |
texmex.useSystemLatex |
boolean |
false |
Advanced: compile with a LaTeX distribution already installed on your system instead of TexMex's bundled engine |
texmex.systemLatexPath |
string |
pdflatex |
Path to your system LaTeX compiler (e.g. xelatex, lualatex). Only used when texmex.useSystemLatex is true |
Development
Building from Source
Clone the repository:
git clone https://github.com/rahul-challa/TexMex.git
cd TexMex
Install dependencies:
npm install
Compile the extension:
npm run compile
Package the extension:
npm run install-vsce # Install vsce globally if needed
npm run package # Creates texmex-X.X.X.vsix
Install the local build:
- Open VS Code
- Press
Ctrl+Shift+X
- Click
... menu → Install from VSIX...
- Select the generated
.vsix file
See PUBLISHING.md for how to cut and publish a release.
Available Scripts
| Script |
Description |
npm run compile |
Type-check and bundle the extension with esbuild |
npm run watch |
Watch for file changes and rebuild |
npm run lint |
Run ESLint code quality checks |
npm run test |
Run test suite |
npm run clean |
Clean build artifacts |
npm run package |
Package as .vsix for installation |
npm run install-vsce |
Install VS Code packaging tool globally |
Architecture
Core Components
- Extension (
extension.ts): Main VS Code extension entry point
- Engine Manager (
engineManager.ts): Resolves, downloads, verifies, and caches the bundled Tectonic LaTeX engine per platform
- LaTeX Compiler (
latexCompiler.ts): Runs the bundled engine (or an opted-in system LaTeX install) and reports results
- Peer Server (
peerServer.ts): WebSocket server for real-time collaboration
- PDF Viewer (
pdfViewer.ts): Embedded PDF renderer (no external CDN dependencies)
Bundled LaTeX Engine
TexMex ships without a LaTeX distribution to keep the .vsix small, and instead downloads Tectonic — a self-contained, single-binary LaTeX engine — the first time you compile:
- The correct binary for your OS/architecture (Windows, macOS Intel/Apple Silicon, Linux x64/arm64) is downloaded from Tectonic's GitHub releases and verified against a pinned SHA256 checksum
- It's cached in VS Code's global storage, so it's downloaded once, not per-workspace or per-update
- Tectonic itself fetches only the individual LaTeX packages a document actually needs (not a full distribution), caching them the same way — so unusual packages "just work" the first time they're used
- Everything runs locally; your document content never leaves your machine
- Prefer your own TeX Live/MiKTeX install? Set
texmex.useSystemLatex to true
No External npm Dependencies at Runtime
- WebSocket support (bundled
ws library)
- PDF rendering (embedded viewer)
- Engine download uses Node's built-in
https/crypto; archive extraction uses the OS's native tar/Expand-Archive — no extra packages needed
- Works fully offline once the engine and any packages your documents need are cached
Troubleshooting
Preview Not Showing / Engine Download Fails
- Make sure you have an internet connection for the one-time engine download (subsequent compiles work offline)
- Check the "TexMex" output channel (TexMex: Show Compiler Log) for the underlying error
- If a download was interrupted or the binary seems corrupted, run TexMex: Reinstall LaTeX Engine
Peer Collaboration Not Working
- Ensure
texmex.enablePeerWork is true in settings
- Check that the peer server port (default 3000) is not blocked by firewall
- Verify both users are running extension version 0.0.6 or higher
- Session IDs must match exactly
LaTeX Compilation Errors
- Open TexMex: Show Compiler Log to see the full engine output
- Check your
.tex file for syntax errors (undefined commands, mismatched \begin/\end, etc.)
- If you enabled
texmex.useSystemLatex, make sure texmex.systemLatexPath points at a working compiler and that the packages your document needs are installed in your distribution
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
Links
Version History
See CHANGELOG.md for full release notes.
v0.0.9 (Current)
- Fixed the preview panel rendering blank by replacing the old iframe-based viewer with a bundled pdf.js
- Redesigned the preview toolbar (grouped icon buttons, browser-style zoom, page-jump box) and added a settings shortcut
- Added a one-click preview button on the editor title bar for any
.tex file
v0.0.8
- Bundled Tectonic LaTeX engine — no local LaTeX distribution required, downloaded and cached automatically on first use
- Removed the online compilation fallback (
pdflatex.online) that sent document content to a third party
- Added a "TexMex" output channel with full compiler logs, plus Reinstall LaTeX Engine and Show Compiler Log commands
- Added
texmex.useSystemLatex / texmex.systemLatexPath as an advanced opt-out for users with their own LaTeX install