[Tex/LaTex] Placing the figure exactly at the top of the page in Latex

positioning

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.

Best Answer

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}
Related Question