我有这个表格代码。我想把这个表格放在 ieee 格式的一列中。
代码如下
\documentclass{IEEEtran}
\usepackage[margin=1in]{geometry}
\usepackage{booktabs}
\usepackage{makecell}% <--- added
\begin{document}
\begin{table*}
\centering
\caption{Solution with \texttt{tabular}}
\begin{tabular}{@{} ll *{6}{c} @{}}
\toprule
Heading 1 & State of Health
&\multicolumn{3}{c}{Fasting Value}
&\multicolumn{3}{c}{After Eating}\\
\cmidrule(lr){3-5} \cmidrule(l){6-8}
& & \makecell{Maxxxxxxx\\xxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxx} & Maxxxxxxxxxxxx & lllllllllllllllllLow & 2hrs & 3hrs & 4hrs\\
\midrule
add & Healthy &70 &100 &a &$< 140$ & &\\
\addlinespace %\midrule
del & Pre-Diabetes &101 &126 &a & 140--200 & &\\
\addlinespace %\midrule
mult & Diabetes &$>126$ &N/A &a & $>200$ & &\\
\bottomrule
\end{tabular}
\end{table*}
\end{document}
答案1
\documentclass{IEEEtran}
\usepackage{tabularx,ragged2e,booktabs}
\usepackage{kantlipsum}% dummy text
\newcolumntype{C}{>{\Centering\arraybackslash}X} %
\frenchspacing
\begin{document}
1. \kant[1]
\begin{table}[h]
\setlength{\tabcolsep}{2pt} % a bit more whitespace
\begin{tabularx}{\columnwidth}{@{} ll *{6}{C} @{}}
\toprule
Heading 1
& State of Health
&\multicolumn{3}{c}{Fasting Value}
&\multicolumn{3}{c}{After Eating}\\
\cmidrule(lr){3-5} \cmidrule(l){6-8}
&
& A
& B
& C
& 2hrs
& 3hrs
& 4hrs\\
\midrule
add
& Healthy
&70
&100
&a
&$< 140$
& &\\
\addlinespace %\midrule
del
& Pre-Diabetes
&101
&126
&a
& 140--200
& &\\
\addlinespace %\midrule
mult
& Diabetes
&$>126$
&N/A
&a
& $>200$
& &\\
\bottomrule
\end{tabularx}
\smallskip
A is Maxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
B is Maxxxxxxxxxxxx
C is lllllllllllllllllLow
\caption{Precision results of diabetes for various feature subsets.}
\label{table:new}
\end{table}
3. \kant[9-10]
4. \kant[9]
\end{document}
答案2
按照 的建议IEEEtran
,您可以使用该stfloats
包将表格发送至双列页面的顶部或底部。
顶部
底部
% !TeX TS-program = pdflatex
\documentclass{IEEEtran}
\usepackage[margin=1in]{geometry}
\usepackage{booktabs}
\usepackage{makecell}% <--- added
\usepackage{kantlipsum}% dummy text
\usepackage{stfloats}% added <<<<<<<<<<<<<<<
\begin{document}
1. \kant[1]
2. \kant[11]
\begin{table*}[b] % bottom
\centering
\caption{Solution with \texttt{tabular}}
\begin{tabular}{@{} ll *{6}{c} @{}}
\toprule
Heading 1 & State of Health
&\multicolumn{3}{c}{Fasting Value}
&\multicolumn{3}{c}{After Eating}\\
\cmidrule(lr){3-5} \cmidrule(l){6-8}
& & \makecell{Maxxxxxxx\\xxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxx} & Maxxxxxxxxxxxx & lllllllllllllllllLow & 2hrs & 3hrs & 4hrs\\
\midrule
add & Healthy &70 &100 &a &$< 140$ & &\\
\addlinespace %\midrule
del & Pre-Diabetes &101 &126 &a & 140--200 & &\\
\addlinespace %\midrule
mult & Diabetes &$>126$ &N/A &a & $>200$ & &\\
\bottomrule
\end{tabular}
\end{table*}
3. \kant[9-10]
4. \kant[9]
5. \kant[12]
\end{document}