1extern crate latex;
2
3use latex::{print, Align, Document, DocumentClass, Element, Equation, List, ListKind, Section};
4
5fn create_document() -> Document {
8 let mut doc = Document::new(DocumentClass::Article);
9
10 doc.preamble
13 .title("Hello World")
14 .author("Michael-F-Bryan")
15 .use_package("amsmath")
16 .use_package("parskip");
17
18 doc.push(Element::TitlePage)
19 .push(Element::ClearPage)
20 .push(Element::TableOfContents)
21 .push(Element::ClearPage)
22 .push(first_section());
23
24 doc
25}
26
27fn first_section() -> Section {
30 let mut section_1 = Section::new("Introduction");
31 section_1.push("This is an example paragraph.");
32
33 let mut equations = Align::new();
34 equations
35 .push("y &= mx + c")
36 .push(Equation::with_label("quadratic", "y &= a x^2 + bx + c"));
37
38 section_1
39 .push("Please refer to the equations below:")
40 .push(equations);
41
42 let mut objectives = List::new(ListKind::Enumerate);
43 objectives
44 .push(r"Demonstrate how to use the \textit{latex} library.")
45 .push("Create a reasonably complex document")
46 .push("???")
47 .push("PROFIT!");
48
49 section_1.push("Here are our objectives:").push(objectives);
50
51 section_1
52}
53
54pub fn main() {
55 let doc = create_document();
56 let rendered = print(&doc).unwrap();
57 println!("{}", rendered);
60}