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

Adding backslash to keywords outside of math mode #7

Closed
samrobbins85 opened this issue Dec 10, 2019 · 5 comments
Closed

Adding backslash to keywords outside of math mode #7

samrobbins85 opened this issue Dec 10, 2019 · 5 comments

Comments

@samrobbins85
Copy link

This program adds a backslash to keywords such as min and max, however, this only works inside of math mode as \min is not valid outside of it. To fix this problem, it should be detected if the keyword is in math mode, and if it is, then do the same as it currently does, but if the keyword is not in math mode, then the characters to put the keyword into math mode should be inserted

@nschloe
Copy link
Collaborator

nschloe commented Dec 11, 2019

For this to work, blacktex will have to be a LaTeX parser which is way to complex for a package like this. We can use heuristics though which work in most of the cases. The heuristic for keywords like min is to replace it by \min if it's not proceeded or succeeded by a letter as in, e.g., minimum. What's the exact context of your finding?

@samrobbins85
Copy link
Author

This is true, it's up to you of course. Just thought I would mention this behaviour as it can lead to LaTeX that has errors

@nschloe
Copy link
Collaborator

nschloe commented Dec 15, 2019

If you show me the snippet of code that produced the false positive, I can try and fix that case.

@samrobbins85
Copy link
Author

An example of this would be take the min of the two values, which is shorthand for minimum, but could be used outside of math mode in brief notes

@nschloe
Copy link
Collaborator

nschloe commented Dec 16, 2019

Yeah, this is a tough one. The regex is to add a backslash if min is not preceded or succeeded by a letter, such as in "minimum" or "jasmin". I'd vote for keeping it the way it is: If one uses abbreviations like that, you'll have to expect failures. They are so easy to fix though and this is better than skipping a \min too often.

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

No branches or pull requests

2 participants