simple/
simple.rs

1extern crate latex;
2
3use latex::{print, Document, DocumentClass, Element, Section};
4
5fn create_document() -> Document {
6    let mut doc = Document::new(DocumentClass::Article);
7
8    // Set some metadata for the document
9    doc.preamble.title("My Fancy Document");
10    doc.preamble.author("Michael-F-Bryan");
11
12    doc.push(Element::TitlePage)
13        .push(Element::ClearPage)
14        .push(Element::TableOfContents)
15        .push(Element::ClearPage);
16
17    let mut section_1 = Section::new("Section 1");
18    section_1
19        .push("Here is some text which will be put in paragraph 1.")
20        .push("And here is some more text for paragraph 2.");
21    doc.push(section_1);
22
23    let mut section_2 = Section::new("Section 2");
24    section_2.push("More text...");
25    doc.push(section_2);
26
27    doc
28}
29
30fn main() {
31    let doc = create_document();
32    let rendered = print(&doc).unwrap();
33    println!("{}", rendered);
34}