3

I am trying to include an image. This picture should be centered and should not exceed page width:

\documentclass{article}
\usepackage{graphicx}
\usepackage[showframe]{geometry}

\begin{document}

\begin{figure}
\centering
\fbox{\includegraphics[width=.9\textwidth]{image.eps}}
\end{figure}

\end{document}

It looks perfectly in DVI file but fails in PDF during LaTex-DVI-PDF compilation. .eps file is converted to pdf with dvipdfm postprocessor but displays wrong. Here is the output screen.

enter image description here !

So why is it shifted from the specified position and how it can be fixed?

\usepackage[showframe]{geometry} and \fbox{} commands are unnecessarily here but help me to detect problem. I'm also unsuccessfully tried to use different graphicx package like \usepackage[dvipdfm]{graphicx} and \usepackage[pdftex]{graphicx}.

I'm using MiKTeX 2.9.5105 and TeXnicCenter v2.02.

4
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Perhaps the .eps itself causes this. Could you upload that file?
    – Symbol 1
    Mar 11, 2015 at 15:57
  • As Symbol 1 said, it could be a problem with the eps file. To reproduce the error we would need that. In the meantime, does the problem also occur via LaTeX->PS->PDF (with DviPS and ps2pdf as postprocessors)? Mar 11, 2015 at 16:04
  • Yes @Manuel Weinkauf, the problem also occur via LaTex->PS->PDF. And I cant add .eps image via addimage icon due to its unavailable extension. here are links to this file ob Google Drive (link) and Yandex DIsk (link)
    – Yusa
    Mar 11, 2015 at 16:44
  • 1
    It works if you use latex-dvips-ps2pdf but is misplaced if you use dvipdfm Mar 11, 2015 at 19:00

1 Answer 1

3

enter image description here

By default for latex dvips is assumed. texlive doesn't come with a dvipdfm option but does include dvipdfmx.def which seems to work well enough with dvipdfm

\documentclass{article}
\usepackage[dvipdfmx]{graphicx}
\usepackage[showframe]{geometry}

\begin{document}

\begin{figure}
\centering
\fbox{\includegraphics[width=.9\textwidth]{image.eps}}
\end{figure}

\end{document}
4
  • this is actually solves my problem with latex->dvi->pdf. From the other hand there is a strange result with latex->dvi. The picture is shifted now in the dvi-file the same way but to the right up corner. It seems that i have to implement if/else block to maintain usability in both cases.
    – Yusa
    Mar 11, 2015 at 20:49
  • @Yusa yes that's expected as xdvi is interpretting dvips specials and clearly in this case there is a difference in syntax. Is there a particular reason for using dvi rather than just converting the eps to pd then using pdflatex which is the far more common route these days? Mar 11, 2015 at 21:08
  • @Yusa note the picture is not in the dvi file. the tex \special just puts processor-specific instructions into the dvi to tell the dvi driver to include an eps. if you are using two different dvi programs (xdvi and dvipdfm) then you need to make the dvi in each case with the correct syntax \specials. Mar 11, 2015 at 21:10
  • make sense, thx a lot
    – Yusa
    Mar 11, 2015 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .