emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* preview latex fragments
@ 2012-05-23 21:46 Andreas Leha
  2012-05-24  9:10 ` Bastien
  2012-08-03 18:26 ` Bastien
  0 siblings, 2 replies; 9+ messages in thread
From: Andreas Leha @ 2012-05-23 21:46 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

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.

The settings for background and scale (in the same variable) are
honored, though.

Is this a bug or some mis-configuration on my end?

Regards,
Andreas

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

* Re: preview latex fragments
  2012-05-23 21:46 preview latex fragments Andreas Leha
@ 2012-05-24  9:10 ` Bastien
  2012-05-24 12:05   ` Andreas Leha
  2012-08-03 18:26 ` Bastien
  1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2012-05-24  9:10 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Hi Andreas,

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> 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.
>
> The settings for background and scale (in the same variable) are
> honored, though.

Can you post a reproducible case with a specific Org version?

-- 
 Bastien

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

* Re: preview latex fragments
  2012-05-24  9:10 ` Bastien
@ 2012-05-24 12:05   ` Andreas Leha
  2012-05-24 12:18     ` Andreas Leha
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Leha @ 2012-05-24 12:05 UTC (permalink / raw)
  To: emacs-orgmode

Hi Bastien,

Bastien <bzg@gnu.org> writes:

> Hi Andreas,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> 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.
>>
>> The settings for background and scale (in the same variable) are
>> honored, though.
>
> Can you post a reproducible case with a specific Org version?

Thanks a lot for looking into this, but:
No, I can not.  Now it works as it should.  No clue what happened
actually.  Sorry for the noise.

- Andreas

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

* Re: preview latex fragments
  2012-05-24 12:05   ` Andreas Leha
@ 2012-05-24 12:18     ` Andreas Leha
  2012-05-24 15:39       ` Nick Dokos
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Leha @ 2012-05-24 12:18 UTC (permalink / raw)
  To: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi Bastien,
>
> Bastien <bzg@gnu.org> writes:
>
>> Hi Andreas,
>>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> 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.
>>>
>>> The settings for background and scale (in the same variable) are
>>> honored, though.
>>
>> Can you post a reproducible case with a specific Org version?
>
> Thanks a lot for looking into this, but:
> No, I can not.  Now it works as it should.  No clue what happened
> actually.  Sorry for the noise.
>
> - Andreas


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?

Example: Change the :foreground color in org-format-latex-options to
"Red" and do the preview (C-c C-x C-l) on this subtree:

#+begin_org
#+LATEX_HEADER: \usepackage{tikz}


* Test 
  Hi, 

  set :foreground in org-format-latex-options to "Red" and take this
  fragment $1 = 2$ and press C-c C-x C-l.
#+end_org


So the question becomes:
Can I make the foreground changing work even with tikz loaded in the
latex document?

Cheers,
Andreas

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

* Re: preview latex fragments
  2012-05-24 12:18     ` Andreas Leha
@ 2012-05-24 15:39       ` Nick Dokos
  2012-05-28  4:56         ` Nick Dokos
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Dokos @ 2012-05-24 15:39 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> wrote:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> 
> > Hi Bastien,
> >
> > Bastien <bzg@gnu.org> writes:
> >
> >> Hi Andreas,
> >>
> >> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> >>
> >>> 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.
> >>>
> >>> The settings for background and scale (in the same variable) are
> >>> honored, though.
> >>
> >> Can you post a reproducible case with a specific Org version?
> >
> > Thanks a lot for looking into this, but:
> > No, I can not.  Now it works as it should.  No clue what happened
> > actually.  Sorry for the noise.
> >
> > - Andreas
> 
> 
> 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?
> 
> Example: Change the :foreground color in org-format-latex-options to
> "Red" and do the preview (C-c C-x C-l) on this subtree:
> 
> #+begin_org
> #+LATEX_HEADER: \usepackage{tikz}
> 
> 
> * Test 
>   Hi, 
> 
>   set :foreground in org-format-latex-options to "Red" and take this
>   fragment $1 = 2$ and press C-c C-x C-l.
> #+end_org
> 
> 
> So the question becomes:
> 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

--8<---------------cut here---------------start------------->8---

* previewing a latex fragment produces a black blob 

I use a green-on-black scheme:

