# Why does my multicolumn table* start in the right column and go off the page (IEEEtran)?

I'm writing a two-column document with the IEEEtran class. Using their default journal template bare_jrnl.tex I add a bunch of lorum ipsum text to fill the first page and the first column of the second page. I then add a table and get the following:

Could someone please help me understand why the table* environment is not being properly placed at the left of the page?

Here is the code:

\documentclass[journal]{IEEEtran}
\usepackage{lipsum}

\begin{document}

\lipsum[1-18]

\begin{table*}[]
\caption{Here is a smaple caption.}
\centering
\begin{tabular}{|c|r|r|>{\columncolor[gray]{0.8}}r|r|r|r|r|}
\hline
Factories   & Scenario  & Lower     & Approx. & Missing     & Target    & Average \\
& Length    & Bound     & Factor   & Data   & Dairy Size    & Length \\
\hline
F1 $\rightarrow$ F2     & 28    & 27    & 1.04 & 20 & 4 & 7.00  \\
F1 $\rightarrow$ F3     & 109   & 102   & 1.08  & 78    & 13    & 8.46  \\
F1 $\rightarrow$ F4     & 83    & 74    & 1.12  & 55    & 8 & 10.38 \\
\hline
F2 $\rightarrow$ F1     & 152   & 139   & 1.09  & 110   & 13    & 11.69 \\
F2 $\rightarrow$ F3     & 143   & 132   & 1.08  & 109   & 13    & 11.00 \\
F2 $\rightarrow$ F4     & 112   & 102   & 1.10  & 83    & 8 & 14.00 \\
\hline
F3 $\rightarrow$ F1     & 152   & 130   & 1.17  & 105   & 13    & 11.69 \\
F3 $\rightarrow$ F2     & 55    & 53    & 1.04  & 42    & 4 & 13.75 \\
F3 $\rightarrow$ F4     & 111   & 99    & 1.12  & 76    & 8 & 13.88 \\
\hline
F4 $\rightarrow$ F1     & 143   & 133   & 1.08  & 102   & 13    & 11.00 \\
F4 $\rightarrow$ F2     & 48    & 47    & 1.02  & 36    & 4 & 12.00 \\
F4 $\rightarrow$ F3     & 142   & 123   & 1.15  & 97    & 13    & 10.92\\
\hline
\end{tabular}
\end{table}

\end{document}


• the table environment on top has a star* whereas the bottom closing does not -- how did it compile Apr 29 '20 at 13:02
• Is there any other problem or would you like to accept the answer with the help of the green tick Apr 29 '20 at 13:33
• @jsbibra: I was missing the star, do you want to add that as an answer. Now the table spans the two columns as I desired, although I see there are many ways to improve the table, including maybe sqeezing it into one column! Apr 29 '20 at 13:36

Basic problems are solved by @jsBibra answer (+1), so here are some off-topic improvements:

\documentclass[journal]{IEEEtran}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}

\lipsum[1-7]

