9

I am trying to generate a table in a two column document. However, the table also appears in the column settings. I want that table should appear in the one column settings in the float environment. The minimum working example is given below:

      \documentclass[11pt,twocolumn,conference]{IEEEtran}
      \usepackage[T1]{fontenc}
      \usepackage{times}
      \usepackage[latin9]{inputenc}
      \usepackage[english]{babel}
      \usepackage[final]{graphicx}
      \usepackage{natbib}
      \setlength{\bibsep}{0.0pt}
      \usepackage{geometry}
      \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm }
      \usepackage{caption}% <-- added
      \captionsetup[table]{skip = 3pt}
      \usepackage{tabulary}
      \usepackage[para]{threeparttable}
      \usepackage{array,booktabs,longtable,tabularx}
      \newcolumntype{L}{>{\raggedright\arraybackslash}X}% <-- added
      \usepackage{ltablex}% <-- added
      \usepackage{siunitx}% <-- added
      \usepackage{caption}% <-- added
      \setlength{\LTcapwidth}{7in}
      \usepackage[flushleft]{threeparttablex}

      \begin{document}
      \section{INTRODUCTION}
      This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. 

      \begin{table}[!htb]
          \centering
          \footnotesize
          \caption{Year Wise Treatment Frequencies} \label{tab:freq}
          \caption*{
              \footnotesize
              This table provides the frequencies 
          } 

          \begin{tabulary}{\textwidth}{ccccr}
              \toprule
              Year  & \multicolumn{1}{c}{Nones} & Option  1 & Option 2 & Total \\
              \midrule
              \multicolumn{1}{r}{2001} & 126   & 16    & 2     & 144 \\
              \multicolumn{1}{r}{2002} & 114   & 9     & 4     & 127 \\
              \multicolumn{1}{r}{2003} & 115   & 7     & 1     & 123 \\
              \multicolumn{1}{r}{2004} & 114   & 6     & 4     & 124 \\
              \multicolumn{1}{r}{2005} & 104   & 5     & 8     & 117 \\
              \multicolumn{1}{r}{2006} & 96    & 3     & 6     & 105 \\
              \multicolumn{1}{r}{2007} & 93    & 2     & 4     & 99 \\
              \multicolumn{1}{r}{2008} & 93    & 2     & 2     & 97 \\
              \multicolumn{1}{r}{2009} & 85    & 2     & 11    & 98 \\
              \multicolumn{1}{r}{2010} & 83    & 0     & 7     & 90 \\
              \multicolumn{1}{r}{2011} & 74    & 0     & 12    & 86 \\
              \midrule      
              Total & 1,097 & 52    & 61    & 1,210 \\
              \bottomrule
          \end{tabulary}
      \end{table}
       This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction.This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction.
      \end{document}
2
  • You want your table to be full text width?
    – Bernard
    Commented Dec 23, 2016 at 14:00
  • 1
    your table perfectly fit in one column. what is the problem? beside unnecessary \multicolumn{1}{r}{...} ... i can't find anything wrong.
    – Zarko
    Commented Dec 23, 2016 at 14:50

2 Answers 2

13

I'm not sure I understand your requirements, but it looks to me like you want a table that occupies the width of a full column. If this is the case, you should look into using a tabular* environment with a width set to \columnwidth. Oh, and don't use both a \caption and a \caption* directive for one and the same figure -- it's abuse of notation, if not something worse.

enter image description here

\documentclass[11pt,twocolumn,conference]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[latin9]{inputenc}
\usepackage[english]{babel}
\usepackage[final]{graphicx}
\usepackage{natbib}
\setlength{\bibsep}{0.0pt}
\usepackage{geometry}
\geometry{verbose,margin=3cm}
\usepackage{caption}% <-- added
\captionsetup[table]{skip = 3pt}
\usepackage{tabulary}
\usepackage[para]{threeparttable}
\usepackage{array,booktabs,longtable,tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}% <-- added
\usepackage{ltablex}% <-- added
\usepackage{siunitx}% <-- added
\usepackage{caption}% <-- added
\setlength{\LTcapwidth}{7in}
\usepackage[flushleft]{threeparttablex}

