DEV Community

Cover image for Why so much Latex?

Posted on


Why so much Latex?

I've recently got myself into yet another project, and again it's based upon producing Latex files. This project aptly named tex-rs is a Rust library that can be used to create Latex documents using Rust.

In all honesty, the answer to the post is simply I'm not that creative and I've been thinking of a back end to texcreate for quite a while now. So how does it work?

The idea of this library is attaching the elements, so relating to my last post on Latex Basics Part 2, the hierarchy of content is:

  • Part
  • Chapter
  • Section
  • Paragraph
  • Text

So the rule in this library is you can attach things to each other as long as they have less priority (Confusingly I have 0 as top priority), so how does this look like:

use std::path::Path;
use tex_rs::*;
fn main() {
    let mut latex = Latex::new();
    latex.set_metadata(Metadata::new("A title", "An author", "What day is it?"));

    let mut part = Part::new("Part 1");
    let mut chapter = Chapter::new("Chapter 1");
    let mut section = Section::new("Section 1");
    let mut text = Text::new("Some text", TextType::Underline);


Enter fullscreen mode Exit fullscreen mode

Note: 0.1.0 is a very early build and future builds will break this code, so I do recommend waiting until 0.2.0 has been released.

As you can see when you add part in latex.set_elements(), it brings everything that's inside it along as well.

I hope to do a lot more in this project like bringing elements and user-defined commands, so if you're interested in contributing contact me at or feel free to push pull requests to the repo

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git