![双列表格](https://linux22.com/image/334811/%E5%8F%8C%E5%88%97%E8%A1%A8%E6%A0%BC.png)
我正在尝试在两列文档中生成表格。但是,该表格也出现在列设置中。我希望该表格出现在浮动环境中的一列设置中。最小工作示例如下:
\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}
答案1
我不确定我是否理解了您的要求,但在我看来,您想要一个占据整列宽度的表格。如果是这种情况,您应该考虑使用将tabular*
宽度设置为 的环境\columnwidth
。哦,不要对同一个对象同时使用 a\caption
和 a指令——这是符号滥用,甚至更糟。\caption*
figure
\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}
附录解决 OP 的后续评论:使表格材料跨度两个都列,您需要在上面显示的代码中更改答案的所有内容是 (a) 将 的两个实例替换{table}
为{table*}
并替换\columnwidth
为\textwidth
。但请注意,LaTeX 只会将 table* 和 figure* 环境放在顶部页面。由于现在空间绰绰有余,footnotesize
因此您可能应该删除这些指令。
第二附录:对环境内容的进一步分析table
表明:(a) 没有必要切换到\footnotesize
;(b) 从使数字信息更具可读性的角度来看,将四个数据列中的数字与其(隐式)小数标记对齐会很有用。这可以通过加载包siunitx
并使用S
列类型来实现。
另外,由于你正在使用IEEEtran
文档类,我会不是加载caption
包,因为这样做会相当果断地修改标题的外观。我认为您使用这个包IEEEtran
是有充分理由的;因此您应该非常小心地更改表格和图形标题的布局和外观。
\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}
答案2
如果您坚持将表格跨越两列,尽管其自然宽度小于一列宽度,那么您应该使用
\begin{table*}
...
\end{table*}
(关于这一点,你的问题与这里的许多问题重复...)。这些表格只能出现在(下一页)的顶部。要强制它位于当前页面的底部,你需要加载包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}
这使:
上面的表格中,列格式使用了siunitx
列类型S
。在我看来,结果非常非常丑陋……好吧,也许你的真实表格需要这么宽,谁知道呢 :)