Skip to content

JohnScience/nalgebra_latex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crates.io crates.io

nalgebra extension for LaTeX

The crate provides several robust formatters for nalgebra::Matrix as well as several LaTeX environments for customization.

On top of that, the crate offers feature-gated support for nalgebra_linsys and evcxr.

Example

use nalgebra_latex::{
	latex_writer::{Writer, LatexWriter, UnsafeWrite},
	latex_flavors::AmsLatex,
	latex_features::NoFeatures,
	latex_modes::{InnerParagraphMode, DisplayMathMode},
	latex_format,
};

let mut s = Writer::<AmsLatex,NoFeatures,InnerParagraphMode,String>::default();
latex_format!(
	#[on_format_error(unwrap)]
	s += "$$" ;
	|mut s: Writer::<AmsLatex,NoFeatures,DisplayMathMode,String>| {
		unsafe { s.write_str(r"\overrightarrow{x}" ) }?; 
		Ok(s)
	};
	// At the moment of writing string literals are being pushed inside of writers without validation o contents
	// However, it can change in the future
	" = (x_1,x_2)";
	"$$" ;
);
let (s,_no_features) = s.into_raw_parts();
assert_eq!(s, r"$$\overrightarrow{x} = (x_1,x_2)$$");

What is nalgebra?

nalgebra is a general-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices.

What is LaTeX?

LaTeX is a language for typesetting documents, especially scientific papers, and a document preparation system.

Example of .tex code

% ...
\subsection*{H}
	\glossaryentry{hadamard_product}{Hadamard product}
	\begin{adjustwidth}{1em}{}
		\textbf{Field of study}: \textit{Mathematics. Linear Algebra. Matrix theory.} \\
		\textbf{Distinct meanings in other fields of study}: \textit{unspecified.} \\
		\textbf{Definitions}:
		\begin{adjustwidth}{1em}{} \leavevmode
			\begin{framed}
				For two \hyperlink{matrix}{\textit{matrices}} $A$ and $B$ of the same \hyperlink{dimension_of_matrix}{\textit{dimension}} $m \times n$, the \beingdefined{Hadamard product} $A \circ B$ (or $A \odot B$) is a \hyperlink{matrix}{\textit{matrix}} of the same \hyperlink{dimension_of_matrix}{\textit{dimension}} as the operands, with elements given by
				\begin{equation*}
					(A \circ B)_{ij} = (A \odot B)_{ij} = (A)_{ij}(B)_{ij}.
				\end{equation*}
				
				Source: \cite{wiki_hadamard_product_matrices}.
			\end{framed}
			\begin{framed}
				Let $A$ and $B$ be $m \times n$ \hyperlink{matrix}{\textit{matrices}} with entries in $C$. The \beingdefined{Hadamard product} is defined by $[A \circ B]_{ij}=[A]_{ij}[B]_{ij}$ for all $1 \leq i \leq m$, $1 \leq j \leq n$. \\ \vspace{1em}
				
				Source: \cite{emillion}.
			\end{framed}
		\end{adjustwidth}
	\end{adjustwidth} \vspace{1em}
% ...

Output

tex output

Warning

The library is overhauled. It changes frequently and the documentation is not always available. Doc tests (examples in the documentation) generally show working code.

A lot of previous work was put into trash to make it work better. The last commit before the breaking changes is here.

Resources on LaTeX

Other useful links

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

nalgebra extension for LaTeX

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages