Table

Struct Table 

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

An object that can contain different TableComponents in rows and columns. Refer to table in LaTeX documentation for more information.

Example:

let mut table_1: Table = Table::new(
    "H",                                // Positioning
    "|c|c|c|",                          // Options
    true,                               // Centered
    Some(Text::new("Random caption")),  // Caption
    "tab_1"                             // Label
);

table_1.add_component(HorizontalLine::new());
let table_row_1 = TableRow::new(vec![Text::new(r"\multicolumn{3}{|c|}{**Lorem Ipsum**}")]);

table_1.add_component(table_row_1);
table_1.add_component(HorizontalLine::new());

let table_row_2 = TableRow::new(vec![
    Text::new("#red{First}"),
    Text::new("#violet{Second}"),
    Text::new("#teal{Third}")]
);

table_1.add_component(table_row_2);
table_1.add_component(HorizontalLine::new());

let table_row_3 = TableRow::new(vec![
    Text::new("Test 1"),
    Text::new("Test 2"),
    Text::new("Test 3")]
);
table_1.add_component(table_row_3);
table_1.add_component(HorizontalLine::new());

Generated LaTeX:

\begin{table}[H] \label{tab_1}
    \centering
    \begin{tabular}{|c|c|c|}
        \hline
        \multicolumn{3}{|c|}{\textbf{Lorem Ipsum}} \\
        \hline
        {\color{red}{First}} & {\color{violet}{Second}} & {\color{teal}{Third}} \\
        \hline
        Test 1 & Test 2 & Test 3 \\
        \hline
    \end{tabular}
    \caption{Random caption}
\end{table}

Implementations§

Source§

impl Table

Source

pub fn new( _positioning: &str, _options: &str, _centered: bool, _caption: Option<Text>, _label: &str, ) -> Self

Initializes a new Table object

Source

pub fn add_component<TC: TableComponent + 'static>(&mut self, component: TC)

Add a TableComponent to the Table

Trait Implementations§

Source§

impl Container for Table

Source§

impl Item for Table

Source§

fn build(&self, doc: &Document) -> Result<(), Error>

Source§

fn update_indent(&mut self, super_indent: &usize)

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl !Send for Table

§

impl !Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

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> 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, 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.