抑制列條目和新定義的列分隔符號之間的空格

抑制列條目和新定義的列分隔符號之間的空格

正如另一篇文章中所解釋的,我定義了一個列分隔符,如下所示:

\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}

使用普通的分隔符,|我通常@{}將列條目一個接一個地輸入。這不再起作用:有沒有辦法讓它也與新的分隔符號一起工作?

作為最小的完整工作範例,在第一個表中,文字Round與分隔符號間隔開,而在第二個表中,文字位於其旁邊:

\documentclass[a4paper,twoside]{article}

\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{calc}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{multicol}
\usepackage{pslatex}
\usepackage{apalike}
\usepackage{ulem}
\usepackage{tabularx}
\makeatletter
\newcommand{\thickhline}{%
    \noalign {\ifnum 0=`}\fi \hrule height 1.2pt
    \futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
\makeatother

\begin{document}

\title{Title}
\maketitle
\begin{table} % Add the following just after the closing bracket on this line to specify a position for the table on the page: [h], [t], [b] or [p] - these mean: here, top, bottom and on a separate page, respectively
\centering % Centres the table on the page, comment out to left-justify
\tiny
\begin{tabular}{@{}c@{}" c@{ }|@{ }c " c@{}|@{}c  " c@{}|@{}c" c@{}|@{}c} 
%\toprule % Top horizontal line
\textbf{\footnotesize{Round}} & \multicolumn{8}{c}{\textbf{\footnotesize{Test run}}} \\ % Amalgamating several columns into one cell 
%\cline{2-9}
%\cmidrule(l){2-5} % Horizontal line spanning less than the full width of the table - you can add (r) or (l) just before the opening curly bracket to shorten the rule on the left or right side
 & \multicolumn{2}{c"}{\textbf{1}} & \multicolumn{2}{c"}{\textbf{2}} & \multicolumn{2}{c"}{\textbf{3}} & \multicolumn{2}{c}{\textbf{4}}\\ % Column names row
%\cline{2-9}
& devices&users & devices&users & devices&users & devices&users\\
\thickhline

\textbf{1} & $440$                &    $10$    & $440 $               &   $10^2$      & $440$        &           $10^3$     & $440$           &           $ 10^4$ 

\end{tabular}
\caption{Table caption text} 
\label{tab:template} 
\end{table}


\begin{table} 
\centering 
\tiny
\begin{tabular}{@{}c@{}| c@{ }|@{ }c " c@{}|@{}c  " c@{}|@{}c" c@{}|@{}c} 

\textbf{\footnotesize{Round}} & \multicolumn{8}{c}{\textbf{\footnotesize{Test run}}} \\ % Amalgamating several columns into one cell 

 & \multicolumn{2}{c"}{\textbf{1}} & \multicolumn{2}{c"}{\textbf{2}} & \multicolumn{2}{c"}{\textbf{3}} & \multicolumn{2}{c}{\textbf{4}}\\
& devices&users & devices&users & devices&users & devices&users\\
\thickhline

\textbf{1} & $440$                &    $10$    & $440 $               &   $10^2$      & $440$        &           $10^3$     & $440$           &           $ 10^4$ 

\end{tabular}
\caption{Table caption text} 
\label{tab:template} 
\end{table}


\end{document}

答案1

使用

\newcolumntype{"}{!{\vrule width 1pt}}

不是

\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}

!類似於@但不抑制自動\tabcolsep空格,因此相鄰的確實@{}會抑制它。

相關內容