\flushbottom

\begin{document}
\section{INTRODUCTION}
This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section.

Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. 

\begin{table}[!htb]
\captionsetup{size=footnotesize}
\caption{Year Wise Treatment Frequencies} \label{tab:freq}
\setlength\tabcolsep{0pt} % let LaTeX compute intercolumn whitespace
\footnotesize\centering
This table provides the frequencies.

\smallskip 
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}rcccr}
\toprule
  Year  & Nones& Option  1 & Option 2 & Total \\
\midrule
  2001& 126   & 16    & 2     & 144 \\
  2002& 114   & 9     & 4     & 127 \\
  2003& 115   & 7     & 1     & 123 \\
  2004& 114   & 6     & 4     & 124 \\
  2005& 104   & 5     & 8     & 117 \\
  2006& 96    & 3     & 6     & 105 \\
  2007& 93    & 2     & 4     & 99 \\
  2008& 93    & 2     & 2     & 97 \\
  2009& 85    & 2     & 11    & 98 \\
  2010& 83    & 0     & 7     & 90 \\
  2011& 74    & 0     & 12    & 86 \\
  \midrule
  Total & 1,097 & 52    & 61    & 1,210 \\
\bottomrule
\end{tabular*}
\end{table}

This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction.This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. 

Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction.
Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. 

Here is a the text about the introduction.Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction. This section is the introduction section. Here is a the text about the introduction.
\end{document}

Addendum to address the OP's followup comment: To make the tabular material span both columns, all you need to change in the code shown above answer is (a) replace both of instances of {table} with {table*} and replace \columnwidth with \textwidth. Do be aware, though, that LaTeX places table* and figure* environments only at the top of a page. Since there's more than enough space now, you should probably get rid of the footnotesize directives, though.

enter image description here


Second Addendum: Further analysis of the contents of the table environments shows that (a) it's not necessary to switch to \footnotesize and (b) it would useful, from the point of making the numeric information more readable, to align the numbers in the four data columns on their (implicit) decimal markers. This may be achieved by loading the siunitx package and employing the S column type.

Separately, since you're using the IEEEtran document class, I would not load the caption package, as doing so modifies the appearance of captions rather decisively. I would assume that you're using IEEEtran for a solid reason; you should thus be rather careful to change the layout and appearance of table and figure captions.

enter image description here

\documentclass[11pt,twocolumn,conference]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[verbose,margin=3cm]{geometry}
\usepackage{booktabs,siunitx}
\sisetup{group-minimum-digits=4,group-separator={,}}
\newcolumntype{T}[1]{S[table-format=#1]}

% macro for a paragraph of filler text
\newcommand\blurb{This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction. This section is the introduction section. Here is the text about the introduction.\par}

%\flushbottom % may not be necessary

\begin{document}
\section{Introduction}
\blurb\blurb
\begin{table}[!htb]
\setlength\tabcolsep{0pt}
\caption{Year Wise Treatment Frequencies} \label{tab:freq}
\centering
This table provides the frequencies.

\smallskip
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}%
    l T{4}T{2}T{2}T{4}}
\toprule
Year & {Nones}& {Option 1} & {Option 2} & {Total} \\
\midrule
  2001& 126   & 16    & 2     & 144 \\
  2002& 114   & 9     & 4     & 127 \\
  2003& 115   & 7     & 1     & 123 \\
  2004& 114   & 6     & 4     & 124 \\
  2005& 104   & 5     & 8     & 117 \\
  2006& 96    & 3     & 6     & 105 \\
  2007& 93    & 2     & 4     & 99 \\
  2008& 93    & 2     & 2     & 97 \\
  2009& 85    & 2     & 11    & 98 \\
  2010& 83    & 0     & 7     & 90 \\
  2011& 74    & 0     & 12    & 86 \\
  \midrule
  Total & 1097 & 52   & 61    & 1210 \\
