texc_latex/templates/
basic.rs

1use crate::set;
2use tex_rs::Comment;
3use tex_rs::Latex;
4use tex_rs::*;
5
6
7/// Creates basic template into `tex_rs::Latex`
8/// ```
9/// use texc_latex::basic;
10///
11/// fn main(){
12///     let basic_latex = basic::basic(11, "letterpaper", "article", "author", "title", "Some day", &vec![]);
13///     // You can write with the following:
14///     // basic_latex.write(...)
15///     // basic_latex.async_write(...)
16///     // basic_latex.split_write(...), used in texcreate
17/// }
18///
19/// ```
20pub fn basic(fs: u8, ps: &str, dc: &str, author: &str, title: &str, date: &str, packages: &Vec<String>) -> Latex {
21    let mut latex = Latex::new();
22    set(&mut latex, fs, ps, dc, author, title, date);
23
24    // Write in order
25    let mut comments: Vec<Comment> = Vec::new();
26    comments.push(Comment::new_comment("Meta data goes here", Level::Meta));
27    latex.add_package("amsmath".to_string());
28    for i in packages{
29        latex.add_package(i.to_string());
30    }
31    comments.push(Comment::new_comment(
32        "Extra packages from config.toml goes under here",
33        Level::Package,
34    ));
35    let input = UserDefined::new("\\input{src/structure.tex}", Level::Meta);
36    comments.push(Comment::new_comment("Document code goes here", Level::Body));
37
38    latex.set_elements(elements![
39        comments[0].clone(),
40        comments[1].clone(),
41        input,
42        comments[2].clone()
43    ]);
44    latex
45}