preview latex fails with pdflatex

Bug #543266 reported by jhn on 2010-03-21
This bug affects 37 people
Affects Status Importance Assigned to Milestone
Fix Released
auctex (Debian)
Fix Released
auctex (Ubuntu)
ghostscript (Ubuntu)

Bug Description

Binary package hint: auctex

Preview latex does not work on the attached minimum example when using pdf latex mode in the latest version of lucid it works correctly in karmic and in ordinary latex mode on lucid. It also fails using the latest version of auctex from the main auctex page (11.86)
The preview pdf files are generated and converted to dsc however the ghost script conversion to png does not work.

Please see the following error logs. The error seems to be Error: /typecheck in --setfileposition-- from gs.
When using preview section this is replaced by Error: /undefined in copy_trailer_attrs and it still doesn't work.
This might be related to the following debian bug fixed by 8.71~dfsg-2 in debian:

The output of c-c c-l is as follows and displays no error:

Running `Preview-LaTeX' on `test' with ``pdflatex -interaction=nonstopmode "&prv_test" test.tex''
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, loaded.
CUSTOMISED FORMAT. Preloaded files:
 article.cls 2007/10/19 v1.4h Standard LaTeX document class
  size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
(./test.aux) (/usr/local/share/texmf/tex/latex/preview/preview.sty
No auxiliary output files.

Preview: Fontsize 10pt
Preview: PDFoutput 1
! Preview: Snippet 1 started.

l.7 \section
Preview: Tightpage -32891 -32891 32891 32891
! Preview: Snippet 1 ended.(608173+0x22609920).

l.7 \section{test1}

! Preview: Snippet 2 started.

l.9 \section
! Preview: Snippet 2 ended.(608173+0x22609920).

l.9 \section{test2}

[2] )
(see the transcript file for additional information)</usr/share/texmf-texlive/f
Output written on test.pdf (2 pages, 9854 bytes).
Transcript written on test.log.

Preview-LaTeX exited as expected with code 1 at Sun Mar 21 10:04:52
Running `Preview-PDF2DSC' with ``pdf2dsc test.pdf test.prv/tmp5534zxN/preview.dsc''

Preview-PDF2DSC finished at Sun Mar 21 10:04:52
Running `Preview-Ghostscript' with ``gs -dOutputFile\=\(test.prv/tmp5534zxN/pr1-\%d.png\) -q -dSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r115.427x115.564''

Preview-Ghostscript finished at Sun Mar 21 10:04:52

The gs process generates the following error:
As shown by right clicking on the missing preview in emacs.

gs -dOutputFile\=\(test.prv/tmp5534zxN/pr1-2.png\) -q -dSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r115.427x115.564
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.996109 0.996109 0.996109 setrgbcolor clippath fill 0.0781262 0.0742199 0.0703136 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 /GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin/graphicsbeginpage{//graphicsbeginpage exec 0.0781262 0.0742199 0.0703136 3 copy rg RG}bind store end readonly store [(test.prv/tmp5534zxN/preview.dsc)(r)file]aload exch dup 0 setfileposition 454()/SubFileDecode filter cvx .runandhide aload pop dup dup 454 setfileposition 53()/SubFileDecode filter cvx<<>>preview-do
Error: /typecheck in --setfileposition--
Operand stack:
   --nostringval-- --nostringval-- --nostringval-- 454
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:1160/1684(ro)(G)-- --dict:1/20(G)-- --dict:77/200(L)-- --dict:108/127(ro)(L)-- --dict:288/300(ro)(G)-- --dict:20/25(L)--
Current allocation mode is local
Current file position is 28

Related branches

jhn (jenshnielsen) wrote :
jhn (jenshnielsen) wrote :

The bug seems to be in pdf2dsc by applying the following 1 line patch from debian to pdf2dsc in ghostscript the problem is gone.

Josh Holland (jshholland) wrote :

I'll apply the patch to the lp:ubuntu/ghostscript branch and upload a fix shortly.

Changed in auctex (Ubuntu):
status: New → In Progress
assignee: nobody → Josh Holland (jshholland)
Josh Holland (jshholland) wrote :

Branch pushed and proposed for merging

Changed in auctex (Ubuntu):
milestone: none → ubuntu-10.04
Changed in auctex (Ubuntu):
importance: Undecided → High
James Westby (james-w) on 2010-04-06
affects: auctex (Ubuntu) → ghostscript (Ubuntu)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ghostscript - 8.71.dfsg.1-0ubuntu5

ghostscript (8.71.dfsg.1-0ubuntu5) lucid; urgency=low

  * debian/patches/pdf2dsc-fix-for-pdflatex-preview.dpatch:
    Fix pdflatex preview mode using the patch from
    by William Bader (LP: #543266)
 -- Josh Holland <email address hidden> Fri, 02 Apr 2010 08:25:31 +0100

Changed in ghostscript (Ubuntu):
status: In Progress → Fix Released
Diego Restrepo (diego-restrepo) wrote :

The problem persists for the usual PS mode. It was working in 9.10

I can confirm this, preview-latex doesn't work with emacs any more and it used to work in 9.10.

I can confirm that the bug, at least in my setup is still alive. The problem is back.

Changed in ghostscript (Ubuntu):
status: Fix Released → Incomplete
Steve Langasek (vorlon) on 2010-06-17
Changed in ghostscript (Ubuntu):
milestone: ubuntu-10.04 → none
status: Incomplete → New

It seems that just by removing (--purge) all the *8.71.dfsg.1-0ubuntu5 packages for ghostscript and reinstalling them fixes the problem.

Can everyone who still has this problem attach his file


and then run the following commands in a terminal window:

sudo dpkg -P --force-depends ghostscript
sudo apt-get install ghostscript

and then try the pdflatex preview again. Does it work now?

Changed in ghostscript (Ubuntu):
status: New → Incomplete

Till, I followed your suggestion, which (partially) solved the problem, since I ran into another latex preview issue: \usepackage{lastpage} from texlive-latex-extra package doesn't work for me. It seems is a very old bug, which can be solved by following , i.e:
/usr/share/texmf-texlive/tex/latex/lastpage# diff lastpage.sty lastpage.sty.original
< refs to last page number (JPG)]
> LaTeX2e package for refs to last page number (JPG)]

