Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

[Feature Request] Native LaTeX (.tex) export support via Weave.jl integration

Open gruumsh1 opened this issue 1 month ago • 0 comments

Currently, Pluto allows exporting to HTML and PDF (via browser print), but there is no direct way to export to .tex source files.

This creates friction for academic and scientific workflows where users need the raw LaTeX source to:

Apply specific journal templates.

Fix typesetting issues manually.

Integrate the notebook content into larger LaTeX projects (e.g., Overleaf).

I have implemented a working prototype locally that adds a "LaTeX (.tex)" option to the export menu.

My current implementation works as follows:

Frontend: Added a button in ExportBanner.js that sends a write_latex request to the backend.

Preprocessing: The backend reads the notebook source and cleans it (stripping out the Pluto-specific TOML/Manifest data at the end of the file) to ensure clean conversion.

Conversion: It uses Weave.jl (specifically doctype="md2tex") to generate the LaTeX body.

Post-processing: I implemented a patching step to:

Inject \usepackage{pmboxdraw} to support terminal UI characters (like ╔, ═).

Define missing symbols (e.g., mapping \Rdsh to \hookrightarrow) to prevent compilation errors.

Download: The server sends the file content back to the frontend, which triggers a browser download via a Blob.

I considered using Pandoc directly via command line, but Weave.jl seems much more robust for the Julia ecosystem and handles code execution blocks natively.

I would love to submit a Pull Request for this feature.

Since Weave.jl is a heavy dependency, I assume we should not add it to the core Project.toml.

Would you accept a PR that implements this using Package Extensions (Weakdeps)?

The idea is that the "Export to LaTeX" button would only work (or only appear) if the user has Weave installed in their environment.

The backend logic currently lives in src/webserver/Dynamic.jl, but could be moved to ext/PlutoWeaveExt.jl.

I am looking forward to your feedback to align with the project's architecture before finalizing the code.

Image Image

gruumsh1 avatar Nov 19 '25 07:11 gruumsh1