> I fear you may be over-committed to a certain way of thinking about > this: that is, you are convinced it is the job of a preview tool to > compensate for ill-formed LaTeX code. That is a really large demand.
If org-latex-preview provides a live-updating preview feature, it has to compensate for several edge cases like this one in Org's parser. Otherwise it is not at all useful. Another example is that the live-preview feature treats \[ ... \] as a latex-environment for display purposes, even though this is a latex-fragment and should be previewed inline according to Org's parser. > Maybe it is better to think about how to provide editing tools that > circumvent common mistakes (like removing \end{FOO}). No simple text editing action (like killing a line) in an Org buffer can be considered a mistake. It remains a valid Org document. Also, with enough use you can be sure that LaTeX environments in Org will be edited and broken in every way possible. For the LaTeX preview feature to be useful, it must be robust against arbitrary edits. > My suggestion would be to add an `org-insert/delete-latex-environment' > that could also delete matching pairs of environment delimiters. I don't think it's Org's responsibility to provide this. There are dozens of ways to do this in Emacs, and Org will do a poor job providing appropriate completions compared to AucTeX's C-c C-e. Karthik