我的代码如下。由于文本较大,我的表格超出了页面限制。我试图在单元格中添加文本的下一行。
\documentclass{IEEEtran}
\usepackage[margin=1in]{geometry}
\usepackage{tabularx,booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\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}
& &{Maxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} &{Maxxxxxxxxxxxx} &{lllllllllllllllllLow} &2hrs &3hrs &4hrs\\
%\makecell{Minnnnnn\\ nnnnnnnnnnn}
\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
实际上,所有东西都已经存在,只需要加载makecell
包。
\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}
或者你可以编写自己的版本,例如
\newcommand*{\mymakecell}[2][c]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}