12

Possible Duplicate:
Table in LaTeX appearing in middle of next page

I'm triying to make an image appear on top, but only works if I have some text, otherwise, the image appears at the center (vertical alignement). If I only put the image, I can make it appear on top, but if I add some text (leaving no space for the image in that page), the image appears on the next page, but at the center. I been looking into many forums and I didn't find an answer yet ... I'm losing my mind, because I need to put every image on top (even if it's alone on a page).

Here's a minimal example:

\documentclass[lettersize,oneside,11pt]{book}
\usepackage{graphicx}
\usepackage{blindtext} % for dummy text

\begin{document}

\blindtext
\blindtext
\blindtext

\begin{figure} [htbp] 
\includegraphics[width=0.8\columnwidth]{figure xx}
\caption{figure xx}
\label{fig:figure xx}
\end{figure} 

\end{document}

My image is a PNG file and if you run this example with any image, you will notice that the text is on the first page, and the image on the second one vertically centered. But I want to have it on top.

I tried [t], [!t], [!ht], ... all combinations I guess without good results.

2 Answers2

14

Now check it:

\documentclass[lettersize,oneside,11pt]{book}
\usepackage{graphicx}
\usepackage{blindtext} % for dummy text

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

\begin{document}

\blindtext
\blindtext
\blindtext

\begin{figure} [htbp]
\includegraphics[width=0.8\columnwidth]{figure xx}
\caption{figure xx}
\label{fig:figure xx}
\end{figure}

\end{document}
  • @ÁlvaroParedes: Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). – Marco Daniel Apr 09 '12 at 10:16
  • Could someone explain how that magic incantation in the preamble works? (Solves my problem, too.) – Mars Aug 16 '16 at 20:53
7

Actually I don't get what your trying to do. You want to place the picture w/o any text on the top of the page? The problem is, that the image is centered in this case, right?

Try to add the following lines after your image; this fills up the rest of the page and should place the image on top of the page - in case you want that at all :)

\null
\vfill
Eric
  • 2,587
  • 5
  • 23
  • 26