From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Huszagh Subject: Re: Removing horizontal space in latex fragments Date: Sat, 14 Dec 2019 19:48:53 -0800 Message-ID: <87v9qiw8nu.fsf@gmail.com> References: <87tv63osz9.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39571) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igKtv-00071v-Oc for emacs-orgmode@gnu.org; Sat, 14 Dec 2019 22:49:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1igKtu-0006Jg-Is for emacs-orgmode@gnu.org; Sat, 14 Dec 2019 22:48:59 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:38347) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1igKtu-0006Fs-6u for emacs-orgmode@gnu.org; Sat, 14 Dec 2019 22:48:58 -0500 Received: by mail-pl1-x62c.google.com with SMTP id f20so1200923plj.5 for ; Sat, 14 Dec 2019 19:48:57 -0800 (PST) In-Reply-To: <87tv63osz9.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" , "Fraga, Eric" --=-=-= Content-Type: text/plain Nicolas Goaziou writes: > So, has anyone settled on which one to apply? My vote goes for keeping the newlines to improve readability in the generated tex file. But, again, I'm more than happy to be overuled. > Minor nitpick: > > (if (string-suffix-p string "\n") ...) > > is slightly less low-level. Appreciate the nitpick; your version is better! I've attached an updated patch. Best, Matt --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=keep-newlines.patch Content-Description: keep-newlines.patch >From bdb93a13a43d90ad6e66449797111e836a67a219 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Thu, 5 Dec 2019 23:25:32 -0800 Subject: [PATCH] org.el: Remove leading/trailing whitespace from latex fragment * lisp/org.el (org-create-formula-image): Ensure user input ends with a % character to remove trailing whitespace. Also, add % characters between macros and newlines purely visual. --- lisp/org.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 9b84592ba..ae686e330 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16554,12 +16554,17 @@ a HTML file." (setq bg (org-latex-color :background)) (setq bg (org-latex-color-format (if (string= bg "Transparent") "white" bg)))) + ;; remove tex \par at end of snippet to avoid trailing + ;; whitespace + (if (string-suffix-p string "\n") + (aset string (- (length string) 1) ?%) + (setq string (concat string "%"))) (with-temp-file texfile (insert latex-header) (insert "\n\\begin{document}\n" - "\\definecolor{fg}{rgb}{" fg "}\n" - "\\definecolor{bg}{rgb}{" bg "}\n" - "\n\\pagecolor{bg}\n" + "\\definecolor{fg}{rgb}{" fg "}%\n" + "\\definecolor{bg}{rgb}{" bg "}%\n" + "\n\\pagecolor{bg}%\n" "\n{\\color{fg}\n" string "\n}\n" -- 2.24.0 --=-=-=--