\begin{table*}
\caption{Here is a smaple caption.}
\centering
\sisetup{table-format=3.0}
\begin{tabular}{|c|S|S|>{\columncolor[gray]{0.8}}S[table-format=1.2]|
S[table-format=3.0]|
S[table-format=2.0]|
S[table-format=2.2]|}
\hline
\makecell{Factories}
&{\makecell{Scenario\\ Length}}
&{\makecell{Lower\\ Bound}}
&{\makecell{Approx.\\ Factor}}
&{\makecell{Missing\\ Data}}
&{\makecell{Target\\ Dairy Size}}
&{\makecell{Average\\ Length}}              \\
\hline
F1 $\rightarrow$ F2     & 28    & 27    & 1.04 & 20 & 4 & 7.00  \\
F1 $\rightarrow$ F3     & 109   & 102   & 1.08  & 78    & 13    & 8.46  \\
F1 $\rightarrow$ F4     & 83    & 74    & 1.12  & 55    & 8 & 10.38 \\
\hline
F2 $\rightarrow$ F1     & 152   & 139   & 1.09  & 110   & 13    & 11.69 \\
F2 $\rightarrow$ F3     & 143   & 132   & 1.08  & 109   & 13    & 11.00 \\
F2 $\rightarrow$ F4     & 112   & 102   & 1.10  & 83    & 8 & 14.00 \\
\hline
F3 $\rightarrow$ F1     & 152   & 130   & 1.17  & 105   & 13    & 11.69 \\
F3 $\rightarrow$ F2     & 55    & 53    & 1.04  & 42    & 4 & 13.75 \\
F3 $\rightarrow$ F4     & 111   & 99    & 1.12  & 76    & 8 & 13.88 \\
\hline
F4 $\rightarrow$ F1     & 143   & 133   & 1.08  & 102   & 13    & 11.00 \\
F4 $\rightarrow$ F2     & 48    & 47    & 1.02  & 36    & 4 & 12.00 \\
F4 $\rightarrow$ F3     & 142   & 123   & 1.15  & 97    & 13    & 10.92\\
\hline
\end{tabular}
\end{table*}
\end{document}


Addendum: If you like to have larger vertical spaces in cells, you can achieve this on two ways:

• with for example \renewcommand\arraystretch{1.2} added before \begin{tabular} (for bigger stretch instead 1.2 select desired amount)
• with use of the cellspace package:
\documentclass[journal]{IEEEtran}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage[column=O]{cellspace}% define O as column operator
\setlength\cellspacetoplimit{3pt}    % additional vertical space above
\setlength\cellspacebottomlimit{3pt} % additional vertical space below
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}
\lipsum[1-7]
\begin{table*}
\caption{Here is a sample caption.}
\centering
\sisetup{table-format=3.0}
\begin{tabular}{|Oc|S|S|>{\columncolor[gray]{0.8}}S[table-format=1.2]| % <---
S[table-format=3.0]|
S[table-format=2.0]|
S[table-format=2.2]|}
\hline
\hline
F1 $\rightarrow$ F2     & 28    & 27    & 1.04 & 20 & 4 & 7.00  \\
F1 $\rightarrow$ F3     & 109   & 102   & 1.08  & 78    & 13    & 8.46  \\
F1 $\rightarrow$ F4     & 83    & 74    & 1.12  & 55    & 8 & 10.38 \\
\hline
F2 $\rightarrow$ F1     & 152   & 139   & 1.09  & 110   & 13    & 11.69 \\
F2 $\rightarrow$ F3     & 143   & 132   & 1.08  & 109   & 13    & 11.00 \\
F2 $\rightarrow$ F4     & 112   & 102   & 1.10  & 83    & 8 & 14.00 \\
\hline
F3 $\rightarrow$ F1     & 152   & 130   & 1.17  & 105   & 13    & 11.69 \\
F3 $\rightarrow$ F2     & 55    & 53    & 1.04  & 42    & 4 & 13.75 \\
F3 $\rightarrow$ F4     & 111   & 99    & 1.12  & 76    & 8 & 13.88 \\
\hline
F4 $\rightarrow$ F1     & 143   & 133   & 1.08  & 102   & 13    & 11.00 \\
F4 $\rightarrow$ F2     & 48    & 47    & 1.02  & 36    & 4 & 12.00 \\
F4 $\rightarrow$ F3     & 142   & 123   & 1.15  & 97    & 13    & 10.92\\
\hline
\end{tabular}
\end{table*}
\lipsum[8-12]
\end{document}


by which you will get:

Edit:

As OP complain that no answer explicitly pointed out in the first place, what is wrong with his code, let me do this now. His code not working because:

• In the preamble you forgot to add \usepackage[table]{xolor} (or usepackage{colortbl}), consequently you get series of errors (if you force compilation):
! Undefined control sequence.
<argument> |c|r|r|>{\columncolor
[gray]{0.8}}r|r|r|r|r|
l.11 ...|r|r|>{\columncolor[gray]{0.8}}r|r|r|r|r|}

