From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: preview latex fragments Date: Mon, 28 May 2012 00:56:41 -0400 Message-ID: <24698.1338181001@alphaville> References: <8762bmy5m6.fsf@med.uni-goettingen.de> <87obpej65q.fsf@gnu.org> <87ipflwzqc.fsf@med.uni-goettingen.de> <87ehq9wz55.fsf@med.uni-goettingen.de> <8463.1337873981@alphaville> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:46748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYs0q-0002LP-Pa for emacs-orgmode@gnu.org; Mon, 28 May 2012 00:57:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SYs0o-0004vn-PE for emacs-orgmode@gnu.org; Mon, 28 May 2012 00:57:00 -0400 Received: from g6t0184.atlanta.hp.com ([15.193.32.61]:4255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYs0o-0004ml-JY for emacs-orgmode@gnu.org; Mon, 28 May 2012 00:56:58 -0400 In-Reply-To: Message from Nick Dokos of "Thu, 24 May 2012 11:39:41 EDT." <8463.1337873981@alphaville> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas Leha , emacs-orgmode@gnu.org Nick Dokos wrote: > Andreas Leha wrote: > > ... > > >>> I experience a problem with the preview of latex fragments: I can not > > >>> change the foreground color (in org-format-latex-options). On a dark > > >>> background, the black fragments are barely visible. > > >>> > > Actually, now I can again reproduce it. The problem seems to be tikz: > > With tikz in the latex header, foreground is always black. So probably > > more a LaTeX-issue? > > > > ... > > > > Can I make the foreground changing work even with tikz loaded in the > > latex document? > > > > I can reproduce it too, without tikz. I have a green-on-black setup but > I think the underlying reason (at least in my case: Andreas's case might > be different) is minted. I'm appending an org file with my > investigation. > > Nick > > ... investigation elided... > > So either the production of the fragment is wrong or the production of > the png from the fragment, probably the former. The latex code for the > fragment follows. If I again do the latex/dvipng run by hand (with > --shell-escape to accommodate minted) I get an all-black png. If I > comment out minted, it works. > > #+BEGIN_SRC latex > \documentclass{article} > \usepackage[usenames]{color} > \usepackage{amsmath} > \usepackage[mathscr]{eucal} > \pagestyle{empty} % do not remove > \usepackage{minted} > \usepackage[utf8]{inputenc} > \usepackage[T1]{fontenc} > % Package fixltx2e omitted > \usepackage{graphicx} > % Package longtable omitted > % Package float omitted > % Package wrapfig omitted > \usepackage{soul} > \usepackage{textcomp} > \usepackage{marvosym} > \usepackage{wasysym} > \usepackage{latexsym} > \usepackage{amssymb} > % Package hyperref omitted > \tolerance=1000 > % The settings below are copied from fullpage.sty > \setlength{\textwidth}{\paperwidth} > \addtolength{\textwidth}{-3cm} > \setlength{\oddsidemargin}{1.5cm} > \addtolength{\oddsidemargin}{-2.54cm} > \setlength{\evensidemargin}{\oddsidemargin} > \setlength{\textheight}{\paperheight} > \addtolength{\textheight}{-\headheight} > \addtolength{\textheight}{-\headsep} > \addtolength{\textheight}{-\footskip} > \addtolength{\textheight}{-3cm} > \setlength{\topmargin}{1.5cm} > \addtolength{\topmargin}{-2.54cm} > \begin{document} > \[ > 2 + 2 = 4 > \] > \end{document} > > #+END_SRC I asked on comp.text.tex and Philipp Stephani provided the following explanation (fragment2.tex is a simplified version of the above tex file): ,---- | nick writes: | | > If I process the following file through latex and dvipng: | > | > latex [--shell-escape] fragment2.tex | > dvipng -fg "rgb 0 1 0" -bg "rgb 0 0 0" -T tight -D 140\ | > -o fragment2.png fragment2.dvi | > | > I get a black blob as output if the \usepackage{minted} line | > is included, but the expected image (a green-on-black "2 + 2 = 4"), | > ... | > Is this a minted bug? a dvipng bug? both? neither? | | It's a feature/unavoidable technical limitation. A more minimal example | that doesn't even require minted is | | \documentclass{article} | \usepackage{xcolor} | \begin{document} | a | \end{document} | | xcolor is loaded by minted, and it explicitly initializes the foreground | color. According to the 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.* | | So you should rather set the desired foreground color in the TeX file, | that's less fragile. | | -- | Philipp Stephani `---- So it might be worth thinking about doing that when previewing latex fragments. I haven't tried anything out yet, but I thought I'd post this for any intrepid souls who might like to experiment with it. Nick