Is there a calculator with LaTeX-syntax?

前端 未结 17 2035
北海茫月
北海茫月 2020-12-12 17:00

When I write math in LaTeX I often need to perform simple arithmetic on numbers in my LaTeX source, like 515.1544 + 454 = ???.

I usually copy-paste the

17条回答
  •  再見小時候
    2020-12-12 17:44

    There is a way to do what you want just not quite how you describe.

    You can use the fp package (\usepackage[options]{fp}) the floating point package will do anything you want; solving equations, adding dividing and many more. Unfortunately it will not read the LaTeX math you instead have to do something a little different, the documentation is very poor so I'll give an example here.

    for instance if you want to do (2x3)/5 you would type:

    \FPmul\p{2}{3}           % \p is the assignment of the operation 2x3
    \FPupn\p{\p{} 7 round}   % upn evaluates the assignment \p and rounds to 7dp
    \FPdiv\q{\p}{5}          % divides the assigned value p by 5 names result q
    \FPupn\q{\q{} 4 round}   % rounds the result to 4 decimal places and evaluates
    $\frac{2\times3}{5}=\FPprint\q$  % This will print the result of the calculations in the math.
    

    the FP commands are always ibvisible, only FPprint prints the result associated with it so your documents will not be messy, FP commands can be placed wherever you wish (not verb) as long as they are before the associated FPprint.

提交回复
热议问题