?


It seems that you instead correcting this error force compiling, which result in showed result.

• Your code has typo in using environment begin{figure*}, which is not closed by\end{figure*but with\end{figure}(see differences in use of*). This gives you an error in compilation (which you not present), which clearly indicate what is error:
! LaTeX Error: \begin{table*} on input line 14 ended by \end{table}.


which you again not consider and force compilation instead checkout, why \columncolor is not defined

• Both those errors are corrected in provided MWE in the both answers. Simple comparison of the gotten MWEs and your code this will show up.

• Beside this correction in MWE, in my answer is stated: so here are some off-topic improvements: and not explicitly mentioned what is changed (assuming that this is evident from MWE code). Sorry for that. However, in comment you ask how to add more vertical spaces in cell. This is explained in my comment, as well detail described in addendum to answer and indicated all changes in comments to code. For this you inform me i your comment.

Conclusion: main error which you doing is that at compilation of your MWE you did not take into account the errors reported during compilation and rather forced it. Consequently this confused LaTeX and resulted in wrong result.

• That does look nice.. thanks! Apr 29 '20 at 13:47
• Would you know how to add a touch more vertical padding in the headings? Apr 30 '20 at 7:35
• @krumpelstiltskin, try with \\renewcommand\arraystretch{1.2} added before \begin{tabular} or use cellspace package, see addendum to answer. Apr 30 '20 at 7:50
• thead did the trick. Thanks! Apr 30 '20 at 12:04
• @krumpelstiltskin, if you liked answer and if it fulfill your expectations, than you may consider to accept it (by clicking on check mart at top left side of answer). Apr 30 '20 at 12:41

\usepackage[table]{xcolor}


also reduced the size with \scriptsize for fitment

\documentclass[journal]{IEEEtran}
\usepackage{lipsum}
\usepackage[table]{xcolor}
\begin{document}

\lipsum[1-18]

\begin{table}[h]
\scriptsize
\caption{Here is a smaple caption.}
\centering
\begin{tabular}{|c|r|r|>{\columncolor[gray]{0.8}}r|r|r|r|r|}
\hline
Factories   & Scenario  & Lower     & Approx. & Missing     & Target    & Average \\
& Length    & Bound     & Factor   & Data   & Dairy Size    & Length \\
\hline
F1 $\rightarrow$ F2     & 28    & 27    & 1.04 & 20 & 4 & 7.00  \\
F1 $\rightarrow$ F3     & 109   & 102   & 1.08  & 78    & 13    & 8.46  \\
F1 $\rightarrow$ F4     & 83    & 74    & 1.12  & 55    & 8 & 10.38 \\
\hline
F2 $\rightarrow$ F1     & 152   & 139   & 1.09  & 110   & 13    & 11.69 \\
F2 $\rightarrow$ F3     & 143   & 132   & 1.08  & 109   & 13    & 11.00 \\
F2 $\rightarrow$ F4     & 112   & 102   & 1.10  & 83    & 8 & 14.00 \\
\hline
F3 $\rightarrow$ F1     & 152   & 130   & 1.17  & 105   & 13    & 11.69 \\
F3 $\rightarrow$ F2     & 55    & 53    & 1.04  & 42    & 4 & 13.75 \\
F3 $\rightarrow$ F4     & 111   & 99    & 1.12  & 76    & 8 & 13.88 \\
\hline
F4 $\rightarrow$ F1     & 143   & 133   & 1.08  & 102   & 13    & 11.00 \\
F4 $\rightarrow$ F2     & 48    & 47    & 1.02  & 36    & 4 & 12.00 \\
F4 $\rightarrow$ F3     & 142   & 123   & 1.15  & 97    & 13    & 10.92\\
\hline
\end{tabular}
\end{table}

\end{document}
`