# Crate tectonic

Expand description

Tectonic is a complete TeX/LaTeX engine converted into a standalone library. It is derived from the XeTeX variant of TeX and uses the support files packages by the TeX Live project. Tectonic would not be possible without the hard work that has gone into these projects.

Because Tectonic is based on the XeTeX engine, it can take advantage of the features of modern fonts (TrueType, OpenType, etc.), outputs directly to the PDF file format, and supports Unicode inputs. Most importantly, the TeX experience delivered by Tectonic is completely embeddable: if you link with this crate you can fully process TeX documents, from source to PDF, without relying on any externally installed software, configuration, or resource files. This is possible because Tectonic bundles the traditional TeX tools and routes their I/O through a pluggable backend system.

This crate delivers command-line frontend, tectonic, that has a modernized user experience that hides TeX’s copious output (by default) and never asks for user input. Virtually all of the functionality of the frontend is accessible programmatically through the driver module of this crate.

This crate joins a set of sub-crates that combine to provide the Tectonic user experience. Those crates generally have APIs that are more carefully structured and better documented than this crate, which grew somewhat organically. The foundational crates are:

Building on these and other support crates of less general interest are the following major pieces of Tectonic’s functionality:

The main module of this crate provides an all-in-wonder function for compiling LaTeX code to a PDF:

use tectonic;

let latex = r#"
\documentclass{article}
\begin{document}
Hello, world!
\end{document}
"#;

let pdf_data: Vec<u8> = tectonic::latex_to_pdf(latex).expect("processing failed");
println!("Output PDF size is {} bytes", pdf_data.len());

The driver module provides a high-level interface for driving the engines in more realistic circumstances.

## Re-exports

pub use crate::engines::bibtex::BibtexEngine;
pub use crate::errors::Error;
pub use crate::errors::ErrorKind;
pub use crate::errors::Result;

## Modules

User configuration settings for the Tectonic engine.

Compatibility re-exports of tectonic_io_base::digest types.

Connecting the Tectonic document model to the engines.

The high-level Tectonic document processing interface.

Tectonic error types and support code.

Extensions to Tectonic’s pluggable I/O backend.

Compatibility reexports of tectonic_status_base types

Unstable options for the Tectonic engine.

## Macros

“Chained try” — like try!, but with the ability to add context to the error message.

Use string formatting to create an Error of kind errors::ErrorKind::Msg.

Report a formatted error message to the user.

Show formatted text to the user, styled as an error message.

Report a formatted informational message to the user.

Report a formatted warning message to the user.

## Structs

An engine that converts SPX to HTML.

A struct for invoking the (Xe)TeX engine.

A struct for invoking the xdvipdfmx engine.

## Enums

A possible outcome from a (Xe)TeX engine invocation.

## Constants

A serial number describing the detailed binary layout of the TeX “format files” used by this crate. This number will occasionally increment, indicating that the format file structure has changed. There is no provision for partial forwards or backwards compatibility: if the number changes, you need to regenerate your format files. If you’re generating format files, you should munge this serial number in the filename, or something along those lines, to make sure that when the engine is updated you don’t attempt to reuse old files.

## Functions

Compile LaTeX text to a PDF.