Closed npapapietro closed 3 years ago
Hi, that's a tricky question. When do you consider two expressions equal? Is "\overline{x}" the same as "\bar{x}"? is "a-b" the same as "$a-b$"? If you can narrow down the scope of the task you can use pylatexenc to parse the latex expression into logical nodes, and then do whatever comparison or standardization you'd like on the level of the nodes. For instance, in your example, you could declare ^
and _
as "latex specials" in pylatexenc (see here) and parse their argument suitably; then you can scan through your parsed nodes and standardize the order of any subscripts and superscripts.
To summarize, I think pylatexenc
can help you accomplish what you're after, by parsing the latex expression into logical nodes, but only once you've really specified more precisely what constitutes "two equal expressions". Good luck!
Thanks for the quick answer!
Question equality of two latex expressions. Perhaps this is naïve but if I have two expressions that display the same way, should there be a way to do this?