\bottomrule
\end{tabular*}
\end{table}
\blurb\blurb\blurb\blurb
\end{document} 
8
  • I want to spread the table over two columns instead of being shown in one column.
    – Ahmed Arif
    Commented Dec 23, 2016 at 16:49
  • 1
    but for this is no reason! natural width of your table is smaller than width of one column. If you persist to have so wide table, than \begin{figure*} ... \end{figure*} will give what you like to have, of course, on the top of the next page.
    – Zarko
    Commented Dec 23, 2016 at 17:05
  • @AhmedArif - I've provided an addendum to address your follow-up comment. The only changes to the code I posted initially is to switch from a table to a table* environment and to use \textwidth instead of \columnwidth in the first argument of tabular*.
    – Mico
    Commented Dec 23, 2016 at 20:59
  • @Mico, How to make the last table small on page? Commented Sep 24, 2020 at 18:27
  • @AadityaUra - I'm afraid I don't understand your question. The table was designed in a single column, and it does just that. Please clarify your question.
    – Mico
    Commented Sep 24, 2020 at 19:25
10

If you persist to span your table over two columns, despite its natural width is smaller than one column width, than you should use

\begin{table*}
...
\end{table*}

(regarding this, your question is duplicate to many question here...). This tables can appear only on top of the (next) page. To force it to be in bottom of current page, you need to load package stfloats:

\documentclass[11pt,twocolumn,conference]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[latin9]{inputenc}
\usepackage[english]{babel}
\usepackage[final]{graphicx}
\usepackage{natbib}
\setlength{\bibsep}{0.0pt}
\usepackage{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm }
\usepackage{caption}% <-- added
\captionsetup[table]{skip = 3pt}
\usepackage{}
\usepackage[para]{threeparttable}
\usepackage{array,booktabs,longtable,tabularx,tabulary}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{ltablex}
\usepackage{siunitx}
\usepackage{caption}%
\setlength{\LTcapwidth}{7in}
\usepackage[flushleft]{threeparttablex}

\usepackage{stfloats}
\usepackage{lipsum}

\begin{document}
\section{INTRODUCTION}
\lipsum[1]
    \begin{table*}[b]
    \centering
%        \footnotesize
\caption{Year Wise Treatment Frequencies}
    \label{tab:freq}
\caption*{\footnotesize
      This table provides the frequencies
            }
  \begin{tabular*}{\linewidth}{S @{\extracolsep{\fill}}
                            *{4}{S[group-separator = {,},
                                   group-minimum-digits = 4
                                    ]}}
      \toprule
  {Year} & {Nones} & {Option 1} & {Option 2} & {Total}  \\
      \midrule
  2001       & 126   & 16    & 2     & 144 \\
  2002       & 114   & 9     & 4     & 127 \\
  2003       & 115   & 7     & 1     & 123 \\
  2004       & 114   & 6     & 4     & 124 \\
  2005       & 104   & 5     & 8     & 117 \\
  2006       & 96    & 3     & 6     & 105 \\
  2007       & 93    & 2     & 4     & 99 \\
  2008       & 93    & 2     & 2     & 97 \\
  2009       & 85    & 2     & 11    & 98 \\
  2010       & 83    & 0     & 7     & 90 \\
  2011       & 74    & 0     & 12    & 86 \\
      \midrule
      Total & 1097 & 52    & 61    & 1210 \\
      \bottomrule
  \end{tabular*}
\end{table*}
\lipsum
\end{document}

which gives:

enter image description here

In above table for column formatting the siunitx column type S is used. To my opinion the result is very, very ugly ... Well, maybe your real table need to be so wide, who knows :)

You must log in to answer this question.

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