#+BEGIN_SRC elisp
  (setq frame-inherited-parameters '(foreground-color background-color))

  (set-foreground-color "green")
  (set-background-color "black")
  (set-cursor-color "red")
  (set-mouse-color "red")
  (set-face-foreground 'menu "light grey")
  (set-face-background 'menu "black")

#+END_SRC

Here's a simple latex fragment:

\[
2 + 2 = 4
\]

Previewing it with C-c C-x C-l, I get an invisible black blob.

The current value of org-format-latex-options is

(:foreground default
 :background default
 :scale 1.4
 :html-foreground "Black"
 :html-background "Transparent"
 :html-scale 1.0
 :matchers
	     ("begin" "$1" "$" "$$" "\\(" "\\["))

If I link to the produced png file:

[[file:./ltxpng/dark-bg_ca60306327ae6b995f92a473e1e8787c7917c488.png]]

and follow the link, I get nothing. The file has size 84 which seems
ridiculously low.  Indeed, I can ``display'' it and get info on the
image: the channel statistics show it's all black.

OTOH, if I take the following tex program, latex and dvipng it with
the same parameters, I get a reasonable result:

#+BEGIN_EXAMPLE
\documentclass{article}

\begin{document}
\[
2 + 2 = 4
\]
\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "fragment"
%%% End: 

#+END_EXAMPLE

#+BEGIN_SRC sh
 latex fragment.tex
 dvipng -fg "rgb 0 1 0" -bg "rgb 0 0 0" -D 140 -T tight -o fragment.png fragment.dvi

#+END_SRC

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
--8<---------------cut here---------------end--------------->8---

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

* Re: preview latex fragments
  2012-05-24 15:39       ` Nick Dokos
@ 2012-05-28  4:56         ` Nick Dokos
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Dokos @ 2012-05-28  4:56 UTC (permalink / raw)
  To: Andreas Leha, emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> wrote:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> 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 <nobody@nowhere.non> 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

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

* Re: preview latex fragments
  2012-05-23 21:46 preview latex fragments Andreas Leha
  2012-05-24  9:10 ` Bastien
@ 2012-08-03 18:26 ` Bastien
  2012-08-03 19:10   ` Andreas Leha
  1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2012-08-03 18:26 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Hi Andreas,

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

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

If you are still having this bug, can you try this patch and say if it
fixes your problem?

  http://patchwork.newartisans.com/patch/1387/

Thanks!

-- 
 Bastien

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

* Re: preview latex fragments
  2012-08-03 18:26 ` Bastien
@ 2012-08-03 19:10   ` Andreas Leha
  2012-08-06 16:36     ` darcamo
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Leha @ 2012-08-03 19:10 UTC (permalink / raw)
  To: emacs-orgmode

Hi Bastien,

Bastien <bzg@gnu.org> writes:

> Hi Andreas,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> 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.
>
> If you are still having this bug, can you try this patch and say if it
> fixes your problem?
>
>   http://patchwork.newartisans.com/patch/1387/
>
> Thanks!

I still do see this problem and, unfortunately, this patch does not seem
to fix it for me.

Regards,
Andreas

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

* Re: preview latex fragments
  2012-08-03 19:10   ` Andreas Leha
@ 2012-08-06 16:36     ` darcamo
  0 siblings, 0 replies; 9+ messages in thread
From: darcamo @ 2012-08-06 16:36 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Do you add the tikz package to the
org-export-latex-default-packages-alist variable?
I had this bug in the past when I added the tikz package to
org-export-latex-default-packages-alist and the bug still exists
today.

Some threads about this (all related to tikz + preview-latex)
http://thread.gmane.org/gmane.emacs.orgmode/42410
http://article.gmane.org/gmane.emacs.auctex.general/4333/match=tikz+preview+latex
http://article.gmane.org/gmane.emacs.orgmode/56253/match=tikz+preview+latex

--
Darlan

2012/8/3 Andreas Leha <andreas.leha@med.uni-goettingen.de>:
> Hi Bastien,
>
> Bastien <bzg@gnu.org> writes:
>
>> Hi Andreas,
>>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> 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.
>>
>> If you are still having this bug, can you try this patch and say if it
>> fixes your problem?
>>
>>   http://patchwork.newartisans.com/patch/1387/
>>
>> Thanks!
>
> I still do see this problem and, unfortunately, this patch does not seem
> to fix it for me.
>
> Regards,
> Andreas
>
>

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

end of thread, other threads:[~2012-08-06 16:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-23 21:46 preview latex fragments Andreas Leha
2012-05-24  9:10 ` Bastien
2012-05-24 12:05   ` Andreas Leha
2012-05-24 12:18     ` Andreas Leha
2012-05-24 15:39       ` Nick Dokos
2012-05-28  4:56         ` Nick Dokos
2012-08-03 18:26 ` Bastien
2012-08-03 19:10   ` Andreas Leha
2012-08-06 16:36     ` darcamo

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).