Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I do not know how to reduce the vertical space between a figure and the following text or line.

LaTeX code:

\begin{document} 
\centering
\includegraphics[width = 5.0cm]{logo.png}
\HRule
\end{document}

where \HRule is defined as \newcommand{\HRule}{\rule{\linewidth}{1mm}}

I want to reduce the space between the figure and the line. I have tried with \vspace, but it did not work.

I hope you have a solution.

share|improve this question

migrated from stackoverflow.com Apr 18 '12 at 16:10

This question came from our site for professional and enthusiast programmers.

1 Answer 1

In this elementary instance, you can use the following:

enter image description here

\documentclass{article}%
% The [demo] option is just for this example
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\newcommand{\HRule}{\rule{\linewidth}{1mm}}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
\centering
\includegraphics[width = 5.0cm]{logo.png}\par
\kern\dimexpr-\baselineskip-\parskip+2mm\relax
\HRule
\end{document}​

Here \kern inserts vertical space. Since the \Hrule is set on the baseline and in a new paragraph, the vertical distance is reduced by \baselineskip+\parskip. An additional 2mm pushes \Hrule down far enough to leave a 1mm gap between the image and the line.

So, for example, if you want a 10bp gap between the image and your \Hrule, you would use

\kern\dimexpr-\baselineskip-\parskip+1mm+10bp\relax

In general, if you contain your images inside a figure environment, you can modify the length \intextsep. For this, read the layouts documentation.

share|improve this answer
    
Thank you for the answer and it did the job. –  HenrikU Apr 18 '12 at 16:43
    
@HenrikU: Consider accepting it so it can be "closed". –  Werner Apr 18 '12 at 16:49
    
Wouldn't \par\kern10pt\hrule height 2mm be easier? :) –  egreg Apr 18 '12 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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