10 releases

0.2.8 Apr 19, 2022
0.2.7 Apr 18, 2022
0.2.3 Mar 24, 2022
0.2.1 Feb 16, 2022
0.1.0 Feb 11, 2022

#1858 in Text processing


Used in 4 crates (3 directly)

MIT license

35KB
839 lines

Tex-rs
Started Development: February 2022
License: MIT
From: Mustafif Khan | MKProjects
This crate is to be a library to generate LaTeX documents using a concept of attaching document elements. The example below shows how to utilize this library:

use tex_rs::*;
use std::path::Path;

fn main() {
    use std::path::PathBuf;
let mut latex = latex::Latex::new();
    latex.set_class(Class::Book);
    latex.set_metadata(Metadata::default());
    latex.add_package("dramatist".to_owned());

    let mut part_one = Part::new("Part 1");
    let section_one = Section::new("Section 1");

    let mut part_two = Part::new("Part 2");
    let mut chapter = Chapter::new("Chapter");
    let text = Text::new("text in part 2", TextType::Roman);

    part_one.attach(Element::from(section_one)).unwrap();
    chapter.attach(Element::from(text)).unwrap();
    part_two.attach(Element::from(chapter)).unwrap();

    let mut env = Environment::new("equation");
    env.attach_string("x^2 + y^2 = z^2".to_owned());

    part_two.attach(Element::from(env)).unwrap();

    let mut list = List::new(ListMode::Enumerate, &vec!["item 1".to_owned(), "item 2".to_owned(), "item 3".to_owned()]);

    part_two.attach(Element::from(list)).unwrap();

    latex.set_elements(elements![part_one, part_two]);

    latex.write(Path::new("simple.tex").to_path_buf()).unwrap()
}

Dependencies

~6–18MB
~215K SLoC