gillescastel / latex-snippets

Vim + LaTeX snippets setup
MIT License
1.03k stars 201 forks source link

Add tab triggered calculation #25

Open YuruiHong opened 1 year ago

YuruiHong commented 1 year ago

I really appreciate the idea of inline calculation as provided by sympy and mma, and I've noticed a package named "latex2sympy2", which converts LaTeX expressions directly into sympy and makes it possible to calculate right after typing an expression!

Examples:

% before
$x=\int_0^1 \mathrm{d}x = $ % add a '=' at the end before tab for numeric calculation
                            % otherwise for simplification
% after
$x=\int_0^1 \mathrm{d}x = 0.5$

% before
\begin{align*}    
    x &= 123 * 456 % tab here
.\end{align*}

% after
\begin{align*}
    x &= 123 * 456
      &= 56088
.\end{align*}

% before
\begin{align*}    
    x &= \frac{y^2}{y} % tab here
.\end{align*}

% after
\begin{align*}    
    x &= \frac{y^2}{y}
      &= y
.\end{align*}