Crates.io | math_dsl_macro |
lib.rs | math_dsl_macro |
version | 0.1.0 |
source | src |
created_at | 2021-10-16 00:55:06.033001 |
updated_at | 2021-10-16 00:55:06.033001 |
description | Proc-macro that converts LaTeX-code to rust-code |
homepage | |
repository | https://gitlab.com/volkerweissmann/math_dsl_macro |
max_upload_size | |
id | 465700 |
size | 35,714 |
For example
# #[macro_use]
# extern crate math_dsl_macro;
# fn main() {
# let psi = 1f64;
tex_expr!(r"\frac\pi 3 (1-\cos^2\psi)^2");
# }
Gets expanded zu something close to
# let psi = 1f64;
std::f64::consts::PI / 3f64 * ( 1f64 - psi.cos().powi(2) ).powi(2);
Similarly,
# #[macro_use]
# extern crate math_dsl_macro;
# fn main() {
# let psi = 1f64;
tex_equation!(r"x=\frac\pi 3 (1-\cos^2\psi)^2");
# }
gets expanded to
# let psi = 1f64;
let x = std::f64::consts::PI / 3f64 * ( 1f64 - psi.cos().powi(2) ).powi(2);
If, for example, myinput.tex
contains
Other \LaTeX code
\begin{align*}
x=\frac\pi 3 (1-\cos^2\psi)^2
\end{align*}
Other \LaTeX code
\begin{align*}
a=b+c
\end{align*}
Other \LaTeX code
then
from_latex_file!("myinput.tex");
gets expanded to
# let psi = 1f64;
# let b = 1f64;
# let c = 1f64;
let x = std::f64::consts::PI / 3f64 * ( 1f64 - psi.cos().powi(2) ).powi(2);
let a = b + c;