emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
@ 2018-12-05 19:17 Carlos Pita
  2018-12-05 19:37 ` Carlos Pita
  2018-12-05 23:38 ` Nicolas Goaziou
  0 siblings, 2 replies; 13+ messages in thread
From: Carlos Pita @ 2018-12-05 19:17 UTC (permalink / raw)
  To: emacs-orgmode

Hi, I know this problem has been reported in the past ([1], [2]). The
second link provides a hint to a solution that I've developed
further. The underlying problem is (from dvipng man page):

 -fg color_spec Choose foreground color for the images. This option will
     be ignored if there is a foreground color \special in the DVI. The
     color spec should be in TeX color \special syntax, e.g., 'rgb 1.0
     0.0 0.0'.

So the current approach to latex fragment previewing is broken as far as
any latex package indirectly uses xcolor to set background or foreground
color, tikz being a prominent example.

As a more robust solution, I suggest to explicitly set the colors in the
tex fragment for the preview instead of passing them as arguments to
dvipng. This can be done easily:

...
\usepackage{xcolor}
...
\begin{document}
  \definecolor{bg}{rgb}{0,0,0}
  \definecolor{fg}{rgb}{1,1,1}
  \color{fg}
  \pagecolor{bg}
...

Where fg and bg might be replaced by randomly generated string or
whatever you see fit to prevent name clashes.

Notice that the syntax for rgb color is the same than the one for dvipng
so it shouldn't be much of a refactoring.

Best regards
--
Carlos

---

[1] https://lists.gnu.org/archive/html/emacs-orgmode/2010-01/msg00635.html

[2] https://lists.gnu.org/archive/html/emacs-orgmode/2012-05/msg00865.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-05 19:17 Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)] Carlos Pita
@ 2018-12-05 19:37 ` Carlos Pita
  2018-12-05 23:38 ` Nicolas Goaziou
  1 sibling, 0 replies; 13+ messages in thread
From: Carlos Pita @ 2018-12-05 19:37 UTC (permalink / raw)
  To: emacs-orgmode

The quick and dirty option, if anyone wants it now:

(setq org-format-latex-header
      (concat org-format-latex-header
              "\\usepackage{xcolor}\n"
              "\\definecolor{__bg__}{HTML}{1d1f21}\n"
              "\\definecolor{__fg__}{HTML}{c5c8c6}\n"
              "\\color{__fg__}\n"
              "\\pagecolor{__bg__}\n"))
HTML format is more convenient to edit by hand based in your current
default face.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-05 19:17 Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)] Carlos Pita
  2018-12-05 19:37 ` Carlos Pita
@ 2018-12-05 23:38 ` Nicolas Goaziou
  2018-12-08  4:32   ` Carlos Pita
  1 sibling, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2018-12-05 23:38 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

Hello,

Carlos Pita <carlosjosepita@gmail.com> writes:

> As a more robust solution, I suggest to explicitly set the colors in the
> tex fragment for the preview instead of passing them as arguments to
> dvipng. This can be done easily:
>
> ...
> \usepackage{xcolor}
> ...
> \begin{document}
>   \definecolor{bg}{rgb}{0,0,0}
>   \definecolor{fg}{rgb}{1,1,1}
>   \color{fg}
>   \pagecolor{bg}
> ...
>
> Where fg and bg might be replaced by randomly generated string or
> whatever you see fit to prevent name clashes.
>
> Notice that the syntax for rgb color is the same than the one for dvipng
> so it shouldn't be much of a refactoring.

Would you want to provide a patch for that?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-05 23:38 ` Nicolas Goaziou
@ 2018-12-08  4:32   ` Carlos Pita
  2018-12-08  9:56     ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Carlos Pita @ 2018-12-08  4:32 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 204 bytes --]

> Would you want to provide a patch for that?

Yes, sure, just give me a few days since I'm quite busy right know.

Are you ok with depending on xcolor by default or do you prefer a
customization option?

[-- Attachment #2: Type: text/html, Size: 418 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-08  4:32   ` Carlos Pita
@ 2018-12-08  9:56     ` Nicolas Goaziou
  2018-12-08 14:43       ` Eric S Fraga
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2018-12-08  9:56 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

Hello,

Carlos Pita <carlosjosepita@gmail.com> writes:

>> Would you want to provide a patch for that?
>
> Yes, sure, just give me a few days since I'm quite busy right know.
>
> Are you ok with depending on xcolor by default or do you prefer a
> customization option?

I'm nowhere close to being a LaTeX expert. If depending on xcolor is not
too invasive, I'd rather do it than introduce yet another customization
option.

