我在这里看到过类似的问题。但是,其他的所有代码都是从这里开始的, \begin{tabular}{|c|c|c|c|}
我想避免这种情况。如何消除垂直线之间的空间?
\documentclass[letter,11pt,twoside]{article}
\usepackage{array,siunitx,booktabs}
\usepackage{multirow}
\usepackage{subfig,rotating,longtable,lscape,geometry,layouts}
\usepackage{makecell}
%%%%%%%%%%%%%%%%
\begin{document}
\begin{table}[h!]
\small
\hspace*{-0.3cm}
\begin{tabular*}{\textwidth}{p{1.7cm}
@{\extracolsep{\fill}}
l
*{3}{
S[table-format=4.0]
S[table-format=4.0]
S[table-format=4.0]
}
@{}
}
\par\noindent\rule[-2mm]{16.5cm}{0.3mm} \\
\multicolumn{2}{c|} {} & {\makecell{text}} & {\makecell{text}} & {text} & {text} \\
\par\noindent\rule[0mm]{16.5cm}{0.2mm}\\
\multicolumn{2}{c|} {text} & {text} & {text} & {text} & {text} \\
\vspace{-0.5cm}
\par\noindent\rule[1mm]{16.5cm}{0.3mm}
\end{tabular*}
\vspace{-0.2cm}
\caption{text}
\label{idealized}
\end{table}
\end{document}
非常感谢
答案1
尝试以下方法,而不是所有手动的空格和线条:
\documentclass[letter,11pt,twoside]{article}
\usepackage{array,siunitx,booktabs}
\usepackage{multirow}
\usepackage{subfig,rotating,longtable,lscape,geometry,layouts}
\usepackage{makecell}
%%%%%%%%%%%%%%%%
\begin{document}
\begin{table}[h!]
\small
%\hspace*{-0.3cm}
\begin{tabular*}{\textwidth}{
p{1.7cm}|
@{\extracolsep{\fill}}
*{4}{
S[table-format=4.0]
}
@{}
}
\hline
& {\makecell{text}} & {\makecell{text}} & {text} & {text} \\
\hline
{text} & {text} & {text} & {text} & {text} \\
\hline
\end{tabular*}
%\vspace{-0.2cm}
\caption{text}
\label{idealized}
\end{table}
\end{document}
如果你的表只有 5 列,为什么会有 11 列?
答案2
正如我在评论中提到的,你的问题不清楚...例如,你想用
*{3}{
S[table-format=4.0]
S[table-format=4.0]
S[table-format=4.0]
}
它和
*{0}{S[table-format=4.0]}
S
如果表格主体不包含数字,那么为什么要使用列呢?
对于表格中的水平规则,我定义了一些特殊线,从标准\hline
和cline
到\toprule
,\midrule
并bottomrule
在包和许多其他中定义booktabs
。为什么你使用\rule
不适用于这种用途的东西?
看看下面你的猜测是否正确:
\documentclass[letter,11pt,twoside]{article}
\usepackage{geometry}
\usepackage{siunitx}
\usepackage{rotating}
\usepackage{array,booktabs,longtable,makecell,multirow}
\setcellgapes{3pt} % for more vrtical space around cells contents
% defined in the 'makecell' package
\usepackage{subfig}
\usepackage{lscape}
\begin{document}
\begin{table}[ht]
\makegapedcells % for more vrtical space around cells contents
% defined in the 'makecell' package
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{ p{1.7cm}| @{\extracolsep{\fill}}
l
*{9}{S[table-format=4.0]}
}
\Xhline{1pt} % defined in the 'makecell' package
& some text
& {text} & {text} & {text}
& {text} & {text} & {text}
& {text} & {text} & {text} \\
\hline
text & some text
& 1234 & 1234 & 1234
& 1234 & 1234 & 1234
& 1234 & 1234 & 1234 \\
\Xhline{1pt}
\end{tabular*}
\caption{Caption text}
\label{idealized}
\end{table}
\end{document}