From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Huszagh Subject: Removing horizontal space in latex fragments Date: Thu, 5 Dec 2019 11:03:01 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000aa93260598f9944d" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:52652) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icwPL-0000fc-BF for emacs-orgmode@gnu.org; Thu, 05 Dec 2019 14:03:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icwPI-0002Da-Tt for emacs-orgmode@gnu.org; Thu, 05 Dec 2019 14:03:23 -0500 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:38389) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icwPH-000292-W0 for emacs-orgmode@gnu.org; Thu, 05 Dec 2019 14:03:20 -0500 Received: by mail-lj1-x235.google.com with SMTP id k8so4836787ljh.5 for ; Thu, 05 Dec 2019 11:03:16 -0800 (PST) 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: emacs-orgmode@gnu.org --000000000000aa93260598f9944d Content-Type: text/plain; charset="UTF-8" I've modified the behavior of `org-create-formula-image' so that `\definecolor' etc do not create unnecessary whitespace in the output PDF. Here's the relevant change: ``` ... ;; remove tex \par at end of line (if (string= (substring string -1 nil) "\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" "\n{\\color{fg}\n" string "\n}\n" "\n\\end{document}\n")) ... ``` This is useful if you (like me) have replaced the default document class with standalone and are using dvisvgm. The change removes leading left and right space, which is especially useful when using inline math mixed with normal text. It shouldn't make a difference if using Imagemagick's convert as a backend since that can get rid of whitespace boundaries. Is anyone else interested in this modification? Should I submit it as a patch? Matt --000000000000aa93260598f9944d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've modified the behavior of `org-create-formula= -image' so that `\definecolor' etc do not create unnecessary whites= pace in the output PDF. Here's the relevant change:

```
...
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; remove= tex \par at end of line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (string=3D (sub= string string -1 nil) "\n")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 (aset string (- (length string) 1) ?%)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (setq string (concat string "%")))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 (with-temp-file texfile
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (insert latex-header)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert "= \n\\begin{document}\n"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\\= definecolor{fg}{rgb}{" fg "}%\n"
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0"\\definecolor{bg}{rgb}{" bg "}%\n"
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\n\\pagecolor{bg}%\n"
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\n{\\color{fg}\n"
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0string
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= ;\n}\n"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\n\\end{document}= \n"))
...
```

This is= useful if you (like me) have replaced the default document class with stan= dalone and are using dvisvgm. The change removes leading left and right spa= ce, which is especially useful when using inline math mixed with normal tex= t. It shouldn't make a difference if using Imagemagick's convert as= a backend since that can get rid of whitespace boundaries.

<= /div>
Is anyone else interested in this modification? Should I submit i= t as a patch?

Matt
--000000000000aa93260598f9944d--