You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, aside from recognizing groups and environments, math is treated as a simple stream of tokens. As LaTeX is known for its excellent math equation generation, better parsing of math allows better formatting of math expressions, easing maintenance of documentation websites making heavy use of math notation.
Here is a rough idea on how to implement it, inspired in part by programming language parsers:
expr_unit "expression unit"
= num+
/ char
/ whitespace
/ !binary_macro macro
/ begin_group b_expr end_group
power "superscript and subscript"
= expr_unit
/ power "^" expr_unit
/ power "_" expr_unit
d_expr "delimited expression"
= power
/ left_delimiter b_expr? right_delimiter
m_expr "multiplication expression"
= power
/ m_expr power
u_expr "unary plus/minus expression"
= m_expr
/ [+-] u_expr
b_expr "binary expression"
= u_expr
/ b_expr binary_operator u_expr
A description in table form for the commons:
Operator
Description
Superscript and subscript
Normally ^ and _.
Logical delimitation
Parentheses, brackets, \{, \}, and \left-\right pairs. The delimiter on the left and right can be different.
"Multiplication"
Denoted by the lack of operators between two logical units. 2x is considered a "multiplication" expression, while 2 \times x is not.
Unary operators
+, -, \neg, etc.
Binary operators
+, -, =, \times, \le, etc.
The text was updated successfully, but these errors were encountered:
This sounds like a nice idea! Whatever the parser is, it will have to be very error tolerant. People often misuse latex symbols. For example using |x| for absolute value of x and a|b for a divides b, etc.
Currently, aside from recognizing groups and environments, math is treated as a simple stream of tokens. As LaTeX is known for its excellent math equation generation, better parsing of math allows better formatting of math expressions, easing maintenance of documentation websites making heavy use of math notation.
Here is a rough idea on how to implement it, inspired in part by programming language parsers:
A description in table form for the commons:
^
and_
.\{
,\}
, and\left
-\right
pairs. The delimiter on the left and right can be different.2x
is considered a "multiplication" expression, while2 \times x
is not.+
,-
,\neg
, etc.+
,-
,=
,\times
,\le
, etc.The text was updated successfully, but these errors were encountered: