Section

Struct Section 

Source
pub struct Section {
    pub name: String,
    /* private fields */
}
Expand description

A document Section.

Like the Document type, a Section is more or less just a collection of Elements. When rendered it will start with \section{Section Name} and then each element will be rendered in turn.

Fields§

§name: String

The name of the section.

Implementations§

Source§

impl Section

Source

pub fn new(name: &str) -> Section

Create a new section with the specified name.

Examples found in repository?
examples/template.rs (line 17)
14fn create_part_document() -> Document {
15    let mut doc = Document::new(DocumentClass::Part);
16
17    let mut section = Section::new("Section 1");
18    section.push("Some text which gets included into the main document.");
19    doc.push(section);
20    doc
21}
More examples
Hide additional examples
examples/simple.rs (line 17)
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}
examples/complex.rs (line 30)
29fn 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}
Source

pub fn push<I>(&mut self, element: I) -> &mut Self
where I: Into<Element>,

Add an element to the Section.

Examples found in repository?
examples/template.rs (line 18)
14fn create_part_document() -> Document {
15    let mut doc = Document::new(DocumentClass::Part);
16
17    let mut section = Section::new("Section 1");
18    section.push("Some text which gets included into the main document.");
19    doc.push(section);
20    doc
21}
More examples
Hide additional examples
examples/simple.rs (line 19)
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}
examples/complex.rs (line 31)
29fn 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}
Source

pub fn iter(&self) -> Iter<'_, Element>

Iterate over the elements in this list.

Source

pub fn is_empty(&self) -> bool

Is this section empty?

Trait Implementations§

Source§

impl Clone for Section

Source§

fn clone(&self) -> Section

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Section

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Section

Source§

fn default() -> Section

Returns the “default value” for a type. Read more
Source§

impl From<Section> for Element

Source§

fn from(other: Section) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Section

Source§

fn eq(&self, other: &Section) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Section

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.