Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latex Input support #27

Open
mayurankv opened this issue Feb 4, 2023 · 6 comments
Open

Latex Input support #27

mayurankv opened this issue Feb 4, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@mayurankv
Copy link

mayurankv commented Feb 4, 2023

Would it be possible to add latex support for the functions that mathjs supports? This would allow users who commonly type in latex to not use different syntaxes and be able to use other existing autocompletion tools!

EDIT: To clarify I meant without dropping of the . My title is a little bit misleading so apologies.

@gtg922r gtg922r added the enhancement New feature or request label Feb 5, 2023
@gtg922r
Copy link
Owner

gtg922r commented Feb 5, 2023

Can you give some example use cases to help me understand the request?

@mayurankv
Copy link
Author

So rather than using a=fraction(1/3)*(sin(1.5*pi))^2, I would want to use a=\frac{1}{3}*(\sin(1.5*\pi))^{2}.

Functions

I understand this isn't the most straightforward request. In many cases, simply ignoring the preceding backslash would make things work. I would only expect this to be implemented for extremely basic functions like fraction or those which work without the backslash in front. i.e. sin works so \sin should work but comb is not an accepted function so I would not expect \comb to work (combinatorics).
The only basic function I can think off that would need to be implemented differently is just fraction which goes from fraction(x/y) to \frac{x}{y}.
In addition treating {} bracket pairs as () pairs would presumably work just fine for things like powers.

Essentially for functions the following rules could apply:

  1. If the function is not in a specially handled list (i.e. fraction), then treat \func{x_1}{x_2},...,{x_n} as math.func(x_1,x_2,...,x_n). Similarly \single_arg_func(x) should be treated as math.single_arg_func(x).
    • If the function is not defined in math.js, then throw an undefined function error i.e. \nonsense{3} should be treated the same as nonsense(3).
  2. If the function is specially handled, then carry out that special handling i.e. special handling on frac: \frac{4}{5} -> frac(4,5) -> fraction(4/5) (This could hypothetically solved by changing the fraction syntax too).
  3. Exceptions would be non functionally applied things like powers so that should just treat {} as brackets.

Variables

This bit is hopefully quite a bit simpler, but allow for variables to be typed out using latex. This would be akin to allowing \vec{a} to be a variable name that is rendered in latex or a_{i,j} to be a variable name rendered properly. Currently using {} gives an Unexpected operator error. In reality any variable name is a placeholder that should not really affect the program up to parsing.

Totally understand if this isn't something you want to pursue but I really do think the small addition of variables would be a big boost and proper treatment of latex functions would make this invaluable! Please let me know if you have any thoughts.

@mayurankv
Copy link
Author

Just wondering if you've managed to have a think about this? (No worries if not!)

@mccann-kristian
Copy link

I use latex to take math notes in obsidian, compatibility would be nice

@usirg
Copy link

usirg commented May 9, 2024

Writing latex with e.g. Latex Suite is super efficient and can even be customized.

For example, one can write @b to get \beta etc.

If Numerals would be interoperable with latex, this would already take care of e.g. #69, at least partially.

Another nice improvement would be the ability to write latex in comments. For example, I'd like to write this:

# Let $h$ be the hypotenuse of right triangle $\triangle{ABC}$:
h=5cm
# Let $@a$ be one of its angles:
@a=30
# Then the opposite $o$ of $@a$ is:
o=h\sin{@a}

I understand that it may be difficult to enable this.

@usirg
Copy link

usirg commented May 9, 2024

To follow up on my post above, being able to write latex inside a math block will be less important with the features of global variables currently under development. Because then it's possible to interleave latex and numerals sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants