A native macOS LaTeX editor crafted for academic writing.
myleaf is a native macOS LaTeX editor built with SwiftUI, offering out-of-the-box LaTeX compilation, syntax highlighting, PDF preview, and template management. No manual TeX distribution installation required — the app features automatic Tectonic engine installation.
- Syntax highlighting: Color-coded tokens for comments, commands, environments, math mode, and braces with dark/light mode support
- Native editing experience: NSTextView-based with undo/redo, auto-indent, monospaced font
- Smart paste: Automatically strips rich text formatting on paste, with instant syntax highlighting
- Live preview: PDFKit-powered rendering, displayed immediately after compilation
- Split-pane layout: Draggable divider between editor and PDF preview
- Multi-engine support: Tectonic (preferred) with automatic fallback to pdflatex
- Auto-detection: Detects available engines on launch with status indicator
- One-click install: In-app Tectonic download and installation from GitHub Releases
- Shortcut: Cmd+B to compile
- 19 built-in templates in three categories:
- Conference (8): AAAI, NeurIPS, CHI, SIGGRAPH, UbiComp, MobiSys, MobiCom, CCF Chinese
- Journal (3): SCI, EI, IEEE Transactions
- Thesis (8): Bilingual Chinese/English templates for Science, Engineering, Liberal Arts, and Fine Arts — both Bachelor's and Master's levels
- Quick template selection when creating new documents
- PDF export: Save the current PDF preview to a file
- Word export: Convert LaTeX to DOCX via Pandoc, with in-app Pandoc installation
- Import
.bibfiles with structured entry parsing - Search and batch-select citations
- Automatic
\cite{key}insertion before\end{document}
- Recent projects: Remembers the last 10 opened files
- Auto-save: Automatic save every 30 seconds (toggleable)
- Session restore: Reopens the last edited project on launch
- Release hardening: Hardened Runtime, symbol stripping, anti-debug protection (ptrace)
- Debug diagnostics: Memory leak detection via the
leaksCLI tool, deinit logging
- macOS 14.0 (Sonoma) or later
- Apple Silicon (ARM64) or Intel (x86_64)
Grab the latest .app bundle from the Releases page and drag it into your Applications folder.
First launch: The app will automatically detect available LaTeX engines. If none are found, you can install Tectonic with one click in Settings (~25MB download).
git clone https://github.com/65zlui/myleaf.git
cd myleaf
open myleaf.xcodeprojSelect the myleaf scheme in Xcode, press Cmd+R to run, or choose Product > Archive for a release build.
| Action | Shortcut |
|---|---|
| New Document | Cmd+N |
| New from Template | Cmd+Shift+N |
| Open File | Cmd+O |
| Save | Cmd+S |
| Save As | Cmd+Shift+S |
| Compile | Cmd+B |
| Export PDF | Cmd+E |
| Export Word | Cmd+Shift+E |
| Settings | Cmd+, |
- Create a document: Use the welcome screen to start blank or pick a template
- Edit LaTeX: Write your content in the editor with automatic syntax highlighting
- Compile & preview: Press Cmd+B to compile — the PDF renders instantly on the right
- Export: Use the Export menu in the toolbar for PDF or Word output
- Manage references: Click the BibTeX button to import
.bibfiles and insert citations
| Layer | Technology |
|---|---|
| UI Framework | SwiftUI + AppKit (NSViewRepresentable) |
| Architecture | MVVM + Service Layer |
| State Management | @Observable (iOS 17+) |
| PDF Rendering | PDFKit |
| Text Editor | NSTextView with regex syntax highlighting |
| LaTeX Engine | Tectonic / pdfLaTeX |
| Word Export | Pandoc (LaTeX to DOCX) |
| Process Management | Process with pipe communication |
| Persistence | UserDefaults (project history) |
| Debugging | leaks CLI memory analysis |
Compile-time: None (uses only Apple frameworks: Foundation, SwiftUI, PDFKit, AppKit)
Runtime:
- Tectonic (optional, auto-installable)
- pdfLaTeX (optional, requires system MacTeX installation)
- Pandoc (optional, auto-installable)
myleaf/
├── myleaf/ # Main application
│ ├── Models/ # Data models
│ ├── ViewModels/ # State management (EditorViewModel)
│ ├── Views/ # SwiftUI views
│ ├── Services/ # Business logic services
│ ├── Utils/ # Utility classes
│ └── Resources/Templates/ # 19 LaTeX templates
├── myleafTests/ # Unit tests
├── myleafUITests/ # UI tests
└── myleaf.xcodeproj # Xcode project
xcodebuild -scheme myleafTests -configuration Debug test43+ unit tests covering:
- Template loading and categorization
- BibTeX file parsing
- Project history management
- Document model validation
Zhang Rui — 65zlui
Making LaTeX writing simpler.