0

This question is an exact duplicate of:

I have designed a long table, the problem is that this table is displayed in the bottom of the document and even when a paragraph is set to be displayed after the table it's displayed before the table. I have also used [!ht] to maintain the table where I want but it didn't seem to influence on it.

\documentclass[review]{elsarticle}
\DeclareGraphicsExtensions{.pdf,.gif,.jpg}
\usepackage{lineno}
\modulolinenumbers[5]
\usepackage{graphicx}
\usepackage{amssymb,amsmath,nccmath}
\usepackage{cclicenses}
%%\usepackage{caption} % is loaded automatically by 'subcaption'
\usepackage{lscape,array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % centered 'p' col.
%%\usepackage{natbib} % is loaded automatically by elsarticle doc class
\usepackage{subcaption}
\usepackage{framed}  % Framing content
\usepackage{nomencl} % Nomenclature package
\makenomenclature
\setlength{\nomitemsep}{-\parskip}\usepackage{booktabs,multirow}

%% Load the next two packages *last*:
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}

\journal{Journal of \LaTeX\ Templates}

\bibliographystyle{elsarticle-num}

\begin{document}


\section{Introduction} 


 blablablablablablablablablablablablablabllabl\\blablablablabl\\
\begin{table}[!h]
\centering
\begin{tabular}{@{} c *{3}{C{0.45cm}} *{2}{C{1.69cm}} c c @{}} 
\toprule
Voltage N\textsuperscript{o} & \multicolumn{3}{c}{Switching states} & 
\multicolumn{2}{c}{Voltage output} & Magnitude & Phase \\   
\cmidrule(lr){2-4} \cmidrule(lr){5-6}
$V_n$ & $S_a$ & $S_b$ & $S_c$ & $V_{\alpha}$ & $V_{\beta}$ & 
$U_{\mathrm{ref}}$ & $\alpha$ \\ 
\midrule
$V_{0o}$ & 0 & 0    & 0    & 0 & 0                    & 0 & 0 \\
$V_{0p}$ & 1 & 1    & 1   & 0 & 0                    & 0 & 0 \\
$V_{0n}$ &  -1 &  -1    & -1    & 0 & 0                    & 0 & 0 \\
$V_{1p}$ & 1 & 0    & 0    & $U_{dc}/3$ & 0                    & $U_{dc}/3$ 
& 0 \\
$V_{1n}$ & 0 & -1 & -1 & $U_{dc}/3$ & 0                    & $U_{dc}/3$ & 0 
\\
$V_{2p}$ & 1 & 1    & 0    & $U_{dc}/6$ & $\sqrt{3}\,U_{dc}/6$ & $U_{dc}/3$ 
& $\pi/3$ \\
$V_{2n}$  &  0 &  0 &  -1 &  $U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &  
$U_{dc}$/3 & $\pi/3$ \\
$V_{3p}$  &   0 & 1 &  0 &  -$U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &  
$U_{dc}$/3 & 2$\pi/3$ \\
$V_{3n}$  &   -1 &  0 &  -1 &  -$U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &   
$U_{dc}$/3 & 2$\pi/3$ \\
$V_{4p}$  &   0 & 1 &  1 &  -$U_{dc}$/3  & 0 &   $U_{dc}$/3 & $\pi$ \\
$V_{4n}$  &   -1 & 0 &  0 &  -$U_{dc}$/3  & 0 &   $U_{dc}$/3 & $\pi$ \\
$V_{5p}$  &   0 &  0 &  1 &  -$U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 4$\pi$/3 \\
$V_{5n}$  &   -1 &  -1 &  0 &  -$U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 4$\pi$/3 \\
$V_{6p}$  &   1 &  0 &  1 &  $U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 5$\pi$/3 \\
$V_{6n}$  &   0 &  -1 &  0 &  $U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 5$\pi$/3 \\
$V_{7}$  &   1 &  0 &  -1 &  $U_{dc}$/2 & $\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & $\pi$/6 \\
$V_{8}$  &   0 &  1 &  -1 &  0 & $\sqrt{3}$ $U_{dc}/3$ &  $\sqrt{3}$ 
$U_{dc}$/3 & $\pi$/2 \\
$V_{9}$  &   -1 &  1 &  0 &  -$U_{dc}$/2 & $\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 5$\pi$/6 \\
$V_{10}$  &   -1 &  0 &  1 &  -$U_{dc}$/2 & -$\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 7$\pi$/6 \\
$V_{11}$  &   0 &  -1 &  1 &  0 & -$\sqrt{3}$ $U_{dc}/3$ &  $\sqrt{3}$ 
$U_{dc}$/3 & 3$\pi$/2 \\
$V_{12}$  &   1 &  -1 &  0 &  $U_{dc}$/2  & -$\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 11$\pi$/6 \\
$V_{13}$  &   1 &  -1 &  -1 &  2$U_{dc}$/3  & 0 &  2 $U_{dc}$/3 & 0 \\
$V_{14}$  &   1 &  1 &  -1 &  $U_{dc}$/3  & $\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & $\pi$/3 \\
$V_{15}$  &   -1 &  1 &  -1 &  -$U_{dc}$/3  & $\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 2$\pi$/3 \\
$V_{16}$  &   -1 &  1 &  1 &  -2$U_{dc}$/3  & 0 & 2$U_{dc}$/3 & $\pi$ \\
$V_{17}$  &   -1 &  -1 &  1 &  -$U_{dc}$/3  & -$\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 4$\pi$/3 \\
$V_{18}$  &   1 &  -1 &  1 &  $U_{dc}$/3  & -$\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 5$\pi$/3 \\
\bottomrule
\end{tabular}
\end{table} 




  trtrtrtrtrtrtrtrtrtrttaatatatatatatatatat \\

