LaTeX.wasm: LaTeX Engines in Browsers

theanonymousone1 pts0 comments

SwiftLaTeX: WYSIWYG LaTeX Editor for Browsers

Fork me on GitHub

LaTeX.wasm: LaTeX Engines in Browsers

100% Browser

PdfTeX and XeTeX written in 100% WebAssembly and run in browsers.

Compatibility

Produce exact same output you would get from TexLive or MikTeX.

Library Support

Simply include a script tag and use PdfTeX or XeTeX in your own webpage.

WYSIWYG

Support WYSIWYG editing on LaTeX documents using XeTeX engine.

Speed

Run merely 2X slower than native binaries.

Open Source

Completely Open Source. You can find the code on GitHub.

Select a demo:

PdfTeX basic demo (IEEEConf)<br>XeTeX basic demo (acmart)<br>XeTeX Chinese/Japanese demo<br>XeTeX TrueType demo<br>XeTeX Tikz demo<br>XeTeX Beamer demo<br>PdfTeX Beamer demo<br>PdfTeX UTF8 demo<br>PdfTeX Tikz demo<br>PdfTeX CV demo

It may take a few minutes to download template files for the first time. Please be patient

Installation

Step 1: Download latest release from Github. Extract the files and put them into<br>your webpage directory.

Step 2: Include the src tag in your page.

Step 3: Initial the engine.<br>const engine = new LaTeXEngine();<br>await engine.loadEngine();

Step 4: Load the tex files/pictures/fonts to engines.<br>const engine = new LaTeXEngine();<br>engine.writeMemFSFile("main.tex", "\documentclass{...");

Step 5: Set the main file and fire the compilation.<br>engine.setEngineMainFile("main.tex");<br>let r = await engine.compileLaTeX(); // r contains PDF binray and compilation log.

APIs

async loadEngine(): PromiseLoad the webassembly engine.

isReady(): boolean.<br>Check whether the engine is ready to compile documents.

writeMemFSFile(filename: string, srccode: string | Uint8Array).<br>Upload source codes / assets to the engine.

makeMemFSFolder(folder: string).<br>Create a directory.

setEngineMainFile(filename: string).<br>Tell the engine which latex file is the entry file.

compileLaTeX():Promise.<br>Start compiling LaTeX documents and return CompileResult.

flushCache().<br>Purge all the files uploaded.

closeWorker().<br>Shutdown the engine.

engine demo latex xetex pdftex step

Related Articles