rustex/lib.rs
1//! # RusTeX
2//!
3//! A library to make simple auto-generated LaTeX files in Rust.
4//!
5//! - [Quick Start](#quick-start)
6//! - [Implemented Features](#implemented-features)
7//! - [Example](#example)
8//!
9//! ## Quick start
10//!
11//! To use `RusTeX`, add the crate to your `Cargo.toml`.
12//!
13//! ```toml
14//! [dependencies]
15//! rustex = "0.1.0"
16//! ```
17//!
18//! ## Implemented Features
19//!
20//! ### _Components_
21//!
22//! - Package
23//! - Command
24//! - Chapter
25//! - Section
26//! - Enumerate
27//! - Table
28//! - Figure
29//! - Text
30//! - Label
31//! - PageBreak
32//!
33//! ### _Formatting_
34//!
35//! - Markdown **bold**
36//! - Markdown _italic_
37//! - Color text
38//!
39//! ## Example
40//!
41//! A full example with the resulting PDF file is accessible in the **_example_** folder of the repository.
42//!
43//! 1. Start by creating a base `Document`
44//!
45//! ```rust
46//! const DOCUMENT_NAME: &str = "generated_tex/main.tex";
47//! const DOCUMENT_CLASS: ClassType = ClassType::Report;
48//! const FONT_SIZE: &str = "12pt";
49//!
50//! let doc_file: File = File::create(DOCUMENT_NAME).unwrap();
51//!
52//! let doc_class: DocumentClass = DocumentClass::new(
53//! DOCUMENT_CLASS,
54//! vec![FONT_SIZE]
55//! );
56//!
57//! let mut doc: Document = Document::new(doc_file, doc_class);
58//! ```
59//!
60//! 2. Add some `Packages`
61//!
62//! ```rust
63//! let packages = vec![
64//! Package::new(
65//! "babel",
66//! vec!["english"]
67//! ),
68//! Package::new(
69//! "geometry",
70//! vec!["margin=2.5cm"]
71//! ),
72//! Package::new(
73//! "fontenc",
74//! vec!["T1"]
75//! )
76//! ];
77//!
78//! doc.add_packages(packages);
79//! ```
80//!
81//! 3. Add some global `Commands`
82//!
83//! ```rust
84//! let commands = vec![
85//! Command::new(r"\title{Title}"),
86//! Command::new(r"\author{Author}"),
87//! Command::new(r"\date{YYYY / MM / DD}"),
88//! Command::new(r"\setlength{\tabcolsep}{18pt}")
89//! ];
90//!
91//! doc.add_global_commands(commands);
92//! ```
93//!
94//! 4. Then you can add different `Items`
95//! - Any `Item` can be added to a `Document`
96//! - Any `Item` can be added to a `Container`
97//! - A `Container` is an `Item`, so they can be nested
98//! - `Items` are displayed by order that they have been added
99//!
100//! ```rust
101//! let mut section_1: Section = Section::new(
102//! "Section", // Section name
103//! SectionType::Section, // Section type
104//! true, // Display section number
105//! "sec_1" // Label
106//! );
107//!
108//! let paragraph_1 = Text::new(
109//! "Lorem ipsum dolor sit amet, **consectetur** adipiscing elit. Integer congue nisi condimentum
110//! lacus vulputate cursus. _Curabitur_ bibendum orci ac nibh vestibulum ultrices. Aenean pulvinar
111//! mattis lectus, sed vehicula leo pellentesque eget. Sed sed quam sit amet nulla lacinia mollis.
112//! Maecenas dignissim, augue quis suscipit pellentesque, ipsum turpis facilisis eros, eu aliquam
113//! erat massa sit amet ex."
114//! );
115//!
116//! section_1.add_item(paragraph_1);
117//! doc.add_item(section_1);
118//! ```
119
120mod components;
121#[doc(hidden)]
122mod utilities;
123
124pub use components::document::*;
125pub use components::item::*;
126pub use components::container::*;
127pub use components::table::*;