Floating figures and tables with Latex

Latex provides you with a lot of advantages when writing scientific papers. It allows you to fully focus on the content without having to worry to much about the formatting. Of course this works out well if you know the Latex syntax and thats also why I was a bit skeptic initially. I know MS Office really well and I'm therefore fast and productive. Nevertheless I tried Latex for writing a technical report for the Data Mining and Data Warehousing course at the university. And I was positively surprised. Once you know the basic stuff you become productive very soon. Learning the syntax wasn't a big deal..for a computer scientist :)
Anyway, I'm writing this post because I think that if you're a newbie (like me) you'll quite soon get into some trouble, especially when you have to deal with tables and figures. When I wanted to lay them out on the page, they just were not placed where I defined them on the source code. So I searched on the web and found the "[h]" attribute. So I wrote the following:
\begin{figure}[h]
...
\end{figure}
This however didn't place the figure exactly at the position defined in the Latex source but where Latex "thinks" it best fits on the page. When in your document you're writing however something like "...as shown in he figure below:" you want your figure to be displayed immediately afterwards in the next line and not two paragraphs further down. So, to overcome this problem, there are basically two possibilities. One is to not use the figure (or table) environment but just use the graphix include (or tabular for the tables). In this way however you cannot make use of tags like "caption" and "label" which may be useful.
The other possibility is to use the float package. For doing so you probably have to download the float package. Here's the URL where I downloaded it:
http://www.ctan.org/tex-archive/macros/latex/contrib/float/
Extract the "float.ins" file and run it through Latex (in your shell type "latex float.ins"). This will produce a file called "float.sty" which you can use in your project.

Now you can write
\begin{figure}[H]
...
\end{figure}
and your figure will be positioned exactly where you defined it in your Latex source. And that's basically what we wanted to achieve. The same works also with tables.

Here's another quite useful link on floating images and tables:
http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
Kindle

Comments

0

Your ad here?