I'm trying to include a .png picture into my LaTeX .dvi file. I use Emacs on Debian, if that is of any importance.

I do this by


and then

\includegraphics[bb = 0 0 100 100]{student.png}

Then I process with C-c C-f (see below) and do not (what I can see) run into any problems. For some reason the [2] is shown in red -- if this is an indication of an error, it is probably unrelated as the png image should appear later on.

Then I view with C-c C-v. xdvi displays the document with no errors. But, when I browse down to the page where the image should appear, ghostscript gives the error below, and the image is not shown.

As ghostscript is probably what causes the error, this is the ghostscript stuff I have according to aptitude search ghostscript. (What does A mean?)

i A ghostscript
i A ghostscript-cups
i   ghostscript-doc
i   ghostscript-x

What do you think?

[?17;0;127cincal@VLAN-3434:~/dvk/x/first_try$latex \\nonstopmode\\input first.tex
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, swedish, loaded.

(./first.tex (/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/omsenc.dfu))) (./first.aux) [1]
[2] [3] [4] [5] [6] <./dia/student.png> [7] [8] (./first.aux) )
Output written on first.dvi (8 pages, 20016 bytes).
Transcript written on first.log.
[?17;0;127cincal@VLAN-3434:~/dvk/x/first_try$xdvi /home/incal/dvk/x/first_try/first.dvi&
[1] 3936
[?17;0;127cincal@VLAN-3434:~/dvk/x/first_try$gs: Error: /syntaxerror in (binary token, type=137)
gs: Operand stack:
gs: Execution stack:
gs:    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--
gs:    2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   fals
gs: e   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop
gs:    1861   1   3   %oparray_pop   1755   1   3   %oparray_pop   --nostringval--   
gs: %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval-- 
gs:   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue   --nost
gs: ringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1769 
gs:   1   3   %oparray_pop   --nostringval--   --nostringval--   false   1   %stopped
gs: _push   --nostringval--   1878   1   5   %oparray_pop   1877   1   5   %oparray_p
gs: op   1861   1   5   %oparray_pop   1755   1   5   %oparray_pop   --nostringval-- 
gs:   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval-
gs: -   2   %stopped_push
gs: Dictionary stack:
gs:    --dict:1157/1684(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--   --dict:23/
gs: 250(L)--   --dict:42/200(L)--
gs: Current allocation mode is local

Alright, thanks for you answers. I saved the file as .eps with no problems from Dia.

I didn't have auctex, so C-c C-t C-p didn't do anything, so I downloaded auctex and got it to work. I noticed there were different effects when editing, e.g. subsection captions were in big yellow letters. Also, flyspell-mode was suddenly on by default.

The checker gave more detailed information, although I miss the old C-c C-f shortcut. There is no shortcut stated in the menu - do you know the name of that command, so I can at least run it with M-x (and bind it to C-c C-f)?

But there were no new errors on the graphics stuff.

In the default mode, the view command is:

xdvi first.dvi

This works, but the picture is still not visible.

In PDF mode, the view command is:

xpdf -remote first -raise first.pdf

This does not do anything when run from Emacs. When I run it from bash, it says there is no first.pdf. (The LaTeX file is first.tex)

However, this works (views the file including the EPS image)

pdflatex first.tex; evince first.pdf

I guess I could run it from Emacs every time and simply ignore the view stuff.

New edit:

Ok, it worked yesterday, but for some reason it stopped to. That's what you get when you "solve" problems without knowing why or how...

The pdflatex would give me a new error message every time, and, as I googled them, I had to add a lot of stuff, so now it looks like:


The command I use now is

pdflatex --shell-escape first.tex

I added the flag because it complains that it wasn't enabled.

The file is first.tex and the eps file is ./dia/student.eps

This is the relevant part of compilation output. Yes, I googled the error messages. If you would help me on this, I would be very happy.

[Loading MPS to PDF converter (version 2006.09.02).]
)Error: /syntaxerror in (binary token, type=137)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop   1755   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push
Dictionary stack:
   --dict:1160/1684(ro)(G)--   --dict:0/20(G)--   --dict:70/200(L)--
Current allocation mode is local
GPL Ghostscript 8.71: Unrecoverable error, exit code 1
epstopdf ($Id: epstopdf.pl 17496 2010-03-18 17:57:31Z karl $) 2.15
!!! Error: Writing to gs failed, error code 1

closed as too localized by lockstep, Joseph Wright Mar 4 '12 at 18:06

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

migrated from stackoverflow.com Nov 20 '11 at 14:33

This question came from our site for professional and enthusiast programmers.

  • Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Torbjørn T. Nov 20 '11 at 14:37
  • Are you compiling in dvi-mode? Try toggling to pdf-mode <C-c> <C-t> <C-p> (with auctex). AFAIR, png is not supported natively in dvi-mode. – cjorssen Nov 20 '11 at 14:54
  • 1
    You should use the proper graphics format depending on the TeX engine you're using. See my answer to "Insert eps graphics with graphicx (file not found)". – Schweinebacke Nov 20 '11 at 15:12
  • Ok, made a big edit to my post, probably should have put it as a comment instead. Check it out. – Emanuel Berg Nov 20 '11 at 16:46
  • Update your version of ghostscript - the current one is 9.05 and yours is at least two years old (you should also install TeXLive 2011). Then convert your eps once to pdf and include that. And forget about dvi. – Martin Schröder Feb 22 '12 at 20:53