\end{document}

here is the image enter image description here

marked as duplicate by David Carlisle tables Oct 20 '17 at 20:34

This question was marked as an exact duplicate of an existing question.

  • this is just a repeat of the question you just asked – David Carlisle Oct 20 '17 at 20:28
  • A modified question, I lose the control of the table position because of the length of the table. You can check the code to verify. – twimo Oct 20 '17 at 20:32
  • the table clearly would not fit on the first page so it moves to the second, it is hard to guess what else you want but in any case this question is a duplicate. you should never use [!h] (the above document produces a warning about that,) use [htp] or perhaps you want [H] from the float package – David Carlisle Oct 20 '17 at 20:32
  • No sorry there is no new detail here you could have edited the question you just asked but either way it is just a duplicate of the question on keeping the table from floating. – David Carlisle Oct 20 '17 at 20:33
  • No this is not the what I want , the second paragraph where there is trtrtrtrtrtatata should appear after the table but it's shown before the table – twimo Oct 20 '17 at 20:33
1

Well, your table fills the complete page!

To show this to you I added package showframe which visualized the resulting typing area and margins of your document. With package blindtext I added some dumy text to your code.

With the following MWE

\documentclass[review]{elsarticle}
\DeclareGraphicsExtensions{.pdf,.gif,.jpg}
\usepackage{lineno}
\modulolinenumbers[5]
\usepackage{graphicx}
\usepackage{showframe,blindtext}
\usepackage{amssymb,amsmath,nccmath}
\usepackage{cclicenses}
%%\usepackage{caption} % is loaded automatically by 'subcaption'
\usepackage{lscape,array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % centered 'p' col.
%%\usepackage{natbib} % is loaded automatically by elsarticle doc class
\usepackage{subcaption}
\usepackage{framed}  % Framing content
\usepackage{nomencl} % Nomenclature package
\makenomenclature
\setlength{\nomitemsep}{-\parskip}\usepackage{booktabs,multirow}

%% Load the next two packages *last*:
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}

\journal{Journal of \LaTeX\ Templates}

\bibliographystyle{elsarticle-num}

