I am using TeXShell and MiKTeX to compile with. Once I have written my code, I compile and preview and at first there was some problems with floats and stuff, but now, everything is perfect and exactly where it should be.

However, when I then do


And click on the "pdflatex" button to put it into a PDF, all my pictures and graphs go all over the place and aren't like they are in the preview bit. Why is this? It didn't happen before? I double checked with my preview by compiling and previewing it again and again, my pictures and stuff were perfect, but when doing a PDF, it was all messed up.

My pictures are all in both .eps and .jpg format. These are my margins that I have set at the beginning of the documents:

\parindent 0.25in
\oddsidemargin -0.25in
\evensidemargin -0.25in
\headsep= 0.2in
\textheight = 9.5in
\textwidth 6.5in

Could this have anything to do with it? Because the text is fine until I get further down and get to my graphs. I was thinking about making them smaller, but they work fine on my preview so I assumed they would be fine on my PDF.

  • I've never heard of an includegraphix package... do you mean graphicx? BTW, the latter usually should be able to detect the necessary driver itself.
    – cgnieder
    Dec 10, 2012 at 19:10
  • YYeah sorry, I meant graphix. It does detect the drivers and everything, its just the PDF doesn't come out like it does in the preview bit.
    – Kaish
    Dec 10, 2012 at 19:12
  • 1
    Just use \usepackage{graphicx} (you saw the c in graphicx?). As cgnieder already said the driver pdftex is not nececcary.
    – Mensch
    Dec 10, 2012 at 19:16
  • Ok sorry, another mistake. I did \usepackage[pdftex]{graphicx} with the 'c'. I just tried \usepackage{graphix}, no 'c' and I get an error.
    – Kaish
    Dec 10, 2012 at 19:18
  • IDEA: Could it be to do with my margins? If so, why does it not show up like that in my preview?
    – Kaish
    Dec 10, 2012 at 19:19

1 Answer 1


pdflatex can process only JPEG images (and PNG and PDF), but not EPS. latex processes EPS, but not the others. This means that in your preview the EPS images are used, while the PDF version gets the JPEG images. So, unless you explicitly set the width and/or height of every image, and depending on the way how you convert the images, they might be scaled differently in the DVI and PDF output.

What do your \includegraphics commands look like? Specify the width like this to scale the image to 80% of the available width:


By the way: JPEG is not the best compression algorithm for plots (unless you have 3D or colored 2D plots, like heatmaps). If you can get hold of a vector representation, use that (convert to PDF first if necessary); if not, PNG would be your best option. From the R documentation:

Plots in PNG and JPEG format can easily be converted to many other bitmap formats ... . The JPEG format is lossy, but may be useful for image plots, for example.

  • Just out of curiosity, why is jog better for 3D and 2D colored plots?
    – Scott H.
    Dec 11, 2012 at 8:46
  • @ScottH.: Didn't say that. The PNGs might just grow too big if all pixels have a different color. Of course, if you can use a vector graphic, it's still even better -- will edit.
    – krlmlr
    Dec 11, 2012 at 10:05
  • Ok, thanks. I forgot that png is lossless and was thinking that there may have been another reason :)
    – Scott H.
    Dec 11, 2012 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.