org: 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.

TINYCHANGE
This commit is contained in:
Matt Huszagh 2019-12-05 23:25:32 -08:00 committed by Nicolas Goaziou
parent b64a3308aa
commit bc9a92ee7b

View file

@ -16500,12 +16500,16 @@ 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 space.
(if (string-suffix-p string "\n")
(aset string (1- (length string)) ?%)
(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"