Developer-Mike / calctex

An Obsidian plugin for automatic calculation of LaTeX formulas.
GNU General Public License v3.0
7 stars 0 forks source link

No Rounding Option #12

Closed SpacePiggy17 closed 1 week ago

SpacePiggy17 commented 1 week ago

Hi, while I was using this great plugin for some physics, I noticed that it outputs like 100 decimal places for quite a few of the calculations I am doing. I found some defaults inside the main.js file but I couldn't figure out a way to change the rounding from there. @Developer-Mike is there a way I can modify the file to add the ability to round or some way you can update this plugin?

For example: \frac{3.82\sqrt{9.29}}{\sqrt{9.92}+\sqrt{2.63}}= 2.440'235'317'606'682'333'084'065'121'168'275'906'884'471'431'138'884'115'501'534'422'303'866'431'749'048'821'108'381'883'089'243'101

Is one of the outputs it suggests. This is correct, however I definitely don't need 200 sig figs. Thanks.

Developer-Mike commented 1 week ago

Thank you for opening an issue. This is currently not possible using the settings but it's planned (#11). If you want to modify the code yourself, here would probably be the location to add any settings using the CortexJS documentation.

Developer-Mike commented 1 week ago

Just found this sample in the documentation of CortexJS:

const ce = new ComputeEngine();
ce.latexOptions = {
  precision: 3, // <- This line here
  decimalMarker: "{,}",
};

This should be easy to implement in this plugin. After cloning this repository and modifying it in the editor.ts, you can generate a new main.js file by running npm run dev.

SpacePiggy17 commented 4 days ago

Thank you so much for your help! I did what you suggested but also found some options in DEFAULT_LATEX_NUMBER_OPTIONS that were useful. Those rounding and truncation options seemed to do more than the compute engine ones.