1

enter image description hereI am new to latex. I used this site to create a table for my latex document. However, I need the table be spanned over the second column of the document. How can I do this?

Thank you.

\begin{table}[h!]
\begin{tabular}{}
\toprule
\textbf{Table 2}             & \multicolumn{4}{c}{{\ul \textbf{Random Forest}}}                                                          & \multicolumn{4}{c}{{\ul \textbf{Neural Network}}}                                                         \\ \midrule
Mis. Val. Strat./Perf.Merics & \textit{\textbf{Acc.}}   & \textit{\textbf{Prec.}}  & \textit{\textbf{Rec.}}   & \textit{\textbf{F}}      & \textit{\textbf{Acc.}}   & \textit{\textbf{Prec.}}  & \textit{\textbf{Rec.}}   & \textit{\textbf{F}}      \\
Remove Missing rows          & 98\%                     & 97\%                     & 98\%                     & 97\%                     & 96\%                     & 63\%                     & 98\%                     & 76\%                     \\
Replace with mode            & 95\%                     & 94\%                     & 99\%                     & 96\%                     & 96\%                     & 67\%                     & 97\%                     & 77\%                     \\
Predict with decision tree   & {97\%} & {95\%} & {98\%} & {97\%} & {99\%} & {67\%} & {98\%} & {77\%} \\ \bottomrule
\end{tabular}
\end{table}
7
  • 2
    Please provide a minimum working example that reproduces your problem.
    – E. Sommer
    Dec 20, 2018 at 16:25
  • 2
    Welcome to TeX SX! Try using the table* environment, which spreads over both columns.
    – Bernard
    Dec 20, 2018 at 16:26
  • @Bernard I used table* to fit a table into two columns and I did it. The thing here is that I want to fit it only to the second one. Dec 20, 2018 at 16:35
  • 3
    I don't think it's possible with 9 columns. In this case, make two tabulars, one above the other.
    – Bernard
    Dec 20, 2018 at 16:39
  • Please also remove all the superfluous \multicolumn{1}..., they can mess with the alignment Dec 20, 2018 at 16:41

1 Answer 1

5

this is the best what can be daoe with your table (it is simply to big that can be fitted in one column as it is ...):

enter image description here

\documentclass[twocolumn]{article}
\usepackage{booktabs, makecell}

\usepackage{lipsum}
\begin{document}
\lipsum[1-5]
    \begin{table}[htb]
    \centering
    \small
    \setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} *{9}{l} }
    \toprule
\textbf{Table 2}
    & \multicolumn{4}{c}{\textbf{Random Forest}}
        & \multicolumn{4}{c}{\textbf{Neural Network}}       \\
    \midrule
\makecell[l]{Mis. Val. Strat.\\ /Perf.Merics}
    & \textit{\textbf{Acc.}}  & \textit{\textbf{Prec.}} & \textit{\textbf{Rec.}}    & \textit{\textbf{F}}
    & \textit{\textbf{Acc.}}  & \textit{\textbf{Prec.}} & \textit{\textbf{Rec.}}    & \textit{\textbf{F}}   \\
\makecell[l]{Remove\\ Missing rows}
    & 98\%                  & 97\%                      & 98\%                      & 97\%
    & 96\%                  & 63\%                      & 98\%                      & 76\%                  \\
\makecell[l]{Replace with\\ mode}
    & 95\%                  & 94\%                      & 99\%                      & 96\%
    & 96\%                  & 67\%                      & 97\%                      & 77\%                  \\
\makecell[l]{Predict with\\ decision tree}
    & 97\%                  & 95\%                      & 98\%                      & 97\%
    & 99\%                  & 67\%                      & 98\%                      & 77\%                  \\
1
  • 2
    @brain_dead_cow No, it is only want you want, but it seems that Zarko also tried to explain that is not a good solution. The answer is useful (+1) to learn some tricks to shoehorned a table when the space is a bit limited, but in this case is clearly better a two column table*, or split the table, or redesign in other ways (e.g., smaller fonts, plus avoid % symbols if all data are percentages, etc.).
    – Fran
    Dec 20, 2018 at 18:10

You must log in to answer this question.

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