Rudolf Adamkovič <rud...@adamkovic.org> writes:

> I recently reported a bug to Modus Themes [1] about the face of the last
> line of LaTeX environments not extending to the edge of the window.
>
> Turns out, the problem is in Org or Emacs, not Modus Themes.
>
> REPRODUCTION STEPS:
> ...

May you try the attached patch?

>From 81407cb708f38bae525bf648bc93b03102efb09e Mon Sep 17 00:00:00 2001
Message-ID: <81407cb708f38bae525bf648bc93b03102efb09e.1743264213.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Sat, 29 Mar 2025 17:01:02 +0100
Subject: [PATCH] Fix fontification of the last line in latex environments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org.el (org-latex-regexps): Include trailing whitespace and
newline after \end{...}.  This way, latex fontification will include
the whole environment.

Reported-by: Rudolf Adamkovič <rud...@adamkovic.org>
Link: https://orgmode.org/list/m2ldt0picx....@adamkovic.org
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index f73e4f70e7..2394313f26 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -674,7 +674,7 @@ (eval-and-compile
 ;;;; LaTeX Environments and Fragments
 
 (defconst org-latex-regexps
-  '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)\\(?:.\\|\n\\)+?\\\\end{\\2}\\)" 1 t)
+  '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)\\(?:.\\|\n\\)+?\\\\end{\\2}[ \t]*\n?\\)" 1 t)
     ;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil)
     ("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)" 2 nil)
     ("$"  "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)" 2 nil)
-- 
2.47.1

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to