3 个版本
0.1.2 | 2021年3月31日 |
---|---|
0.1.1 | 2021年3月30日 |
0.1.0 | 2021年2月27日 |
#830 in 数学
230KB
2K SLoC
CalcuLaTeX
示例
'''
Given a rock with mass $m_{rock}$ thrown by a force of $F_0$ acting over a duration $dt_{force}$,
calculate its airtime and the max height it achieves.
'''
''' Given: '''
g = 9.81 m/s^2
m_{rock} = 10 kg
F_0 = 1000 N
dt_{force} = 0.1 s
''' Solution: '''
y_{vel} = F_0 / m_{rock} * dt_{force} = ?
airtime = y_{vel} / g * 2 = ?
height_{max} = y_{vel} * airtime / 4 = ? cm
输出结果
'''
CalcuLaTeX:
Write an expression followed by = ? to evaluate it:
'''
50 g + 1 kg = ?
'''
You can suggest a unit if it outputs the wrong one. \\
Make sure it's correct otherwise the document won't \\
compile!
'''
5 m/s^2 * 3 kg = ?
5 m/s^2 * 3 kg = ? N
'''
Assign variables with =
'''
x = 5
y = 10 kg
x * y = ?
z = x kg + y = ?
'''
Set the output digits or use scientific notation \\
by using !digits \{n\} or !scientific
'''
1 / 3 = ?
!digits 10
1 / 3 = ?
!digits 1
!scientific
1 kg = ? mg
'''
Basic mathematical trig functions are supported (with more to come).
Additionally, builtin constants include $\pi$ and $e$.
'''
sin(\pi) = ?
cos(\pi) = ?
e = ?
'''
Escape raw latex with three single quotes.
There's still plenty of bugs, so feel free to \\
open an issue at \\
https://github.com/mkhan45/CalcuLaTeX
'''
输出结果
CLI 使用方法
假设二进制文件名为 calculatex
,运行 calculatex [input] [output.pdf]
将监视 input
文件,并在更改时输出到 output.pdf
。这主要用于与实时更新的 PDF 查看器一起使用。
要运行 CalcuLaTeX CLI,您还需要 pandoc 和 texlive 安装。
编译
要构建 CalcuLaTeX,您需要一个夜间 Rust 编译器和 Cargo,最好通过 rustup。之后,就像这样
git clone [email protected]:mkhan45/CalcuLaTeX.git
cd CalcuLaTeX
# both of these output to target/release/
cargo build --release # builds the library only
cargo build --features build-binary --release # builds the CLI
贡献
如果您想贡献,请随意打开一个问题或给我发电子邮件。目前的代码库非常混乱,但它足够小,可以很容易理解。欢迎性能建议,但请不要引入任何额外的复杂性。我还没有进行基准测试,但 LaTeX 编译基本上肯定会比解释器慢一个数量级。
有关指南,请阅读 CONTRIBUTING.md
依赖项
~3–13MB
~151K SLoC