#latex #pdf #tex #generation

bin+lib rust-texas

Crate to generate latex documents

6 releases

new 0.3.0 May 10, 2024
0.2.8 Jan 25, 2024
0.2.7 Sep 20, 2023
0.2.6 Aug 30, 2023

#458 in Text processing

Download history 3/week @ 2024-01-22 12/week @ 2024-02-26 27/week @ 2024-03-04 15/week @ 2024-04-01 139/week @ 2024-05-06

139 downloads per month
Used in beary

MIT license

53KB
1.5K SLoC

TEXAS

This crate used to be Texas with a capital T. An issue was raised, and thus I have 'renamed' it the only way I know how. Apologies for any inconvenience. It is now rust-texas.

Purpose

This crate does not, in any way, even remotely cover the vast variety of things you can do with latex. Instead, it attempts to provide a friendly API for some of the most basic functions. Furthermore, it does not catch most latex errors.

It's also my first foray into the open-source world, so constructive criticism is welcome and appreciated. https://github.com/Abhay478/texas/issues

Basics

  • The primary type is Document, which you populate per your whims and fancies. This can be written to a file like so:
let mut q = File::create("file.tex")?;
let doc = document!("book");
write!(q, "{}", doc.to_string())?
  • The document can be filled with Components, Packages and Commands. They can be created using both functions and macros.
  • Component is an enum, with each variant containing a separate struct. If a component impls the Populate trait, you can fill it with more Components, then install it in the Document like so:
let mut p1 = part!("one");
p1.attach(chapter!("c1"))?
    .attach(chapter!("c2"))?; // and so on.

p1.attach_vec(vec![chapter!("c3"); 2])?;

doc.new_component(p1);
  • Commands can be created and installed like so:
doc.new_command(Command::new("brak", 1, r"\ensuremath{\left(#1\right)}"));
  • And commands can be called in-text like so:
let mut p1 = section!("one");
p1.attach(command!(doc, "brak", "hello there"))?;
  • Will add ability to generate stuff like ensuremath from code eventually.
  • Packages can be created and installed like so:
doc.new_package(package!("parskip", "parfill"));
  • Also has trait Opt, which allows for adding options to a command (like usepackage and documentclass, for now).

Log

  • 0.2.8

    • Fixed doctests
    • Modified builtins a little. You can now use all the little \phi \infty stuff. I will be improving the syntax for this in the future.
  • 0.3.0

    • Aight, this is a big one.
    • Added Beamer documentclass.
      • Yet to add themes.
    • Added more TextTypes.
    • Added with_components methods to various structs.
    • Some cleanup.

Dependencies

~430KB