Bidirectional, AST-based LaTeX ↔ Typst Converter
Tylax is a high-performance tool written in Rust that converts mathematical formulas, tables, full documents, and TikZ graphics between LaTeX and Typst formats. It focuses on static analysis to preserve the document structure for manual editing and adjustment.
Features
- Macro Engine:
- LaTeX: Full expansion support for
\newcommand,\def,\ifmmode, and complex nested macros. - Typst: Integrated Typst Evaluator handles
#let,#forloops, and conditionals before conversion.
- LaTeX: Full expansion support for
- Bidirectional: LaTeX ↔ Typst (Math, Text, Tables, Graphics)
- High Performance: Written in Rust, compilable to WASM for web usage.
- Complex Tables: Support for
multicolumn,multirow, andbooktabs. - Graphics: Experimental TikZ ↔ CeTZ conversion.
- Full Document: Handles chapters, sections, lists, and bibliographies.
Note: While Tylax covers most common LaTeX and Typst features, there are still uncovered edge cases. If you encounter any conversion issues, please open an issue with a minimal example. Your feedback helps improve the tool! Thank you!
🔗 Try Online Demo
Installation
From crates.io
From Source
Usage
Command Line Interface
# Basic conversion (auto-detect format)
# Convert math formula from stdin
|
# Convert TikZ to CeTZ
Rust Library
Add to Cargo.toml:
[]
= "0.3.0"
use ;
WebAssembly
Tylax can be compiled to WASM for browser usage. See the Online Demo for a live example. The online demo does not collect any user data.
# Build for web
Design Philosophy
To build a handy tool specifically for LaTeX and Typst conversion scenarios.
- Goal: Preserve the original source structure to make the output human-readable and easy to manually edit and adjust.
- Roadmap: We are committed to maintaining this project, slowly but surely improving it. While currently static, we plan to explore adding limited dynamic evaluation in future versions.
Architecture
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#4a90d9', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2d6cb5', 'lineColor': '#5c6bc0', 'secondaryColor': '#81c784', 'tertiaryColor': '#fff3e0'}}}%%
flowchart LR
subgraph INPUT ["📄 Input"]
direction TB
LaTeX["LaTeX\n.tex"]
Typst["Typst\n.typ"]
end
subgraph CORE ["⚙️ Core Engine"]
direction TB
subgraph L2T ["LaTeX → Typst"]
direction LR
LE[["⚙️ Macro\nEngine"]]
MP[["🔍 MiTeX\nParser"]]
LA[("AST")]
LC{{"Converter"}}
LE --> MP --> LA --> LC
end
subgraph T2L ["Typst → LaTeX"]
direction LR
subgraph MINIEVAL ["⚙️ MiniEval"]
direction TB
TP1[["Parse"]]
EXEC[["Expand"]]
TP1 --> EXEC
end
TP2[["🔍 typst-syntax\nParser"]]
TA[("AST")]
TC{{"Converter"}}
MINIEVAL --> TP2 --> TA --> TC
end
subgraph FEATURES ["📦 Features"]
direction TB
F1["Tables\n(Coverage Tracking)"]
F2["TikZ/CeTZ\n(Coord Parser)"]
F4["References"]
end
end
subgraph OUTPUT ["📄 Output"]
direction TB
TypstOut["Typst\n.typ"]
LaTeXOut["LaTeX\n.tex"]
end
LaTeX --> LE
LC --> TypstOut
Typst --> MINIEVAL
TC --> LaTeXOut
LC -.- FEATURES
TC -.- FEATURES
style INPUT fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style CORE fill:#fff8e1,stroke:#ff8f00,stroke-width:2px
style OUTPUT fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
style L2T fill:#e1f5fe,stroke:#0288d1
style T2L fill:#fce4ec,stroke:#c2185b
style FEATURES fill:#f3e5f5,stroke:#7b1fa2
style MINIEVAL fill:#ffebee,stroke:#c62828
style MP fill:#bbdefb,stroke:#1976d2
style TP1 fill:#f8bbd0,stroke:#c2185b
style TP2 fill:#f8bbd0,stroke:#c2185b
style LA fill:#fff9c4,stroke:#fbc02d
style TA fill:#fff9c4,stroke:#fbc02d
style LC fill:#c8e6c9,stroke:#388e3c
style TC fill:#c8e6c9,stroke:#388e3c
Community
Join the conversation!
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow Rust coding conventions
- Add tests for new features
- Update documentation as needed
- Run
cargo fmtandcargo clippybefore committing
License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
Acknowledgments
This project builds upon the following excellent projects: