From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlos Pita Subject: 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/)] Date: Wed, 05 Dec 2018 16:17:03 -0300 Message-ID: <878t13n5qo.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUciU-0001Nn-P2 for emacs-orgmode@gnu.org; Wed, 05 Dec 2018 14:20:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUcfY-0007tM-R3 for emacs-orgmode@gnu.org; Wed, 05 Dec 2018 14:17:16 -0500 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:41945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUcfY-0007t4-Lr for emacs-orgmode@gnu.org; Wed, 05 Dec 2018 14:17:12 -0500 Received: by mail-qt1-x843.google.com with SMTP id d18so23577486qto.8 for ; Wed, 05 Dec 2018 11:17:12 -0800 (PST) Received: from archlinux ([181.228.213.205]) by smtp.gmail.com with ESMTPSA id q62sm10350237qke.67.2018.12.05.11.17.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 11:17:10 -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 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