After this I get a similar problem to the original if I use \usepackage{hyperref}, see the attached file that reproduces the error.

The \usepackage{hyperref} problem seems related to: http://<email address hidden>/msg01358.html , where a workaround ( ) is to switch to pdf ( C-c C-t C-p ).

Are you sure that the remaining problems are a Ghostscript bug? Can you capture the input data which is sent to Ghostscript somehow and if it is PDF try to display it with Adobe Reader or a Poppler-based viewer (like evince) and if it is Postscript try to print it unfiltered on a native Postscript printer? Does the file display/print?

Hi Till, the file that I attached to #12 reproduces the error, are you able to obtain the information you need from it? I notice that a test1.dvi file is created, which seems to be correct, but I don't know where to get what you ask. Thanks.

tags: added: patch

Nuno Sucena Almeida, please follow the instructions in my comment #10.

I followed it and the end result is the same. Can you get preview working on your system with the small .tex file?

See the attached log with the re-installation of the ghostscript package.

Changed in gs-gpl:
status: Unknown → Fix Released
Changed in gs-gpl:
importance: Unknown → Medium

This bug is still present in natty, clean installation. My simple TeX file above (test1.tex) still doesn't work.

I downloaded the cvs version of auctex (2011-05-09):

cvs -z3 -d:pserver:<email address hidden>:/sources/auctex co auctex

cd auctex
./configure --prefix=/usr/local
sudo make install

and it seems to solve the issue. This bug has been present since lucid...

androith (androith) wrote :

I'm just confirming that Nuno Sucena's solution works. Ubuntu really needs to update its packages a bit more often...

As Nuno found out that updating auctex solves the problem, I added a task for the auctex package in Ubuntu.

Changed in auctex (Ubuntu):
status: New → Triaged
importance: Undecided → High
Wilfred de Bondt (wdebondt) wrote :

This seems suspiciously a lot like debian bug, 610714.
In other words, someone who can should upload an updated package to resolve this problem.

Installing the auctex 11.86-4 from debian sid fixed the problem for me

There didn't seem to be any compatibility issues with installing that particular debian package on an ubuntu system.

The Ghostscript upstream bug is fixed and current Oneiric's Ghostscript contains the fix. Therefore marking the Ubuntu Ghostscript task also as fixed.

Changed in ghostscript (Ubuntu):
status: Incomplete → Fix Released
Xiro (xiro-x) wrote :

i can't preview test1.tex in Oneiric

Xiro, can you tell the exact command you entered, so that I can reproduce it? Thanks.

Xiro (xiro-x) wrote :

I used the Emacs/AUCTeX button "Preview on/off at point", Cached the Preamble and got 3 "No entry" signs at \section{test1}, \section{test2} and \section{test3}

Frank (frank-maker) wrote :

Using debian upstream package auctex_11.86-4.deb worked for me as well:

paolo.mgi (paolo-mgi) wrote :

I cannot preview either test1 in Oneiric.

