"Fraga, Eric" <e.fr...@ucl.ac.uk> writes: > The identification of LaTeX fragments is somewhat fragile (in my > experience). I would suggest you enclose complex LaTeX code fragments > within an #+begin_export latex ... #+end_export environment. > > Assuming your export target is LaTeX and/or PDF.
Changing the beginning and end regexes to the following seems to work well (I've just added a non-capturing group for \(\) or $$ so that begin-end blocks can be nested inside inline math environments). (setq org-element--latex-begin-environment "^[ \t]*\\(?:\\\\(\\|\\$\\)?\\\\begin{\\([A-Za-z0-9*]+\\)}") (setq org-element--latex-end-environment "\\\\end{%s}[ \t]*\\(?:\\\\)\\|\\$\\)?$") I'm going to test this a bit before submitting it as a patch to make sure it doesn't cause any issues. If you have any tricky fragments you want to test it on please let me how it works!