3

This question already has an answer here:

I know that my question may be a duplicate, but I couldn't find a solution that worked for me elsewhere on the site.

Here is the MWE :

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
This is my attempt to import the image into latex.
I do not know how so I decided to try all possible cases. 
\begin{center}
\begin{figure}
\includegraphics[scale=0.7]{12.pdf}
\end{figure}
\end{center}
\end{document}

You can get my 12.pdf file there: 12.pdf.

After compiling, I get a PDF file with a page that contains my text, and another contains the image in 12.pdf. The problem is that I want to insert the image right after the words, but there seems to be lot of white space (in the image).

So, how can I get rid of that white space? I'm not a professional TeX user, so the simpler the solution, the better.

marked as duplicate by Martin Schröder, Werner, Claudio Fiandrino, Masroor, Peter Jansson Feb 14 '14 at 15:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    Very likely, you can mitigate the effect by cropping correctly the picture (use tools like pdfcrop, GIMP or whatever), even if I would draw my self the two triangles. TikZ, PSTricks are candidates for drawing. – Claudio Fiandrino Feb 13 '14 at 9:16
  • 3
    Side note: Instead of \begin{center} \begin{figure} \includegraphics[scale=0.7]{12.pdf} \end{figure} \end{center}, write \begin{figure} \centering \includegraphics[scale=0.7]{12.pdf} \end{figure}. – jub0bs Feb 13 '14 at 9:16
  • As Claudio has pointed out, this is only related to your image. The image itself takes up a hole page, including all the blank space. Crop it correctly and then latex will position it correctly automatically. – Vlad030691 Feb 13 '14 at 9:17
  • 1
    I think this is what you want. link. You have to tell us what system you are using like mac or pc. I did most of these pdf figures for my advisor. – Aung Feb 13 '14 at 9:25
  • 1
    I usually use texshop to crop but it is only for mac. Do you have Adobe Acrobat or Inkscape ? – Aung Feb 13 '14 at 9:46
4

With respect to the problem, first consider that the figure environment is a float, that mean that it can stay here, or float freely to the top, to the bottom, or jump to the next page or the last page, according to complex rules. See What are penalties and which ones are defined? and How to influence the position of float environments like figure and table in LaTeX?

Moreover, a float can add some vertical space around it. See Space after float with [h]

But the float width is always the width of the text, so center it is completely useless. As Jubobs point, what you really want is center the contents of the float, but center add vertical space also, so it is better \centering.

Another problem could be the \includegraphic option. Play only with the text and this command in your MWE, to isolate the problem.

Note that you fix a size relative of the original file size (that is, the 70% of who know ...) so if the image can be fitted or not depend of the original file.

To avoid this, usually it is a better idea fix an absolute width or height size (as [height=10cm]) that you know that is smaller than the page, but much better approach is to fix sizes relatives to the text size area. For example, with [height=.5\textheight] so your image will be the half of the text, no matter if you are using an A4 or an A5 paper, or how wider are your margins. You can fix both width or height and maintain the aspect ratio in this way:

\includegraphics[width=\textwidth,height=.95\textheight,keepaspectratio]
{example-image-10x16} % require the mwe package

MWE0

What now? The image can be fitted in the page, filling the remaining space. But note that is too close to the text. To take care of this, you can include this image in a float (or for another reason, as include a caption), but obviously reducing .95\textheight value as needed, if you want avoid a float jump:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

This is my attempt to import the image into latex.
I do not know how so I decided to try all possible cases. 

\begin{figure}[h]
\centering 
\includegraphics[width=\textwidth,height=.75\textheight,keepaspectratio]{example-image-10x16}
\end{figure}

\end{document}

MWE

Finally, if the problem is not a proper scaling, but a bad image that contain empty areas, you can crop the image with Gimp or another tool, as suggested in the comments, but also maintain the original image and show only some area. For example:

\includegraphics[width=\textwidth,height=.75\textheight,
keepaspectratio,bb=0bp 0bp 200bp 300bp,clip]{example-image-10x16}

MWE2

Note: For a MWE with example images, use the option demo in graphicx package or install the mwe package to use some standard images as example-image-a, so others can deal with your code without downloading any image (May be you will need include \usepackage{mwe} in the preamble to use the example images, but at least in Linux with TeXLive 2013 is not needed.)

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