LaTeX: Correct Math Scope Context Matching #138
sleepymalc
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Before, I used the following context-matching code for detecting math scope for$\LaTeX$ :
However, this leads to some problems. For example, sometimes, in the equation, I want to write
Such a case is fine since the math I want to write in the text scope is simple, just
\(n\)
. However, in the current (and perhaps most popular) scope function, it happens that\(\text{ \( not in the math mode \) }\)
.To overcome this, I write the following more generic version:
So, since the nested environment is ordered in the scope, this will always return the correct mode. Even better, there will be no undefined behavior since if the
.findLastIndex
can't find either, it will return-1
instead of something undefined, so everything is handled.Beta Was this translation helpful? Give feedback.
All reactions