我想做这样的事:
不幸的是,我还没有找到解决方案。有人能帮忙吗?
这是我的桌子的一部分:
\begin{table}[H]
\centering
\begin{tabular}{lccccccc}
\toprule
Parameter & $\epsilon_{1}$ & $\epsilon_{2}$ & $\epsilon_{3}$ &
$\epsilon_{4}$ & $\epsilon_{5}$ & $\epsilon_{6}$ & $\epsilon_{7}$ \\
\midrule
$1.$ & \multicolumn{7}{c}{Error} \\
$2.$ & $3.3714 $& $-2.5266 $& $0.0000 $& $-0.0000 $& $-0.0000 $& $0.0000
$& $6.3746 $\\
\bottomrule
\end{tabular}
\caption{Sensitivity analysis
\label{table:SensAnalysis}
\end{table}
提前致谢! :-)
答案1
您可以定义一个宏\dashfill
,重复重叠的破折号来填充一些空间。
我还为表格添加了一些建议,使用siunitx
。
该\Error
宏接收要跨越的列数作为参数。
\documentclass{article}
\usepackage{siunitx,booktabs}
\newcommand{\Error}[1]{%
\multicolumn{#1}{c}{\dashfill\quad Error\quad\dashfill}%
}
\newcommand{\dashfill}{%
--\kern-0.2em\leaders\hbox to .25em{\hss--\hss}\hfill\kern-0.2em--%
}
\begin{document}
\begin{table}
\centering
\addtolength{\tabcolsep}{-2pt} % to make the table fit
\begin{tabular}{
l
S[table-format=1.4]
S[table-format=-1.4]
S[table-format=1.4]
S[table-format=-1.4]
S[table-format=-1.4]
S[table-format=1.4]
S[table-format=1.4]
}
\toprule
Parameter & {$\epsilon_{1}$} & {$\epsilon_{2}$} & {$\epsilon_{3}$} &
{$\epsilon_{4}$} & {$\epsilon_{5}$} & {$\epsilon_{6}$} & {$\epsilon_{7}$} \\
\midrule
1. & \Error{7} \\
2. & 3.3714 & -2.5266 & 0.0000 & -0.0000 & -0.0000 & 0.0000& 6.3746 \\
\bottomrule
\end{tabular}
\caption{Sensitivity analysis}
\label{table:SensAnalysis}
\end{table}
\end{document}
避免该[H]
选项。
答案2
像这样吗?
\documentclass{article}
\usepackage{float,booktabs,array}
\newcommand\longemdash{\textemdash\textemdash%
\textemdash\textemdash\textemdash\textemdash%
\textemdash\textemdash\textemdash\textemdash}
\begin{document}
\begin{table}[H]
\centering
$\begin{array}{@{} >{$}l<{$} *{7}{c} @{}}
\toprule
Parameter & \epsilon_{1} & \epsilon_{2} & \epsilon_{3}
& \epsilon_{4} & \epsilon_{5} & \epsilon_{6}
& \epsilon_{7} \\
\midrule
1. & \multicolumn{7}{>{$}c<{$}}{\longemdash\qquad Error\qquad\longemdash} \\
2. & 3.3714 & -2.5266 & 0.0000 & -0.0000 & -0.0000 & 0.0000 & 6.3746 \\
\bottomrule
\end{array}$
\caption{Sensitivity analysis} \label{table:SensAnalysis}
\end{table}
\end{document}
答案3
像这样,用booktabs
?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{siunitx,booktabs,caption}
\begin{document}
\begin{table}
\centering\setlength{\aboverulesep}{0pt}\setlength{\belowrulesep}{0pt}
\setlength{\extrarowheight}{2pt}
\begin{tabular}{l!{\vrule width \heavyrulewidth}*{7}{>{$}c<{$}}}
& \\[-1.5ex]
\toprule
Parameter & \epsilon_{1} & \epsilon_{2} & \epsilon_{3} & \epsilon_{4} & \epsilon_{5} & \epsilon_{6} & \epsilon_{7} \\
1. & \multicolumn{7}{c}{Error} \\[-1.5ex]
\cmidrule(lr{-0.8em}){2-4}\cmidrule(l{-0.8em}r){6-8}
\addlinespace[\dimexpr1.5ex-\cmidrulewidth]
2. & 3.3714 & -2.5266 & 0.0000 & -0.0000 & -0.0000 & 0.0000 & 6.3746 \\
3. & \multicolumn{7}{c}{Error} \\[-1.5ex]
\cmidrule(lr{-0.8em}){2-4}\cmidrule(l{-0.8em}r){6-8}
\addlinespace[\dimexpr1.5ex-\cmidrulewidth]
\end{tabular}
\caption{Sensitivity analysis}
\label{table:SensAnalysis}
\end{table}
\end{document}