\begin{document}
\section{Introduction} 


 blablablablablablablablablablablablablabllabl\\blablablablabl\\
\begin{table}[!h]
\centering
\begin{tabular}{@{} c *{3}{C{0.45cm}} *{2}{C{1.69cm}} c c @{}} 
\toprule
Voltage N\textsuperscript{o} & \multicolumn{3}{c}{Switching states} & 
\multicolumn{2}{c}{Voltage output} & Magnitude & Phase \\   
\cmidrule(lr){2-4} \cmidrule(lr){5-6}
$V_n$ & $S_a$ & $S_b$ & $S_c$ & $V_{\alpha}$ & $V_{\beta}$ & 
$U_{\mathrm{ref}}$ & $\alpha$ \\ 
\midrule
$V_{0o}$ & 0 & 0    & 0    & 0 & 0                    & 0 & 0 \\
$V_{0p}$ & 1 & 1    & 1   & 0 & 0                    & 0 & 0 \\
$V_{0n}$ &  -1 &  -1    & -1    & 0 & 0                    & 0 & 0 \\
$V_{1p}$ & 1 & 0    & 0    & $U_{dc}/3$ & 0                    & $U_{dc}/3$ 
& 0 \\
$V_{1n}$ & 0 & -1 & -1 & $U_{dc}/3$ & 0                    & $U_{dc}/3$ & 0 
\\
$V_{2p}$ & 1 & 1    & 0    & $U_{dc}/6$ & $\sqrt{3}\,U_{dc}/6$ & $U_{dc}/3$ 
& $\pi/3$ \\
$V_{2n}$  &  0 &  0 &  -1 &  $U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &  
$U_{dc}$/3 & $\pi/3$ \\
$V_{3p}$  &   0 & 1 &  0 &  -$U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &  
$U_{dc}$/3 & 2$\pi/3$ \\
$V_{3n}$  &   -1 &  0 &  -1 &  -$U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &   
$U_{dc}$/3 & 2$\pi/3$ \\
$V_{4p}$  &   0 & 1 &  1 &  -$U_{dc}$/3  & 0 &   $U_{dc}$/3 & $\pi$ \\
$V_{4n}$  &   -1 & 0 &  0 &  -$U_{dc}$/3  & 0 &   $U_{dc}$/3 & $\pi$ \\
$V_{5p}$  &   0 &  0 &  1 &  -$U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 4$\pi$/3 \\
$V_{5n}$  &   -1 &  -1 &  0 &  -$U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 4$\pi$/3 \\
$V_{6p}$  &   1 &  0 &  1 &  $U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 5$\pi$/3 \\
$V_{6n}$  &   0 &  -1 &  0 &  $U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 5$\pi$/3 \\
$V_{7}$  &   1 &  0 &  -1 &  $U_{dc}$/2 & $\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & $\pi$/6 \\
$V_{8}$  &   0 &  1 &  -1 &  0 & $\sqrt{3}$ $U_{dc}/3$ &  $\sqrt{3}$ 
$U_{dc}$/3 & $\pi$/2 \\
$V_{9}$  &   -1 &  1 &  0 &  -$U_{dc}$/2 & $\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 5$\pi$/6 \\
$V_{10}$  &   -1 &  0 &  1 &  -$U_{dc}$/2 & -$\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 7$\pi$/6 \\
$V_{11}$  &   0 &  -1 &  1 &  0 & -$\sqrt{3}$ $U_{dc}/3$ &  $\sqrt{3}$ 
$U_{dc}$/3 & 3$\pi$/2 \\
$V_{12}$  &   1 &  -1 &  0 &  $U_{dc}$/2  & -$\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 11$\pi$/6 \\
$V_{13}$  &   1 &  -1 &  -1 &  2$U_{dc}$/3  & 0 &  2 $U_{dc}$/3 & 0 \\
$V_{14}$  &   1 &  1 &  -1 &  $U_{dc}$/3  & $\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & $\pi$/3 \\
$V_{15}$  &   -1 &  1 &  -1 &  -$U_{dc}$/3  & $\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 2$\pi$/3 \\
$V_{16}$  &   -1 &  1 &  1 &  -2$U_{dc}$/3  & 0 & 2$U_{dc}$/3 & $\pi$ \\
$V_{17}$  &   -1 &  -1 &  1 &  -$U_{dc}$/3  & -$\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 4$\pi$/3 \\
$V_{18}$  &   1 &  -1 &  1 &  $U_{dc}$/3  & -$\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 5$\pi$/3 \\
\bottomrule
\end{tabular}
\end{table} 
\Blindtext
\end{document}