Maybe real LaTeX experts could chime in.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-08  9:56     ` Nicolas Goaziou
@ 2018-12-08 14:43       ` Eric S Fraga
  2018-12-22 14:00         ` Carlos Pita
  0 siblings, 1 reply; 13+ messages in thread
From: Eric S Fraga @ 2018-12-08 14:43 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

On Saturday,  8 Dec 2018 at 10:56, Nicolas Goaziou wrote:
> I'm nowhere close to being a LaTeX expert. If depending on xcolor is not
> too invasive, I'd rather do it than introduce yet another customization
> option.
>
> Maybe real LaTeX experts could chime in.

Whether expert or not, I can say that I have had xcolor in my
org-latex-packages-alist for years and have never noticed any problem.
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-08 14:43       ` Eric S Fraga
@ 2018-12-22 14:00         ` Carlos Pita
  2019-01-01 18:08           ` Carlos Pita
  0 siblings, 1 reply; 13+ messages in thread
From: Carlos Pita @ 2018-12-22 14:00 UTC (permalink / raw)
  To: Carlos Pita, emacs-orgmode

Hi,

I found out that there is already code doing what I proposed but just
when the backend is not dvipng.

If you want to keep using dvipng you can set:

(let ((dvipng (alist-get 'dvipng org-preview-latex-process-alist)))
  (plist-put dvipng :image-converter '("dvipng -D %D -T tight -o %O %f"))
  (plist-put dvipng :use-xcolor t))

The first setting is necessary to remove -F and -B from the command
line since otherwise the mix of xcolor and color arguments makes
dvipng abort with segmentation fault.

Otherwise, use another backend like imagemagick.

Best regards
--
Carlos

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2018-12-22 14:00         ` Carlos Pita
@ 2019-01-01 18:08           ` Carlos Pita
  2019-01-02 15:07             ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Carlos Pita @ 2019-01-01 18:08 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

Considering the above, do you still want me to write a patch for this?

Some options:

1. Add the above as a remark in the user guide or the wiki.

2. Add a variant of the dvipng backend, say dvipng-xcolor, as explained.

3. Remove the dvipng cli color code and (maybe just deprecate or ignore)
the use-xcolor option altogether and make xcolor the default for every
backend.

4. Do nothing.

What do you think?

Regards
--
Carlos

[-- Attachment #2: Type: text/html, Size: 817 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2019-01-01 18:08           ` Carlos Pita
@ 2019-01-02 15:07             ` Nicolas Goaziou
  2019-01-02 22:12               ` Carlos Pita
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2019-01-02 15:07 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

Hello,

Carlos Pita <carlosjosepita@gmail.com> writes:

> Considering the above, do you still want me to write a patch for this?
>
> Some options:
>
> 1. Add the above as a remark in the user guide or the wiki.
>
> 2. Add a variant of the dvipng backend, say dvipng-xcolor, as explained.
>
> 3. Remove the dvipng cli color code and (maybe just deprecate or ignore)
> the use-xcolor option altogether and make xcolor the default for every
> backend.
>
> 4. Do nothing.
>
> What do you think?

I think option 3 is better. Is there any use case left for :use-xcolor?

Thank you for taking care of this.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2019-01-02 15:07             ` Nicolas Goaziou
@ 2019-01-02 22:12               ` Carlos Pita
  2019-01-03 11:35                 ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Carlos Pita @ 2019-01-02 22:12 UTC (permalink / raw)
  To: Carlos Pita, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

Here is a patch. It removes quite a few LOC.

> I think option 3 is better. Is there any use case left for :use-xcolor?

Every other previewer has :use-xcolor t. I assume it's safe to simply
ignore :use-xcolor if it's there except that some user has configured
a converter that for some reason requires the color command line args,
in which case he will get an error (because of the color placeholders
left untouched in the command line template).

> Thank you for taking care of this.

Well, thank you for taking care of everything else ;)

Best regards
--
Carlos

[-- Attachment #2: 0001-Use-xcolor-for-all-latex-preview-converters.patch --]
[-- Type: text/x-patch, Size: 5647 bytes --]

From 9beda785e60c791bc6524b996b60e9db00f858b7 Mon Sep 17 00:00:00 2001
From: memeplex <carlosjosepita@gmail.com>
Date: Wed, 2 Jan 2019 19:05:26 -0300
Subject: [PATCH] Use xcolor for all latex preview converters

---
 lisp/org.el | 63 ++++++++++++++++-------------------------------------
 1 file changed, 19 insertions(+), 44 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0e541cd..2e63a65 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3813,12 +3813,11 @@ All available processes and theirs documents can be found in
      :image-output-type "png"
      :image-size-adjust (1.0 . 1.0)
      :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
-     :image-converter ("dvipng -fg %F -bg %B -D %D -T tight -o %O %f"))
+     :image-converter ("dvipng -D %D -T tight -o %O %f"))
     (dvisvgm
      :programs ("latex" "dvisvgm")
      :description "dvi > svg"
      :message "you need to install the programs: latex and dvisvgm."
-     :use-xcolor t
      :image-input-type "dvi"
      :image-output-type "svg"
      :image-size-adjust (1.7 . 1.5)
@@ -3828,7 +3827,6 @@ All available processes and theirs documents can be found in
      :programs ("latex" "convert")
      :description "pdf > png"
      :message "you need to install the programs: latex and imagemagick."
-     :use-xcolor t
      :image-input-type "pdf"
      :image-output-type "png"
      :image-size-adjust (1.0 . 1.0)
@@ -3848,11 +3846,6 @@ PROPERTIES accepts the following attributes:
   :message            string, message it when required programs cannot be found.
   :image-input-type   string, input file type of image converter (e.g., \"dvi\").
   :image-output-type  string, output file type of image converter (e.g., \"png\").
-  :use-xcolor         boolean, when non-nil, LaTeX \"xcolor\" macro is used to
-                      deal with background and foreground color of image.
-                      Otherwise, dvipng style background and foreground color
-                      format are generated.  You may then refer to them in
-                      command options with \"%F\" and \"%B\".
   :image-size-adjust  cons of numbers, the car element is used to adjust LaTeX
                       image size showed in buffer and the cdr element is for
                       HTML file.  This option is only useful for process
@@ -3884,8 +3877,6 @@ Place-holders used by `:image-converter' and `:latex-compiler':
 
 Place-holders only used by `:image-converter':
 
-  %F    foreground of image
-  %B    background of image
   %D    dpi, which is used to adjust image size by some processing commands.
   %S    the image size scale ratio, which is used to adjust image size by some
         processing commands."
@@ -18339,7 +18330,6 @@ a HTML file."
 	  (cdr (assq processing-type org-preview-latex-process-alist)))
 	 (programs (plist-get processing-info :programs))
 	 (error-message (or (plist-get processing-info :message) ""))
-	 (use-xcolor (plist-get processing-info :use-xcolor))
 	 (image-input-type (plist-get processing-info :image-input-type))
 	 (image-output-type (plist-get processing-info :image-output-type))
 	 (post-clean (or (plist-get processing-info :post-clean)
@@ -18370,36 +18360,23 @@ a HTML file."
 	 (resize-mini-windows nil)) ;Fix Emacs flicker when creating image.
     (dolist (program programs)
       (org-check-external-command program error-message))
-    (if use-xcolor
-	(progn (if (eq fg 'default)
-		   (setq fg (org-latex-color :foreground))
-		 (setq fg (org-latex-color-format fg)))
-	       (if (eq bg 'default)
-		   (setq bg (org-latex-color :background))
-		 (setq bg (org-latex-color-format
-			   (if (string= bg "Transparent") "white" bg))))
-	       (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")))
-      (if (eq fg 'default)
-	  (setq fg (org-dvipng-color :foreground))
-	(unless (string= fg "Transparent")
-	  (setq fg (org-dvipng-color-format fg))))
-      (if (eq bg 'default)
-	  (setq bg (org-dvipng-color :background))
-	(unless (string= bg "Transparent")
-	  (setq bg (org-dvipng-color-format bg))))
-      (with-temp-file texfile
-	(insert latex-header)
-	(insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
-
+    (if (eq fg 'default)
+	(setq fg (org-latex-color :foreground))
+      (setq fg (org-latex-color-format fg)))
+    (if (eq bg 'default)
+	(setq bg (org-latex-color :background))
+      (setq bg (org-latex-color-format
+		(if (string= bg "Transparent") "white" bg))))
+    (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"))
     (let* ((err-msg (format "Please adjust `%s' part of \
 `org-preview-latex-process-alist'."
 			    processing-type))
@@ -18409,9 +18386,7 @@ a HTML file."
 	   (image-output-file
 	    (org-compile-file
 	     image-input-file image-converter image-output-type err-msg log-buf
-	     `((?F . ,(shell-quote-argument fg))
-	       (?B . ,(shell-quote-argument bg))
-	       (?D . ,(shell-quote-argument (format "%s" dpi)))
+	     `((?D . ,(shell-quote-argument (format "%s" dpi)))
 	       (?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0))))))))
       (copy-file image-output-file tofile 'replace)
       (dolist (e post-clean)
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2019-01-02 22:12               ` Carlos Pita
@ 2019-01-03 11:35                 ` Nicolas Goaziou
  2019-01-03 15:38                   ` Carlos Pita
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2019-01-03 11:35 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

Hello,

Carlos Pita <carlosjosepita@gmail.com> writes:

> Here is a patch. It removes quite a few LOC.

Thank you.

> Every other previewer has :use-xcolor t. I assume it's safe to simply
> ignore :use-xcolor if it's there except that some user has configured
> a converter that for some reason requires the color command line args,
> in which case he will get an error (because of the color placeholders
> left untouched in the command line template).

Could you also add an entry in ORG-NEWS, in Incompatible Changes section?

> From 9beda785e60c791bc6524b996b60e9db00f858b7 Mon Sep 17 00:00:00 2001
> From: memeplex <carlosjosepita@gmail.com>
> Date: Wed, 2 Jan 2019 19:05:26 -0300
> Subject: [PATCH] Use xcolor for all latex preview converters

You need to expound a bit the commit message. Please have a look at
other such messages for examples.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2019-01-03 11:35                 ` Nicolas Goaziou
@ 2019-01-03 15:38                   ` Carlos Pita
  2019-01-04 13:21                     ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Carlos Pita @ 2019-01-03 15:38 UTC (permalink / raw)
  To: Carlos Pita, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

Hi Nicolas,

I've improved the commit message to better fit org mode conventions
and also added a note to ORG-NEWS about the new feature. Let me know
if there still is something I should change or feel free to amend it
to your liking.

One question for future patches: is it ok to add a link to the mailing
list thread where the issue was discussed in the commit message?

Regards
--
Carlos.

[-- Attachment #2: 0001-Use-xcolor-for-all-latex-preview-converters.patch --]
[-- Type: text/x-patch, Size: 6647 bytes --]

From bc210a028bb755aa8ca0eaef1605efaab735fde4 Mon Sep 17 00:00:00 2001
From: memeplex <carlosjosepita@gmail.com>
Date: Wed, 2 Jan 2019 19:05:26 -0300
Subject: [PATCH] Use xcolor for all latex preview converters

* lisp/org.el: remove :use-xcolor option and make dvipng use xcolor
  since usage of CLI fg and bg color args is incompatible with docs
  that themselves use xcolor (e.g. through tikz).
* etc/ORG-NEWS: add incompatible change note.
---
 etc/ORG-NEWS |  9 ++++++++
 lisp/org.el  | 63 ++++++++++++++++------------------------------------
 2 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index b988559..c1e426c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -39,6 +39,15 @@ arguments no longer imply a "file" result is expected.
 
 See [[git:3367ac9457]] for details.
 
+*** All LaTeX preview backends use now xcolor
+
+The dvipng backend was previously relying on fg and bg parameters to
+be passed to the CLI. This didn't work when xcolor was directly or
+indirectly used in the document (e.g. tkiz is a user of xcolor). Since
+every other backend was already using xcolor to set fg and bg, the CLI
+alternative was removed and there is no more a :use-xcolor options
+since now it's implicitly always true.
+
 ** New features
 *** Add a dispatcher command to insert dynamic blocks
 
diff --git a/lisp/org.el b/lisp/org.el
index 0e541cd..2e63a65 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3813,12 +3813,11 @@ All available processes and theirs documents can be found in
      :image-output-type "png"
      :image-size-adjust (1.0 . 1.0)
      :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
-     :image-converter ("dvipng -fg %F -bg %B -D %D -T tight -o %O %f"))
+     :image-converter ("dvipng -D %D -T tight -o %O %f"))
     (dvisvgm
      :programs ("latex" "dvisvgm")
      :description "dvi > svg"
      :message "you need to install the programs: latex and dvisvgm."
-     :use-xcolor t
      :image-input-type "dvi"
      :image-output-type "svg"
      :image-size-adjust (1.7 . 1.5)
@@ -3828,7 +3827,6 @@ All available processes and theirs documents can be found in
      :programs ("latex" "convert")
      :description "pdf > png"
      :message "you need to install the programs: latex and imagemagick."
-     :use-xcolor t
      :image-input-type "pdf"
      :image-output-type "png"
      :image-size-adjust (1.0 . 1.0)
@@ -3848,11 +3846,6 @@ PROPERTIES accepts the following attributes:
   :message            string, message it when required programs cannot be found.
   :image-input-type   string, input file type of image converter (e.g., \"dvi\").
   :image-output-type  string, output file type of image converter (e.g., \"png\").
-  :use-xcolor         boolean, when non-nil, LaTeX \"xcolor\" macro is used to
-                      deal with background and foreground color of image.
-                      Otherwise, dvipng style background and foreground color
-                      format are generated.  You may then refer to them in
-                      command options with \"%F\" and \"%B\".
   :image-size-adjust  cons of numbers, the car element is used to adjust LaTeX
                       image size showed in buffer and the cdr element is for
                       HTML file.  This option is only useful for process
@@ -3884,8 +3877,6 @@ Place-holders used by `:image-converter' and `:latex-compiler':
 
 Place-holders only used by `:image-converter':
 
-  %F    foreground of image
-  %B    background of image
   %D    dpi, which is used to adjust image size by some processing commands.
   %S    the image size scale ratio, which is used to adjust image size by some
         processing commands."
@@ -18339,7 +18330,6 @@ a HTML file."
 	  (cdr (assq processing-type org-preview-latex-process-alist)))
 	 (programs (plist-get processing-info :programs))
 	 (error-message (or (plist-get processing-info :message) ""))
-	 (use-xcolor (plist-get processing-info :use-xcolor))
 	 (image-input-type (plist-get processing-info :image-input-type))
 	 (image-output-type (plist-get processing-info :image-output-type))
 	 (post-clean (or (plist-get processing-info :post-clean)
@@ -18370,36 +18360,23 @@ a HTML file."
 	 (resize-mini-windows nil)) ;Fix Emacs flicker when creating image.
     (dolist (program programs)
       (org-check-external-command program error-message))
-    (if use-xcolor
-	(progn (if (eq fg 'default)
-		   (setq fg (org-latex-color :foreground))
-		 (setq fg (org-latex-color-format fg)))
-	       (if (eq bg 'default)
-		   (setq bg (org-latex-color :background))
-		 (setq bg (org-latex-color-format
-			   (if (string= bg "Transparent") "white" bg))))
-	       (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")))
-      (if (eq fg 'default)
-	  (setq fg (org-dvipng-color :foreground))
-	(unless (string= fg "Transparent")
-	  (setq fg (org-dvipng-color-format fg))))
-      (if (eq bg 'default)
-	  (setq bg (org-dvipng-color :background))
-	(unless (string= bg "Transparent")
-	  (setq bg (org-dvipng-color-format bg))))
-      (with-temp-file texfile
-	(insert latex-header)
-	(insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
-
+    (if (eq fg 'default)
+	(setq fg (org-latex-color :foreground))
+      (setq fg (org-latex-color-format fg)))
+    (if (eq bg 'default)
+	(setq bg (org-latex-color :background))
+      (setq bg (org-latex-color-format
+		(if (string= bg "Transparent") "white" bg))))
+    (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"))
     (let* ((err-msg (format "Please adjust `%s' part of \
 `org-preview-latex-process-alist'."
 			    processing-type))
@@ -18409,9 +18386,7 @@ a HTML file."
 	   (image-output-file
 	    (org-compile-file
 	     image-input-file image-converter image-output-type err-msg log-buf
-	     `((?F . ,(shell-quote-argument fg))
-	       (?B . ,(shell-quote-argument bg))
-	       (?D . ,(shell-quote-argument (format "%s" dpi)))
+	     `((?D . ,(shell-quote-argument (format "%s" dpi)))
 	       (?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0))))))))
       (copy-file image-output-file tofile 'replace)
       (dolist (e post-clean)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
  2019-01-03 15:38                   ` Carlos Pita
@ 2019-01-04 13:21                     ` Nicolas Goaziou
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2019-01-04 13:21 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

Hello,

Carlos Pita <carlosjosepita@gmail.com> writes:

> I've improved the commit message to better fit org mode conventions
> and also added a note to ORG-NEWS about the new feature. Let me know
> if there still is something I should change or feel free to amend it
> to your liking.

Applied. Thank you!

> One question for future patches: is it ok to add a link to the mailing
> list thread where the issue was discussed in the commit message?

I usually do that for bugfixes, indeed.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-01-04 13:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-05 19:17 Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)] Carlos Pita
2018-12-05 19:37 ` Carlos Pita
2018-12-05 23:38 ` Nicolas Goaziou
2018-12-08  4:32   ` Carlos Pita
2018-12-08  9:56     ` Nicolas Goaziou
2018-12-08 14:43       ` Eric S Fraga
2018-12-22 14:00         ` Carlos Pita
2019-01-01 18:08           ` Carlos Pita
2019-01-02 15:07             ` Nicolas Goaziou
2019-01-02 22:12               ` Carlos Pita
2019-01-03 11:35                 ` Nicolas Goaziou
2019-01-03 15:38                   ` Carlos Pita
2019-01-04 13:21                     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).