Table positioning, why need (\usepackage{float} \restylefloat{table})

I am quite new to Latex. I just want my table placed between my paragraph like a document in Office Words.

However, I had tried several methods in Table Positioning in Overleaf All seemed not working.

1. What is the meaning of 'Float' in this content? I know float is like maths value.

\usepackage{float}
\restylefloat{table}


However, this does not mention in the Overleaf site.

3. I understand the basic one like:

t = top of page
b = bottom of page
p = put special page

what is the real meaning of 'h', '!' or 'H'

\begin{table}[h!]

• float here does not refer to floating point numbers but to floating around the document. The only reason to use the table environment is to allow latex to move it to help with page breaking. If you just use tabular without the table environment then it will not float (but beware this usually produces poor typesetting) – David Carlisle Aug 13 '19 at 10:18
• – Ralf Stubner Aug 13 '19 at 10:30
• typically a document class will say set topnumber to 3 which means latex will not allow more than three floats in the top of the page, even if they would fit, but ! says to ignore those constraints. – David Carlisle Aug 13 '19 at 10:44
• note that the float package adds some useful features but you don't need it for anything you mention here apart from H and you \restylefloat isn't needed fro anything you mention here. – David Carlisle Aug 13 '19 at 10:45
• only three allowed in the top (t float area) (there are other constraints for bottom, or total on page and fraction of the page height etc. topnumber was just an example of one of the constraints that is ignored if you use ! (basically you should never use ! until final tweaks of the document when all editing done) – David Carlisle Aug 13 '19 at 11:41

The answer to the question in the title is that you do not need the float package or \restylefloat. The package is a good package and has several useful extensions to the built in float features, but you do not need it (and it does not affect the float position, just formatting).

"Float" here is unrelated to floating point numbers, it refers to the traditional typesetting technique of moving tables and figures and other unbreakable objects to help with page breaking.

You may be used to a system that can not do that, You can of course have non-floating tables in latex:

text text text

\begin{center}
\begin{tabular}{cc}
aaa &bbb\\
ccc&ddd
\end{tabular}
\end{center}

text text


The table will just come between the paragraphs.

However this is usually not a good idea, if the table takes up (say) half a page height and the first paragraph is already more than half way down the page, then there will have to be a forced page break and an ugly white space.

For this reason typeset works almost always take tables and figures as inserts that are not in the main document flow but inserted at a convenient place and always referenced indirectly from the text, so not "the table below" but "table 5 on page 4" or whatever.

The table environment implements this feature (and does nothing else). Despite its name it can contain any content, not just a tabular and it re-inserts it in one of 4 places. h (at its location in the source, if it fits there) t (at the top of a page) b (at the bottom of a page) or p on a page that just consists of floats.

In the standard classes the default position is [tbp] so if you want it to possibly be placed mid-page then use the option [htbp] to allow h. Avoid using h on its own as that gives latex very few places to place the float.

The float package adds an option [H] which makes the table a non-float and works as you indicated that you wanted, it always appears at its position in the source. This can be convenient to take manual control sometimes, but as noted above this positioning will typically produce ugly page breaks as it disables the float mechanism which is trying to avoid these bad breaks.

• thanks. Let say I have in sequence: text(1), figure1, text(2), table2, table3. I would like do it as this squence. When I use \begin{table/figure}[h!] for all. It sometimes, get mixed up, it ended in sequence: [Page 1] text(1), figure(1), beginning of text(2); [Page 2] table2, second half of text(2), table3. What I want is [Page2] suppose start with the second half of text(2) first, then table2, then table3. – aan Aug 13 '19 at 14:20
• @aan as I say using h on its own is a bad idea, it makes it more likely the float goes to the end of the document. latex keeps all figures in order and all tables in order but by design allows floats of different types to float past each other. What you describe doesn't sound "mixed up" it sounds like the expected behaviour of a float. by using [h] you are specifying that tables should not be placed at the top or bottom of a page or on a page of their own, as you are saying not t not b not p – David Carlisle Aug 13 '19 at 14:30
• thanks. I am using h! but it does mix up. What I want is [Page2] suppose start with the second half of text(2) first, then table2, then table3. I didnt use t at all, but the figure will go to next top page. – aan Aug 13 '19 at 15:22
• @aan you shouldn't use h! but if you do you most likely get a warning from latex that it has changed it to ht! It is not really possible to understand where the figures have gone from your comments, if you want help on that then make an example that shows the problem, but note that the only reason to use figure and table environments is to allow the content to be moved automatically, so what you describe sounds like the expected behaviour to me. – David Carlisle Aug 13 '19 at 15:39