graphitepdf-math 0.2.0

Mathematical typesetting for GraphitePDF.
Documentation

Overview

graphitepdf-math converts LaTeX input into typed SVG scene data that can flow through the same downstream pipeline as ordinary SVG content.


Scope

graphitepdf-math contains:

  • MathOptions for inline/display, dimensions, color, and debug output
  • MathRender for the original source, raw SVG, and parsed SvgNode
  • render_math() and render_math_with_options()
  • MathDimension for numeric or unit-bearing width/height values

Installation

cargo add graphitepdf-math

API Summary

Category Items
Options MathOptions, MathDimension
Render result MathRender
SVG integration SvgNode, SvgNodeKind
Entry points render_math(), render_math_with_options()

Example

use graphitepdf_math::{MathOptions, render_math_with_options};

fn main() -> graphitepdf_math::Result<()> {
    let render = render_math_with_options(
        r"\\int_0^1 x^2 \\, dx",
        &MathOptions::new().inline(false).width("160").color("#1f2937"),
    )?;

    assert!(render.raw_svg.contains("<svg"));
    Ok(())
}

Design Principles

  • keep math rendering separate from PDF output concerns
  • reuse the SVG pipeline instead of inventing a parallel scene format
  • expose display and inline behavior explicitly
  • keep the public surface small and easy to integrate

Role In GraphitePDF

This crate feeds layout, render, and kit indirectly through typed SVG output. It is the workspace's math scene producer.


License

MIT