# Thread: Problem Inserting EPS Figure into File

1. ## Problem Inserting EPS Figure into File

I'm having trouble inserting .eps files into my LaTeX document.

I have Windows XP Pro, MiKTeX, and TextPad. The .eps files are generated directly by Mathematica v. 4.

Here's the full LaTeX test file:

Code:
\documentclass[12pt,dvips]{report}

\usepackage{graphicx}
\usepackage{epsf}

\begin{document}

\begin{figure}[ht]
\epsffile{BabyAardvarkElegantMultiple.eps}
\caption{Only true eigenvalue curves}\label{Fi:BabyAardvarkElegantMultiple}
\end{figure}

\end{document}
Apparently, the MHF does not allow the uploading of .eps files (a bug? If so, that should be fixed!). So I've uploaded the Mathematica file that generated the eps (it's the very last figure in the file - obtained with the Show command). You'll need to delete the .txt extension, of course.

Here's the Mathematica file:
BabyAardvarkElegantPlot.nb.txt

What I've usually done to generate the .eps file from within Mathematica is select the graph, and then choose Edit -> Save Selection As... -> EPS...

You'll need to name the file BabyAardvarkElegantMultiple.eps to match the calling command in the LaTeX code.

The error I get is not in the compiling, but in viewing the dvi file in Yap. Here is the error message I get:

Code:
MiKTeX Problem Report
Message: The page could not be rendered.
Data: Error: /undefinedresult in --div--
Operand stack:
0.0   0
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1893   1   3   %oparray_pop   1892   1   3   %oparray_pop   1876   1   3   %oparray_pop   1755   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
--dict:1155/1684(ro)(G)--   --dict:0/20(G)--   --dict:71/200(L)--   --dict:101/300(L)--   --dict:39/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
MiKTeX GPL Ghostscript 8.60: Unrecoverable error, exit code 1

Source: C:\work3\miktex-2.8\Libraries\MiKTeX\Dvi\DviPage.cpp
Line: 1045
MiKTeX: 2.8
OS: Microsoft Windows XP Professional Service Pack 3 (build 2600)
SystemAdmin: yes
PowerUser: no
Root0: C:\Documents and Settings\akeister\Application Data\MiKTeX\2.8
Root1: C:\Documents and Settings\akeister\Local Settings\Application Data\MiKTeX\2.8
Root2: C:\Documents and Settings\All Users\Application Data\MiKTeX\2.8
Root3: C:\Program Files\MiKTeX 2.8
UserInstall: C:\Documents and Settings\akeister\Application Data\MiKTeX\2.8
UserConfig: C:\Documents and Settings\akeister\Application Data\MiKTeX\2.8
UserData: C:\Documents and Settings\akeister\Local Settings\Application Data\MiKTeX\2.8
CommonInstall: C:\Program Files\MiKTeX 2.8
CommonConfig: C:\Documents and Settings\All Users\Application Data\MiKTeX\2.8
CommonData: C:\Documents and Settings\All Users\Application Data\MiKTeX\2.8
It appears to be a Ghostscript problem.

