Skip to main content

Crate rtex

Crate rtex 

Source
Expand description

§rtex — Native TeX to multi-format converter

A self-contained Rust library for converting LaTeX documents to PDF, HTML, DOCX, or EPUB without an external TeX installation.

§Quick example

use rtex::{convert_tex_to_pdf, convert_tex_string, OutputFormat};
use std::path::Path;

// File → PDF
convert_tex_to_pdf(Path::new("doc.tex"), Path::new("doc.pdf")).unwrap();

// String → HTML
let html = convert_tex_string("\\documentclass{article}\\begin{document}Hi\\end{document}", OutputFormat::Html).unwrap();

§Modules

§Feature flags

  • wasm — enables wasm-bindgen exports for browser use
  • lsp — builds the rtex-lsp language server binary

Re-exports§

pub use error::LatexError;
pub use error::Position;
pub use lsp::CompletionKind;
pub use lsp::Severity;
pub use lsp::SymbolKind;
pub use lsp::TexCompletion;
pub use lsp::TexDiagnostic;
pub use lsp::TexPosition;
pub use lsp::TexRange;
pub use lsp::TexSymbol;
pub use lsp::analyze_diagnostics;
pub use lsp::command_completions;
pub use lsp::completions_at;
pub use lsp::document_symbols;
pub use lsp::hover_at;

Modules§

error
Structured error types for latex-rs.
lsp
Language Server Protocol support for .tex editors.

Structs§

CacheConfig
Cache configuration.
CacheStats
Statistics for cache performance monitoring.
ConsoleReporter
Simple console reporter that prints stage names to stderr.
ConversionOptions
Options controlling conversion format and package fetching.
DocumentCache
Live cache for parsed documents and rendered output.
DocumentMeta
Document metadata extracted from parsed elements.
IncrementalCompiler
Tracks build state for incremental compilation.
IntermediateMeta
Metadata summary written alongside intermediate artifacts.
MathFormatter
NativeTexConverter
Pure-Rust TeX-to-PDF converter.
NoOpReporter
No-op reporter — useful when progress is not required.
PackageFetcher
Local cache and download settings.
PackageRequest
A LaTeX package or class file required by a document.
StreamingConverter
Converts a LaTeX file to the configured output format with progress reporting and memory-conscious chunked reading.
TexParser
Stateful parser for a single LaTeX document.

Enums§

OutputFormat
Supported output formats for LaTeX conversion.
PdfBackend
Identifies the pdfrs PDF engine as the only PDF backend.
TexElement
A structured element parsed from a LaTeX document.

Traits§

ProgressReporter
Callback trait for reporting conversion progress.
TexConverter
Trait for converting a LaTeX file to PDF.

Functions§

convert_tex_file
Convert a .tex file to an output file using the given options.
convert_tex_string
Convert TeX source to bytes in the requested format.
convert_tex_string_to_pdf_bytes
Convert a TeX source string directly to PDF bytes (no filesystem access).
convert_tex_to_pdf
One-shot helper: convert a .tex file to a .pdf.
expand_document
Expand user-defined macros in text without structured parsing.
render_elements
Render parsed elements to bytes in the requested format.
render_elements_in_dir
Like render_elements with an optional base directory for relative images (PDF).
sibling_artifact
Return the path for a sibling artifact next to output.
watch_batch
Watch a set of input files and recompile when any change.
watch_single
Convenience: watch a single input/output pair, including \input dependencies. When the root file or any dependency changes, the root document is rebuilt.
write_intermediates
Write intermediate artifacts next to output.