带中间规则的餐桌布置

带中间规则的餐桌布置

我想知道如何将 N_1 、 N_2 和 N_3 放高一点,以便让它们与名称编号一起位于中间,并且我希望中间规则仅在 N_1 、 N_2 和 N_3 之下

\documentclass[review]{elsarticle}
\DeclareGraphicsExtensions{.pdf,.gif,.jpg}

\usepackage{lineno}
\modulolinenumbers[5]
\usepackage{graphicx}
\usepackage{amssymb,amsmath,nccmath}
\usepackage{cclicenses}
%%\usepackage{caption} % is loaded automatically by 'subcaption'
\usepackage{lscape,array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % centered 'p' col.
%%\usepackage{natbib} % is loaded automatically by elsarticle doc class
\usepackage{subcaption}
\usepackage{caption}
\usepackage{framed}  % Framing content
\usepackage{nomencl} % Nomenclature package
\usepackage[font=small,skip=0pt]{caption}
\makenomenclature
\setlength{\nomitemsep}{-\parskip}\usepackage{booktabs,multirow}

%% Load the next two packages *last*:
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}

\journal{Journal of \LaTeX\ Templates}

\bibliographystyle{elsarticle-num}

\begin{document}
\begin{table}[htp]
\centering
\begin{tabular}{ c c c c } 
\toprule
name \\ number & $N_1$ & $N_2$ & $N_3$ \\   
\midrule
1 &  full name age 1 & full name age 2    & full name age 3 \\
2 & full name age 4  & full name age 5     & 
full name age 6    \\
3 & full name age 7   & full name age 8     & 
full name age 9  \\
4 & full name age 10  & full name age 11     & 
full name age 12     \\
\bottomrule
\end{tabular}
\end{table}
\section*{References}

\bibliography{mybibfile}

\end{document}

答案1

您可以尝试这个解决方案:

\begin{table}[htp]
\centering
\begin{tabular}{ c c c c } 
\toprule
name & \multirow{2}{*}{$N_1$} & \multirow{2}{*}{$N_2$} & \multirow{2}{*}{$N_3$} \\   
number & & & \\
\cmidrule{2-4}
1 & full name age 1  & full name age 2  & full name age 3  \\
2 & full name age 4  & full name age 5  & full name age 6  \\
3 & full name age 7  & full name age 8  & full name age 9  \\
4 & full name age 10 & full name age 11 & full name age 12 \\
\bottomrule
\end{tabular}
\end{table}

您将需要\usepackage{multirow}在您的序言中。

答案2

最简单的方法是使用makecell包:同名命令允许在标准单元格中换行,并且默认将其内容水平和垂直居中:

\documentclass[review]{elsarticle}
\DeclareGraphicsExtensions{.pdf,.gif,.jpg}

\usepackage{lineno}
\modulolinenumbers[5]
\usepackage{graphicx}
\usepackage{amssymb, mathtools, nccmath}
%\usepackage{cclicenses}
%%\usepackage{caption} % is loaded automatically by 'subcaption'
\usepackage{lscape,array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % centered 'p' col.
%%\usepackage{natbib} % is loaded automatically by elsarticle doc class
\usepackage{subcaption}
\usepackage{caption}
\usepackage{framed} % Framing content
\usepackage{nomencl} % Nomenclature package
\usepackage[font=small,skip=0pt]{caption}
\makenomenclature
\setlength{\nomitemsep}{-\parskip}\usepackage{booktabs,multirow, makecell}
\renewcommand{\cellset}{\renewcommand{\arraystretch}{0.5}}

%% Load the next two packages *last*:
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}

\journal{Journal of \LaTeX\ Templates}

\bibliographystyle{elsarticle-num}

\begin{document}

\begin{table}[!htp]
\centering
\begin{tabular}{ c c c c }
\toprule
\makecell{name \\ number} & $N_1$ & $N_2$ & $N_3$ \\
\midrule
1 & full name age 1 & full name age 2 & full name age 3 \\
2 & full name age 4 & full name age 5 &
full name age 6 \\
3 & full name age 7 & full name age 8 &
full name age 9 \\
4 & full name age 10 & full name age 11 &
full name age 12 \\
\bottomrule
\end{tabular}
\end{table}

\end{document} 

在此处输入图片描述

相关内容