Now here's the weird part: on an older version of MiKTeX, I've gotten all of these figures correctly included before (they were part of my dissertation, which you can download here if you want. The figure I'm discussing here is on pdf page 23, dissertation page 16.) For some reason, upgrading to a later version renders these commands problematic.

I don't want to use pdf files, because the type-compile-view cycle is much longer (you have to close the stupid pdf file before re-compiling). I want to see dvi files that work correctly in Yap so that I can merely click on Yap and have it reload the file.

I've already taken a close look here, and tried a number of things. Perhaps my eps files aren't very clean. I've tried eps2eps to clean them up, and that didn't work. I wasn't able to get the jpeg2ps command to work. Perhaps someone else has used that? I'm thinking I'm missing something simple here.

Any ideas?

2. I think EPS files can be attached in the same way as Mathematica notebooks -- by adding a .txt extension (see the attachment). After all, EPS files are text files.

The first thing that comes to mind about recreating the EPS file is to convert it to PDF and then back to EPS. I am not sure about EPS vs. PS: I think they are basically the same, but the EPS file has a line about the bounding box, like this:

%%BoundingBox: 277 367 334 424

One can convert PS to PDF using Ghostscript or at ps2pdf.com. Conversely, one can print into a file from, say, Adobe Reader using some Postscript printer's driver.

I think there is also an option in Ghostview to save a page or region from a file as EPS. Anyway, the point is to recreate the EPS file using some other program.

Concerning PDF files: I found that pdflatex takes about the same time as simple latex (ten years ago this may not have been so). Then one can press Ctrl-R in Adobe Reader to reload the file without closing it. This works even in Linux now.

3. I will try converting from EPS to PDF and back again. Thanks for that tip! I will let you know how it turns out.

The problem with looking at pdf files is that my LaTeX compiler (MixTeX) doesn't like to overwrite a pdf file that is currently open. It'll ask to save it with a different filename. So I have to close the file in Adobe and then compile, and then reopen. There's a cycle that's a few steps too long: I do the compile cycle so often.

Oh, and congrats on becoming a Super member!

4. Oh, and congrats on becoming a Super member!
I have become a Super member? Wow. Thanks!

5. Yep. As far as I know, 250 posts is Senior, 500 posts is Super, and 1000 posts is MHF Contributor. I don't think there are any categories beyond that. MHF Helpers, Mods, Ambassadors, and Admins appear to be able to change that text to whatever they like.

6. Hmm. Well, the problem I encounter right now is in setting up a PostScript or a GhostScript printer. I tried it this way, but that didn't work. Could you please point me to a reliable, preferably simpler, way to install a GhostScript printer? Thanks!

7. I tried it this way, but that didn't work.
This is probably not what you want. This information is about how to start with PostScript and print it on a non-PostScript printer. You want to start with a non-PostScript file (like PDF of Word) and create its PostScript image.

The idea is to install a printer and then use it to print from Acrobat Reader to file. One set of instructions from Microsoft is here. It uses a driver for a printer, called "Generic Color PS for Commercial Printing color printer", which is provided with Microsoft Office. I have Office 2007, so in my case the path to it was C:\Program Files\Microsoft Office\OFFICE12\MSCOL11.INF instead of OFFICE11 for Office 2003.

AFAIK, most laser printers are PostScript printers, so you can install (in the Control Panel | Printers) some random driver that is provided with Windows, such as HP Color LaserJet 2500 PS and use it to print to file. The instructions above describe how to make it produce EPS rather than PS.

Unfortunately, in my tests, the size of the EPS file produced this way was about 10 times the size produced by LaTeX + dvips, but if this is used occasionally, I guess it's OK.

You can open EPS file in a text editor (for some reason, editing it in Notepad corrupted it, but Notepad++ worked fine), find the line like "%%BoundingBox: 33 12 576 780" and edit the coordinates of the bounding box (lower-left corner and upper-right corner in points; the origin is the lower-left corner of the page). I believe that opening it in GSview and choosing File | PS to EPS automatically modifies this line with the smallest box containing all page content.

Converting a file from PS to PDF and back is just my personal attempt to fix a PS file; I have not seen it elsewhere. Maybe the first thing to try is to use ps2pdf and pdf2ps, which are a part of Ghostscript. Also, if you have access to Linux, there is a command "fixps - sanitize PostScript files".

8. emakarov: You're the best!

Through your ideas, I now have a workable solution:

1. Create original eps using Mathematica.
2. Use ps2pdf command in Windows PowerShell to convert to pdf.
3. Open pdf in Adobe and print to eps using the ps printer you've described in post # 7.
4. Open eps in GhostView and use ps to eps converter in the file menu in order to compute a good bounding box.
5. Compile LaTeX document.

It all works beautifully! Thanks a bundle!

9. Darn. Snag.

I now no longer get any error messages when I view the dvi file. That's good. Unfortunately, I now no longer see the figures! There's a nice big space for them on the page, but the space where they're supposed to be is blank. Any ideas?

10. I don't have a MiKTeX installation, so I can't test this, but here is what comes to mind.

Make sure you don't use the draft option with the graphicx package. Actually, maybe it's a good idea to use this option. Once you know that the figures are correct, do you really need to see them during edit-compile-view cycle? Maybe they can be included only in the final PDF copy.

Do you really need the epsf package and the \epsffile command? According to the graphicx documentation, you can use \includegraphics to include EPS files.

Maybe GSView made an incorrect bounding box that selects a white space from the page. Try including the file you got straight from printing to file from the Adobe Reader.

You could use pdflatex and GSView instead of Adobe Reader. According to this page, it does not lock the open file and automatically reloads it when it changes.

11. You beat me to the post!

I was just going to say that I did manage to get the figures included. I used a slightly different track that you had mentioned before:

1. ps2pdf
2. pdf2ps
3. Opening in GSView and saving PS to EPS from the file menu.

This cleaned up all the figures. Unfortunately, for about half of the figures, the axes and number labels on the axes have lost quite a few of their pixels (the plot lines seem to be fine; they're also more bold), to the point where they seem very faint and hard to read. This phenomenon occurs after my Step # 2 above. I would rather not have to regenerate all my figures - some of them took an entire day for my computer to produce!

Newsflash: I seem to be able to include my original eps files using the graphicx package and includegraphics. The bounding boxes are a bit off, but I may be able to finagle that to work. The GSView resize doesn't appear to work with this...

I'll keep you posted! I'll also keep your post # 10 comments in mind.

12. I got them all!

It turns out that not all the original eps files needed cleaning up. The ones that needed cleaning up were, providentially, the same files that still looked good after being cleaned up. And the files that didn't need cleaning up were the ones that got faint after being cleaned up.

I now have all 8 figures successfully included in my dvi file, and they look great!

Thanks, emakarov. You've been a great help. I couldn't have done it without you.

13. Ok, new snag. I've finally edited my thesis to the point where I want to submit it for publication. However, although all figures show up in the dvi file, none of them show up in the pdf file created by pdflatex. I've tried creating a pdf directly from the dvi using Adobe, but the result is, quite simply, atrocious. The text is all fuzzy and it takes way too long (it took on the order of an hour, I think! And I have a decent computer with 3GB of RAM). I can't remember if this method of creating the pdf had the figures in it or not. On the other hand, pdflatex creates beautiful text, but no graphics. In the output dump from the command, I'm getting the warning messages

Non-PDF Special Ignored!
So, any ideas how I can create a good-looking pdf file including the graphics?

[EDIT] I'd slightly prefer creating the pdf using Adobe, if possible: the publisher I'm working with prefers that. But it's not a hard requirement, especially if pdflatex creates a nice, clean result.

Thanks again!

14. Apparently pdflatex cannot include EPS files. See this FAQ (the whole list is awesome) and this PDF document.

15. So, I'm using the graphicx package, and my inclusion commands are as follows:

Code:
\begin{figure}[ht]
\begin{center}
\includegraphics{BabyAardvarkElegantMultiple.eps}
\end{center}
\caption{Only true eigenvalue curves}\label{Fi:BabyAardvarkElegantMultiple}
\end{figure}
After I convert, say, BabyAardvarkElegantMultiple.eps to BabyAardvarkElegantMultiple.pdf, would my new include command just look like

Code:
\begin{figure}[ht]
\begin{center}
\includegraphics{BabyAardvarkElegantMultiple.pdf}
\end{center}
\caption{Only true eigenvalue curves}\label{Fi:BabyAardvarkElegantMultiple}
\end{figure}
?

Page 1 of 2 12 Last

### non pdf special ignored miktex download

Click on a term to search for related topics.