One of the figures appear in the middle of a page (on its own) when the figure does not fit the other text. How to show it on top of the new page?
In general text you can force a LaTeX image to stay where it is placed in the code using the [! h] command in the figure environment. A slight modification of this which allows the image to move to the top of the next page if there is an overhang is the [! ht] command.
Including images in your LaTeX document requires adding: \usepackage{graphicx} to the beginning/preamble of your document. \includegraphics{ } command tells LaTeX to insert the image. To upload an image, click the upload button, and upload your image file.
The short answer: use the “float” package and then the [H] option for your figure. The longer answer: The default behaviour of figures is to float, so that LaTeX can find the best way to arrange them in your document and make it look better. If you have a look, this is how books are often typeset.
If you really don't want LaTeX to move your float at all, then use the float package with the command \restylefloat{figure} in the preamble. This allows you to specify [H] as the position parameter which means “Here and only Here”.
If all else fails, just add \vspace*{3in}
to the bottom of your figure below the \caption
. Then by trial and error change the 3in
dimension until you get the look you want. This is of course pure brute force, but sometimes that's a lot easier than trying to get LaTeX to do things the "right" way.
When in doubt, use brute force.
--- Ken Thompson
I think I misunderstood your question. Are you asking "how do I get floats on pages by themselves to be at the top of the page, rather than vertically centred?"?.
If so, here's how to customise the float page. From source2e, glue is inserted at the top and bottom of the page, and between each float on the page. This inserted glue is given by the following parameters:
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{8\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
Simply redefine these to get the output you like. For example, for top- and bottom- aligned floats: (untested)
\makeatletter
\setlength\@fptop{0pt}
\setlength\@fpsep{8pt plus 1fil}
\setlength\@fpbot{0pt}
\makeatother
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With