you get the following page with table, showing that it fills completely the page:

enter image description here

EDIT:

With the following MWE your table is printed with longtable going over two pages:

\documentclass[review]{elsarticle}
\DeclareGraphicsExtensions{.pdf,.gif,.jpg}
\usepackage{lineno}
\modulolinenumbers[5]
\usepackage{graphicx}
\usepackage{showframe,blindtext}
\usepackage{longtable} % <==============================================
\usepackage{amssymb,amsmath,nccmath}
\usepackage{cclicenses}
%%\usepackage{caption} % is loaded automatically by 'subcaption'
\usepackage{lscape,array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % centered 'p' col.
%%\usepackage{natbib} % is loaded automatically by elsarticle doc class
\usepackage{subcaption}
\usepackage{framed}  % Framing contents
\usepackage{nomencl} % Nomenclature package
\makenomenclature
\setlength{\nomitemsep}{-\parskip}\usepackage{booktabs,multirow}

%% Load the next two packages *last*:
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}

\journal{Journal of \LaTeX\ Templates}

\bibliographystyle{elsarticle-num}

\begin{document}
\section{Introduction} 


 blablablablablablablablablablablablablabllabl\\blablablablabl\\

\begin{longtable}{@{} c *{3}{C{0.45cm}} *{2}{C{1.69cm}} c c @{}} % <====================
\toprule
Voltage N\textsuperscript{o} & \multicolumn{3}{c}{Switching states} & 
\multicolumn{2}{c}{Voltage output} & Magnitude & Phase \\   
\cmidrule(lr){2-4} \cmidrule(lr){5-6}
$V_n$ & $S_a$ & $S_b$ & $S_c$ & $V_{\alpha}$ & $V_{\beta}$ & 
$U_{\mathrm{ref}}$ & $\alpha$ \\ 
\midrule
$V_{0o}$ & 0 & 0    & 0    & 0 & 0                    & 0 & 0 \\
$V_{0p}$ & 1 & 1    & 1   & 0 & 0                    & 0 & 0 \\
$V_{0n}$ &  -1 &  -1    & -1    & 0 & 0                    & 0 & 0 \\
$V_{1p}$ & 1 & 0    & 0    & $U_{dc}/3$ & 0                    & $U_{dc}/3$ 
& 0 \\
$V_{1n}$ & 0 & -1 & -1 & $U_{dc}/3$ & 0                    & $U_{dc}/3$ & 0 
\\
$V_{2p}$ & 1 & 1    & 0    & $U_{dc}/6$ & $\sqrt{3}\,U_{dc}/6$ & $U_{dc}/3$ 
& $\pi/3$ \\
$V_{2n}$  &  0 &  0 &  -1 &  $U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &  
$U_{dc}$/3 & $\pi/3$ \\
$V_{3p}$  &   0 & 1 &  0 &  -$U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &  
$U_{dc}$/3 & 2$\pi/3$ \\
$V_{3n}$  &   -1 &  0 &  -1 &  -$U_{dc}$/6  & $\sqrt{3}$ $U_{dc}/6$  &   
$U_{dc}$/3 & 2$\pi/3$ \\
$V_{4p}$  &   0 & 1 &  1 &  -$U_{dc}$/3  & 0 &   $U_{dc}$/3 & $\pi$ \\
$V_{4n}$  &   -1 & 0 &  0 &  -$U_{dc}$/3  & 0 &   $U_{dc}$/3 & $\pi$ \\
$V_{5p}$  &   0 &  0 &  1 &  -$U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 4$\pi$/3 \\
$V_{5n}$  &   -1 &  -1 &  0 &  -$U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 4$\pi$/3 \\
$V_{6p}$  &   1 &  0 &  1 &  $U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 5$\pi$/3 \\
$V_{6n}$  &   0 &  -1 &  0 &  $U_{dc}$/6 & - $\sqrt{3}$ $U_{dc}/6$ &  
$U_{dc}$/3 & 5$\pi$/3 \\
$V_{7}$  &   1 &  0 &  -1 &  $U_{dc}$/2 & $\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & $\pi$/6 \\
$V_{8}$  &   0 &  1 &  -1 &  0 & $\sqrt{3}$ $U_{dc}/3$ &  $\sqrt{3}$ 
$U_{dc}$/3 & $\pi$/2 \\
$V_{9}$  &   -1 &  1 &  0 &  -$U_{dc}$/2 & $\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 5$\pi$/6 \\
$V_{10}$  &   -1 &  0 &  1 &  -$U_{dc}$/2 & -$\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 7$\pi$/6 \\
$V_{11}$  &   0 &  -1 &  1 &  0 & -$\sqrt{3}$ $U_{dc}/3$ &  $\sqrt{3}$ 
$U_{dc}$/3 & 3$\pi$/2 \\
$V_{12}$  &   1 &  -1 &  0 &  $U_{dc}$/2  & -$\sqrt{3}$ $U_{dc}/6$ &  
$\sqrt{3}$ $U_{dc}$/3 & 11$\pi$/6 \\
$V_{13}$  &   1 &  -1 &  -1 &  2$U_{dc}$/3  & 0 &  2 $U_{dc}$/3 & 0 \\
$V_{14}$  &   1 &  1 &  -1 &  $U_{dc}$/3  & $\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & $\pi$/3 \\
$V_{15}$  &   -1 &  1 &  -1 &  -$U_{dc}$/3  & $\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 2$\pi$/3 \\
$V_{16}$  &   -1 &  1 &  1 &  -2$U_{dc}$/3  & 0 & 2$U_{dc}$/3 & $\pi$ \\
$V_{17}$  &   -1 &  -1 &  1 &  -$U_{dc}$/3  & -$\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 4$\pi$/3 \\
$V_{18}$  &   1 &  -1 &  1 &  $U_{dc}$/3  & -$\sqrt{3}$ $U_{dc}/3$ & 
2$U_{dc}$/3 & 5$\pi$/3 \\
\bottomrule
\end{longtable} 

\Blindtext
\end{document}

which gives you what you want:

enter image description here

  • Yes but this is not the problem the problem is that in the code I have written a paragraph that should be displayed after the table but after compiling the paragraph is displayed before the table – twimo Oct 20 '17 at 20:37
  • @twimo but you had explictly instructed latex to take the table out of the main document flow and put it in a float so that the two paragraphs are essentially adjacent in the main document text – David Carlisle Oct 20 '17 at 20:45
  • and for a figure how can I force it to stay in its place because even if I use [!ht] the figure as an example is displayed before the table and for my case I want the figure to be displayed after the table – twimo Oct 20 '17 at 20:53
  • @twimo there is no difference between figure and table, the same applies figure is only there to take the content out of the document flow. If you have an image and you never want it to move just use \includegraphics directly exactly the same as here you use tabular directly. – David Carlisle Oct 20 '17 at 21:00
  • Ah now it's clear but here is a complicated case: you have the table environment which is used and the figure environment which isn't used and you want the figure to be displayed after the table and of course there are some paragraphs after the floats. After compiling, the figure will be displayed before the table even if the environment figure isn't used. Normally the figure should appear after the table following what was said before – twimo Oct 20 '17 at 21:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.