-2

I wanna place up my table directly into text. But it places in random places, not exactly where I type the table code like this:

\begin{table}[h!]
    \centering
    \begin{tabular}{|c|c|c|}
...
   \label{tab:my_label}
\end{table}

Also, it isn't placed directly after the text block, for example:

My first plain text block and data description table My second plain text

And table is everywhere but not right after the first text block.

PLease help me

8
  • 3
    I doubt that table take randomly place. With correct selected float placement, for example [!ht] it will appear where is inserted, of course if there is sufficient place. If it is not, It will move to the top of the next page. Using [H] (which destroy floating mechanism), defined in the float package, will insert table immediately after insertion point. However, you should be aware, that in case, that on page is not sufficient space, it also will move to the top of the next page, but will left empty space on the previous. So , be very careful, what you doing.
    – Zarko
    Mar 16, 2022 at 8:17
  • @Zarko, didn't know that [H] in table code works like that. Thanks for useful info. Tried your suggestion of [!ht] and it places the table in right place after the text as I wanted. THANK YOU! Mar 16, 2022 at 8:21
  • I never use {table} or {figure} environments; I just center the image I want with a {center} environment. Then it won't float. But to make that work, I need to use small images. Mar 16, 2022 at 8:43
  • 2
    why make a image? a \begin{tabular} never moves, it only moves because you wrapped it in \begin{table} the only function of which is to specify it can move. (You could use [H] as in the accepted answer but using [H] is a bit odd, you are adding \begin{table} which you don't need then adding [H] which disables he only function of th table environment. Mar 16, 2022 at 8:51
  • 1
    @Programmer1988: for tables I use {center} and {tabular} or {array}. No {table} or {figure}. Mar 16, 2022 at 8:52

1 Answer 1

4
Try with

...
\usepackage{float}

\begin{document}

\begin{figure}[H] or \begin{table}[H]
1
  • Yeah, right now I tried type big H instead of h! in table code like this: \begin{table}[H] and it works! Of course I added the library of \usepackage{float} THANKS A LOT! Mar 16, 2022 at 6:55

Not the answer you're looking for? Browse other questions tagged .