Path: blob/main/dev-docs/tinytex-pattern-maintenance.md
6442 views
Quarto LaTeX engine Pattern Maintenance
Quarto tracks tinytex R package's LaTeX error detection patterns to provide helpful diagnostics when LaTeX compilation fails. This document describes the automated verification process and manual adaptation workflow.
Overview
The R package tinytex maintains a comprehensive database of LaTeX error patterns in its parsing error logic, and export this in regex.json in its daily release. It can detect missing packages and fonts. We track these patterns because:
TinyTeX is the distribution maintain by Posit team actively maintains patterns based on user reports (@yihui and @cderv)
It is used by Quarto (
quarto install tinytex)Every problem will be fixed in the R package first
Low update frequency (~4 changes/year) makes manual adaptation practical
Our process:
Daily automated check detects when TinyTeX patterns change
GitHub issue created/updated when changes detected
Manual review and adaptation for Quarto's usage
Pattern Differences
tinytex R package and Quarto LaTeX engine use patterns differently:
R package: Matches patterns line-by-line against log array
Quarto: Matches patterns against entire log file as string
Common Adaptations
Direct copy (most common):
Anchored patterns need multiline flag or anchor removal:
Filter functions for post-processing:
Manual Adaptation Process
When the automated workflow detects TinyTeX pattern changes, it creates/updates a GitHub issue with:
Date of detection
Category-by-category count changes
Full diff of
regex.jsonchanges
Adaptation Steps
Review the diff:
Identify added, modified, or removed patterns
Update parse-error.ts:
Add new patterns to
packageMatchersarrayConvert TinyTeX string patterns to TypeScript regex with
/gflagAdd multiline flag
/gmif pattern uses^or$anchorsAdd filter function if pattern needs post-processing
Test changes
Commit and close issue
Verification Workflow
The automated workflow runs daily:
Downloads
regex.tar.gzfrom TinyTeX releasesExtracts and compares
regex.jsonwith cached versionIf changed: generates diff and creates/updates issue
If unchanged: exits early (no notification)
Workflow location: .github/workflows/verify-tinytex-patterns.yml
Manual trigger: Run workflow from GitHub Actions tab when testing or after TinyTeX release announcement
Current Coverage
Pattern implementation: 22 of 23 patterns from TinyTeX (96%)
Not implemented:
l3backendpattern for LaTeX3 version mismatch detectionReason: Complex context-aware logic required, rare error case
Test coverage: All documented TinyTeX error examples are tested
Important: Patterns should support both backtick (`) and single quote (') for LaTeX error messages
Resources
parse-error.ts - Pattern implementation
parse-error.test.ts - Unit tests
TinyTeX R source - How patterns are used in R
TinyTeX releases - Source of regex.json