# [Tex/LaTex] Control of whitespace when using \includegraphics

formattinggraphicswhite space

Probable duplicate. When using \includegraphics to insert PDF figures in text (double-column format), I find I need to make use of \hspace and \vspace in order to get the figure and the follow-on text appear in the right place. But this requires me to adjust the value of the length parameter for every new picture to make it appear in the right place. Is there a way to avoid need for \hspace and \vspace, or have their values adjusted automatically? Here is a sample:

\usepackage{graphicx}
\begin{figure}[!ht]
\begin{center} \begin{tabular}{c}
\vspace{-4cm}\\
\hspace{-1.2cm}
\includegraphics[scale=0.5]{foo} \\
\vspace{-7.5cm}\\
\hspace{-1.2cm}
\end{tabular} \end{center}
\end{figure}


\begin{figure}[!ht]


if you use the optional argument it is almost always best to include p as not doing so greatly increases the chances of the figure going to the end of the document. Also ! should only be used for "difficult cases" never as a default usage.

\begin{center}


The environment form adds vertical space which you do not want here as figure already adds vertical space. Use \centering.

\begin{tabular}{c}


The tabular is doing nothing here: it can be deleted.

\vspace{-4cm}\\


This negative space is partly compensating for the vertical space added by center but -4cm will mean that if the h option is used it will over-print text above the figure, and even t option positioning will make it overprint the page head. if the problem is white space in the image this shoudl be fixed by trimming using the options to \includegraphics or (better) fixing the image using an external editor before inclusion.

\hspace{-1.2cm}


This forces the image to over-print the left margin. Again would be better addresses by trimming the image.

\includegraphics[scale=0.5]{foo} \\


OK but the \\ should be removed once the surrounding tabular is removed.

\vspace{-7.5cm}\\
\hspace{-1.2cm}


These spaces match the ones before the image so can be removed for the same reasons.

\end{tabular} \end{center}


As noted above both the tabular and center can be removed.

\end{figure}