All the \section{test1} etc. commands give

Error: /typecheck in --setfileposition--
Operand stack:
   --nostringval-- (test.prv/tmp32282F0b/ (r) (r) (r) 25291
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:1164/1684(ro)(G)-- --dict:0/20(G)-- --dict:79/200(L)--
Current allocation mode is local
Current file position is 30

Same with auctex_11.86-4.deb

paolo.mgi (paolo-mgi) wrote :

Removing auctex ubuntu Oneiric package and compiling installing auctex-current.tar.gz from

as suggested in comment #19 solves for me.

Ilya G. Ryabinkin (ileyka) wrote :

I confirm error with latex-preview for revtex4 class. auctex_11.86-6.deb doesn't fix that. Here is one (out if many) errors reported:

gs -dOutputFile\=\(1dks.prv/tmp28952tio/pr1-7.png\) -q -dSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r108.606x108.587
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 }{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 [(1dks.prv/tmp28952tio/]aload exch dup 0 setfileposition 381362()/SubFileDecode filter cvx .runandhide aload pop dup dup 381362 setfileposition 144()/SubFileDecode filter cvx<<>>preview-do
Error: /typecheck in --setfileposition--
Operand stack:
   --nostringval-- (1dks.prv/tmp28952tio/ (r) (r) (r) 382030 382030 382030 381900 381900 381900 381768 381768 381768 381636 381636 381636 381506 381506 381506 381362
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

Please, update the package!

OS details
$ lsb_release -d -r -c
Description: Ubuntu 11.04
Release: 11.04
Codename: natty
auctex 11.86-2ubuntu1

Ben Gamari (bgamari) wrote :

I am also experiencing this on Oneiric. Installing the Debian package from Sid works, however.

Jochen Seidel (x+launchpad) wrote :

As Ben Gamari, I can confirm the problem on Oneiric -- installing the package from Sid solved it.

hideki (hideki) wrote :

I also have this problem with Precise.
Installing preview.el from auctex cvs repo fixes the problem.

Changed in ghostscript (Ubuntu):
assignee: Josh Holland (jshholland) → nobody
era (era) wrote :

NMU sync request for Debian 211.86-2.1 patches at LP #98711

era (era) wrote :

Sorry, #987711 )-:

Changed in auctex (Debian):
status: Unknown → Fix Released
era (era) on 2012-04-26
summary: - preview latex fails on with pdflatex
+ preview latex fails with pdflatex
john0 (sjh05-2pi) wrote :

I had this problem with a fresh install of Ubuntu 12.04, with ghostscript 9.05. I tried replacing /usr/share/emacs/site-lisp/auctex/preview/preview.el with the one out of the cvs. Initially it had no effect until I also found and deleted the compiled preview.elc file as well, but then it worked fine.

Laurence Lenberg (lenzoid1984) wrote :

With Ubuntu 10.04, ghostscript 9.01, and auctex-11.86-2ubuntu1 I had the same issue. To resolve I followed this

sudo dpkg -P --force-depends ghostscript
sudo apt-get install ghostscript

and then compile the latest AUCTeX Version manually using

Using the source package from debian sid did not solve this problem. Installing the latest did. Note that you of course need to add this to your .emacs if AUCTeX is not loaded automatically

  (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/auctex")
  (load "auctex.el" nil t t)
  (load "preview-latex.el" nil t t)

This issue is still present in Ubuntu 12.04 LTS. By default (auctex 11.86 and gs 9.05), the preview-latex does not work. The fix was to install the latest snapshot of Auctex from the wrbsites given above.

Pausanias (pausanias) wrote :

This is still a problem. The easiest workaround is to grab this file

And install it with dpkg -i

Jarvis Schultz (jarvisschultz) wrote :

In regards to the last two comments. I was also on 12.04 (with auctex 11.86 and gs 9.05) and preview inside of emacs was not working. However, unlike this bug, my error message read

    Error: /invalidfileaccess in --file--


    Error: /typecheck in --setfileposition--

I filed a bug here:

I was able to solve the problem by downgrading gs to 8.70. Alternatively, does upgrading auctex to the cvs version also fix this other problem?

paolo.mgi (paolo-mgi) wrote :

It is simply amazing that this bug is still present in 12.10!

Anyways the following workaround wors form me:
1) get auctex from
2) ./configure --prefix=/usr/local --with-emacs=/usr/bin/emacs24-x && make && make install
3) add to /etc/emacs/site-start.el
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)

Logan Rosen (logan) wrote :

This bug should be fixed now that auctex 11.86-11ubuntu1 is available in Raring.

Changed in auctex (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.