From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Huszagh Subject: Re: Issues with nested begin..end blocks in inline math environments Date: Sat, 07 Dec 2019 23:04:32 -0800 Message-ID: <87sglvi9hb.fsf@gmail.com> References: <87d0d0e5kg.fsf@ucl.ac.uk> <87muc49bqr.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:48462) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idqce-0007oZ-1n for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 02:04:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1idqcZ-0000r0-1V for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 02:04:49 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:38719) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1idqcX-0000o0-Rk for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 02:04:46 -0500 Received: by mail-pf1-x432.google.com with SMTP id x185so5555797pfc.5 for ; Sat, 07 Dec 2019 23:04:40 -0800 (PST) In-Reply-To: <87muc49bqr.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Fraga, Eric" Cc: "emacs-orgmode@gnu.org" "Fraga, Eric" 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!