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.

This question already has an answer here:

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.

share|improve this question

marked as duplicate by cgnieder, Thorsten, mafp, Martin Schröder, Heiko Oberdiek Jun 14 '13 at 16:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
    
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
1  
@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

1 Answer 1

up vote 9 down vote accepted

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}
share|improve this answer
    
What the purpose of \makeatletter and \makeatother command? –  Mohammad Fajar Feb 28 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 at 8:13

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