# Placing the figure exactly at the top of the page in Latex [duplicate]

I have a problem in placing a picture into a page. I used a simple code as below:

\begin{figure}[t!]
\centering
\includegraphics[keepaspectratio, width=0.6\textwidth]{./pics/5_11}
\caption{Number of RSUs that each vehicle has encountered}
\label{fig:RSUencountered}
\end{figure}


The problem is that the picture is placed exactly in the middle, although I used position specifier (t!).

How can I instruct the latex to put the picture at the top of the page.

BTW: this picture is the only element in the page.

-

## marked as duplicate by clemens, Thorsten, mafp, Martin Schröder, Heiko OberdiekJun 14 '13 at 16:39

Do you have anything else on the other pages, or is your document just a single image that you want at the top of the page? –  Werner Aug 7 '12 at 20:23
@Werner: yes. Its a 100-page document, and this figure is the last element in one of the chapters. Latex puts it on a separate page, but in the middle of the page! –  ManiAm Aug 7 '12 at 20:29
What total portion of the page is the size of the float? 50%? 70%? 90%? –  Werner Aug 7 '12 at 20:32
@Werner: I think its around 50 percent or less. –  ManiAm Aug 7 '12 at 20:33

The vertical spacing above the top floatpage float is defined by \@fptop. The default value of this parameter is 0pt plus 1.0fil. Hence when you have a single figure on a separate page you get white space on top. (Similarly \@fpbot is for bottom space with the value 0pt plus 1.0fil. Hence you get white space on bottom also. And \@fpsep defines the vertical spacing between floatpage floats. The default is 8pt plus 2.0fil).

To have the figure on top, you have to define @\fptop as

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother


The MWE:

\documentclass{article}
\usepackage[demo]{graphicx}
%
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
%
\begin{document}
\begin{figure}[t!]
\centering
\includegraphics[keepaspectratio, width=0.6\textwidth]{./pics/5_11}
\caption{Number of RSUs that each vehicle has encountered}
\label{fig:RSUencountered}
\end{figure}

\end{document}

-
What the purpose of \makeatletter and \makeatother command? –  Mohammad Fajar Feb 28 '14 at 8:11
@MohammadFajar You can't use @ in your preamble. It can be used only in a style file. For details see: What do \makeatletter and \makeatother do? –  Harish Kumar Feb 28 '14 at 8:13