Struct Align

Source
pub struct Align { /* private fields */ }
Expand description

A list of equations to be used in an align environment.

§Note

Using this environment requires you to include the amsmath package in your preamble.

§Examples

The typical workflow is to create an empty Align and then add equations to it.

use latex::{Align, Equation};
let mut equations = Align::new();
equations.push("y &= mx + c")
         .push(Equation::with_label("emc2", "E &= m c^2"));

When rendered, you should get something like this:

\begin{align}
y &= mx + c \\
E &= m c^2 \\
\end{align}

Implementations§

Source§

impl Align

Source

pub fn new() -> Align

Create an empty equation list.

Examples found in repository?
examples/complex.rs (line 33)
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<'_, Equation>

Iterate over each of this equations in the list.

Source

pub fn push<E: Into<Equation>>(&mut self, eq: E) -> &mut Self

Add an equation to the end of the list.

Examples found in repository?
examples/complex.rs (line 35)
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}

Trait Implementations§

Source§

impl Clone for Align

Source§

fn clone(&self) -> Align

Returns a copy 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 Align

Source§

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

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

impl Default for Align

Source§

fn default() -> Align

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

impl<'a> From<&'a str> for Align

Source§

fn from(other: &'a str) -> Align

Convert a string into a single equation wrapped in an align.

Source§

impl From<Align> for Element

Source§

fn from(other: Align) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Align

Source§

fn eq(&self, other: &Align) -> 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 Align

Auto Trait Implementations§

§

impl Freeze for Align

§

impl RefUnwindSafe for Align

§

impl Send for Align

§

impl Sync for Align

§

impl Unpin for Align

§

impl UnwindSafe for Align

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.