7

I am using \includegraphics from the graphicx package directly with no floating environment like figure. I need the images placed precisely, but something is inserting space automatically.

\includegraphics*[draft, width=5cm]{Logo.png}
%\vskip 1cm
\begin{center}
\includegraphics*[draft, height=5cm, width=\textwidth]{Image.png}

I wanted the \vskip line to introduce exactly that space, however the automatical vertical space is bigger, so having that there does not add any space, and smaller values are impossible (this is my specific problem, I need 1cm exactly).

This is my output (with showframe in the geometry package): enter image description here

  • 7
    The first horizontal space is probably due to the paragraph indentation. The vertical space is introduced by the center environment. Replace with {\centering \includegraphics{...}\par} to remove it. – Nicola Talbot Jan 27 '14 at 21:22
  • 1
    try \noindent to remove the horizontal space – cmhughes Jan 27 '14 at 21:27
  • \noindent solves the extra horizontal space due to paragraph indentation (I am using the indentfirst package, but it does not seem to make a difference). As to the vertical spacing, the center environment was indeed the problem. – brita_ Jan 27 '14 at 21:35
  • @brita_ why would you expect indentfirst to suppress indentation? the positioning rules for \includegraphics are exactly the same as those of a letter such as x. – David Carlisle Jan 27 '14 at 22:19
  • 1
    @brita_ indentfirst only affects the paragraph after a section heading not the first para of the document if there is no heading. – David Carlisle Jan 27 '14 at 23:14
5

You do not want the center environment, probably this will do the right thing, although it's hard to tell as no real example document supplied:

\noindent
\includegraphics*[draft, width=5cm]{Logo.png}\\[\dimexpr 1cm-\lineskip\relax]
\includegraphics*[draft, height=5cm, width=\textwidth]{Image.png}\par
  • Can you explain why this is better \\[\dimexpr 1cm-\lineskip\relax] than \vskip 1cm? And, I do need the 2nd image centered (in case the real image's width is not \textwidth). \centering worked for me and I moved the center environment to after the 2nd image to affect all the text that follows the 2nd image (after another 1cm spacing). I did not thought this last text part would be relevant for the question. This is for my document's cover, it must have a centered title.. etc. – brita_ Jan 28 '14 at 10:21
  • @brita_ well it's better because it works:-) on not needing center(ing) OK that was just an observation that your second image was \textwidth if that doesn't apply in the real case, OK. but then you don't want \\ you want \par\vspace{\dimexpr 1cm-\lineskip-\parskip\relax\centering\includegraphics... – David Carlisle Jan 28 '14 at 12:09
  • I am more confused. I had \vskip 1cm and, apparently, it works (with no center). I used no `\` and I know exactly what you are suggesting, half the commands you are using, or if it is to put after the 1st or 2nd image. – brita_ Jan 28 '14 at 13:40
  • @brita_ vskip is the primitive, vspace is the latex version of that with a more normal {} argument syntax. other than that it's the same except that if you just add 1cm you get 1cm extra but TeX would have added a small gap (\lineskip) anyway (1pt usually) so to get exactly 1cm you need to subtract \lineskip (or set it to 0) – David Carlisle Jan 28 '14 at 14:06

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.