[Tex/LaTex] preview-latex in emacs auctex: empty boxes

auctexemacspreview

I originally posted this question directly on the Auctex mailing list but did not receive a response. I'll hopefully get more luck on the TeX Exchange.

I was recently reminded by
this
post regarding availability of preview-latex. After pressing C-c C-p
C-b, I get small empty boxes next to my equations. That is, the png
images aren't displayed correctly. I looked into the temporary
directories and the png files are indeed created. They're just not
being displayed correctly in emacs. Does anyone know how to fix this?

After getting that to work, I would also like to set the "font" color
in the png files to be green since I have a black background in emacs
(currently set to white for testing). How could I modify this?

FYI, I am using AucTeX 11.86 with Emacs 23 in Ubuntu 11.04. Also,
this error was reproduced with a simple LaTeX file (below), and emacs
was started without the init file (loaded AucTeX and preview-latex
manually).

foo.tex:

\documentclass{article}
\begin{document}
Let $x=1$.  %%
Then
\[
\lim_{x\rightarrow \infty} x^{x}
\]
is undefined.  %%
\end{document}

UPDATE 9/16/2011: Right clicking on the emtpy box, I get an option for "view error". On one of it, the error is:

gs -dOutputFile\=\(_region_.prv/tmp27138kzR/pr1-16.png\) -q -dSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r105.443x105.424
GS>{DELAYSAFER{.setsafe}if}stopped pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne or{.preview-BP 0 0 0 setrgbcolor clippath fill 1 1 1 setrgbcolor}{pop}ifelse}bind/PageSize[1 1]>>setpagedevice/preview-do{[count 3 roll save]3 1 roll dup length 0 eq{pop}{setpagedevice}{ifelse .runandhide}stopped{handleerror quit}if aload pop restore}bind def [(_region_.prv/tmp27138kzR/preview.ps)(r)file]aload exch dup 0 setfileposition 224768()/SubFileDecode filter cvx .runandhide aload pop dup dup 224768 setfileposition 288()/SubFileDecode filter cvx<<>>preview-do
Error: /typecheck in --setfileposition--
Operand stack:
   --nostringval--   (_region_.prv/tmp27138kzR/preview.ps)   (r)   (r)   (r)   226987   226987   226987   226885   226885   226885   226732   226732   226732   226613   226613   226613   226461   226461   226461   226312   226312   226312   226196   226196   226196   226078   226078   226078   225954   225954   225954   225848   225848   225848   225750   225750   225750   225626   225626   225626   225528   225528   225528   225056   225056   225056   224768
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1163/1684(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Current file position is 31
GS<48>

Any thoughts on how to fix this??? Thanks.

Best Answer

I was having this same problem when I stumbled across this post. I was able to fix it the following way:

Note, I am using Emacs23.3.1, AUCTeX 11.86, Ubuntu 11.10, Gnome3.2.1

Open a .tex file (or make one). I will assume that you are using Emacs23, using an Xwindow (Mine is in Gnome). Go to the menu bar and do:

Preview -> Customize -> Browse Options

In this buffer, do:

Preview GS -> Preview GS options -> [click on the little arrow to show the options] -> del -dSAFER

C-x C-s to save, and reload Emacs. Previews should work now!