[Tex/LaTex] Tables in latex – problems with text after a table

tables

I have problems with tables in latex. I want to have text before a table and I cannot do that. I don't know why the text wrote by me is written after the table. Any help?

enter image description here

Here is the code for making table which I used in my project:

\begin{table}
\small
\begin{tabular}{p{3.5cm}p{3.5cm}p{3.5cm}p{3.5cm}}
\hline
I(mA) &1mA &5mA &7mA\\
\hline
R(k$\ohm$)  &0.415k$\ohm$ &0.415k$\ohm$ &0.415k$\ohm$\\
\hline
U(V)   &0.175V &0.077V &0.107V
\end{tabular}
\end{table}

Best Answer

Here a two strategies (and a third one, with floating table as the O.P. has already, which does not produce the requested result)

  1. Omit the \begin{table}...\end{table} pair and use {\small\centering ...} instead to prevent font declaration leaking into the rest of the document. The table will be centered then. For a caption you need \captionof{table}{Your caption text}.
  2. Try \begin{table}[htb]

In both cases the table stays at the desired position, keeping the text above as desired.

In addition, I've changed the look and dimensions of the table a little bit, using siunitx and tabularx packages.


\documentclass{article}

\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{blindtext}

\begin{document}

\blindtext
\begin{table}
\small
\begin{tabularx}{\linewidth}{*{4}{X}}
\multicolumn{4}{c}{The floating table} \tabularnewline
\hline
I(\si{\mA}) &1 &5 &7\tabularnewline
\hline
R(\si{\kohm})  &0.415 &0.415 &0.415\tabularnewline
\hline
U(\si{V})   &0.175 &0.077 &0.107
\end{tabularx}
\end{table}


\clearpage

\blindtext

\begin{table}[htb]
\small
\begin{tabularx}{\linewidth}{*{4}{X}}
\multicolumn{4}{c}{The non - floating table with \texttt{[htb]}} \tabularnewline
\hline
I(\si{\mA}) &1 &5 &7\tabularnewline
\hline
R(\si{\kohm})  &0.415 &0.415 &0.415\tabularnewline
\hline
U(\si{V})   &0.175 &0.077 &0.107
\end{tabularx}
\end{table}


\clearpage


\blindtext

{%
\centering
\small
\begin{tabularx}{\linewidth}{*{4}{X}}
\multicolumn{4}{c}{The non-floating floating table} \tabularnewline
\hline
I(\si{\mA}) &1 &5 &7\tabularnewline
\hline
R(\si{\kohm})  &0.415 &0.415 &0.415\tabularnewline
\hline
U(\si{V})   &0.175 &0.077 &0.107
\end{tabularx}
\captionof{table}{My still improvable table}
}

\clearpage
\end{document}