如何制作这种格式的表格

如何制作这种格式的表格

桌子 代码

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{}
\caption*{Comparison between the series solution $[y_{1}(x)]$ and $y_{2}(x)]$ and exact solution $[y_{01}(x)]$ and $y_{02}(x)]$ for $\mu{} = 2.0$, $\varepsilon{} = 10^{−7}$.}
\begin{tabular}{l*{5}{c}}
\toprule
\multicolumn{1}{c}{x}   &\multicolumn{1}{c}{$y_{1}(x)$}   &\multicolumn{1}{c}{$y_{01}(x)$}   &\multicolumn{1}{c}{$y_{2}(x)$}   &\multicolumn{1}{c}{$y_{02}(x)$}   \\
\midrule
&-0.000645   &-0.000645   &-0.000645   \\
&  (-0.83)   &  (-0.83)   &  (-0.39)   \\
&     5035   &     5035   &     5035   \\
\bottomrule
\end{tabular}
\end{table}

答案1

一些意见和建议:

  • 使用threeparttable环境确保标题与相关tabular环境占据相同的宽度。

  • 使用caption包(和\captionsetup说明)来(重新)格式化标题。

  • 确保tabular环境的所有列都自动处于数学模式,并使用该dcolumn包使数字在各自的小数标记上对齐。

  • 可选(未在下面显示的答案中实现):如果表格(以及大概是文档的其余部分)需要使用 Times (New) Roman 字体系列进行排版,我建议您也加载和newtxtextnewtxmath

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs,caption,threeparttable,dcolumn}
\captionsetup{labelfont=bf,labelsep=newline,
              singlelinecheck=false,skip=0.5\baselineskip}
\newcolumntype{d}[1]{D..{#1}}
\newcolumntype{L}{>{$}l<{$}}
\newcommand{\mc}[1]{\multicolumn{1}{@{}>{$}c<{$}@{}}{#1}}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{document}

\begin{table}[htbp]
\centering
\begin{threeparttable}
\caption{Comparison between the series solution $[y_{1}(x)$ and $y_{2}(x)]$ 
    and exact solution $[y_{01}(x)$ and $y_{02}(x)]$, for $\mu= 2.0$ 
    and $\varepsilon= 10^{−7}$.}
\begin{tabular}{L d{2.8} L *{2}{d{2.5}} }
\toprule
x & \mc{y_{1}(x)} & y_{01}(x) & \mc{y_{2}(x)} & \mc{y_{02}(x)} \\
\midrule
0.0 & -4.89{\times}10^{-7} & 0.0 & 1.00000 & 1.00000 \\
0.2 & 0.20000              & 0.2 & 0.95948 & 0.95948 \\
\vdots \\ 
1-\varepsilon & \mc{1-\varepsilon} & 1-\varepsilon & -7.31833 & -7.31776\\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}

\end{document}

相关内容