规则、颜色框、空间

规则、颜色框、空间

我对于这个表有三个疑问:

  1. 和描述之间的间距\toprule大于描述和之间的间距\midrule。我该如何改变这一点,使两个间距相等。

  2. 如何在$+$ 2-fold (20-fold)和之间引入垂直规则Rep. 2

  3. 我怎样才能使蓝色空白不覆盖文本并且空白不超出表格的边缘

\documentclass[a4paper, 11pt]{article}
\usepackage[left=2cm,top=2cm,right=2cm, bottom=2cm]{geometry}
\usepackage[utf8]{inputenc} 

% color
\usepackage[dvipsnames, table,x11names]{xcolor}
\usepackage[singlespacing]{setspace}
\usepackage{tcolorbox} % box
\definecolor{mintbg}{rgb}{.63,.79,.95} % blue color
\colorlet{lightmintbg}{mintbg!40}


\usepackage{array,multirow,graphicx} 
\usepackage{ragged2e} 
\usepackage{booktabs, tabularx} 

\newcolumntype{C}{>{\scriptsize\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\scriptsize\RaggedRight\hspace{0pt}}m{#1}}
\newlength\colwidth

\begin{document}

\begin{table}
\small
\settowidth\colwidth{time} % set width of 1st col.
\begin{tabularx}{\textwidth}{@{}P{\colwidth}*  {9}{C} @{}}
    \toprule 
 \textbf{Time } & \textbf{Rep. 1}& \textbf{2-fold }& \textbf{$+$ 5-fold (10-fold)} & \textbf{$+$ 2-fold (20-fold)}  & \textbf{Rep. 2}& \textbf{2-fold }& \textbf{$+$ 5-fold (10-fold)} & \textbf{$+$ 2-fold (20-fold)}\\
\midrule
\multirow{3}{*}{\scriptsize\textbf{5}} & 1.1 & & & & 2.1 &\\
\addlinespace
\rowcolor{lightmintbg} & 1.2& & & &  2.2 & & & &\\
\addlinespace
& 1.3& & & &  2.3 &\\
\midrule
\multirow{3}{*}{\scriptsize\textbf{10}}& 1.1& & & & 2.1 &\\
\addlinespace
&1.2& & & &  2.2 &\\
\addlinespace
& 1.3& & & &  2.3 &\\
\midrule
\multirow{3}{*}{\scriptsize\textbf{15}}& 1.1& & & & 2.1 &\\
& 1.2& & & &  2.2 &\\
\addlinespace
& 1.3& & & &  2.3 &\\
\addlinespace
\midrule
\multirow{3}{*}{\scriptsize\textbf{20}} & 1.1& & & & 2.1 &\\
\addlinespace
& 1.2& & & &  2.2 &\\
\addlinespace
& 1.3& & & &  2.3 &\\
\midrule
\multirow{3}{*}{\scriptsize\textbf{30}} & 1.1& & & & 2.1 &\\
\addlinespace
& 1.2& & & &  2.2 &\\
\addlinespace
& 1.3& & & &  2.3 &\\
\midrule
\multirow{3}{*}{\scriptsize\textbf{45}} & 1.1& & & & 2.1 &\\
\addlinespace
& 1.2& & & &  2.2 &\\
\addlinespace
& 1.3& & & &  2.3 &\\
    \bottomrule
\end{tabularx}
\endtabularx
\end{table}

\end{document}

答案1

{NiceTabular*}以下是关于 的建议nicematrix

\documentclass[a4paper, 11pt]{article}
\usepackage[left=2cm,top=2cm,right=2cm, bottom=2cm]{geometry}


\usepackage[dvipsnames, table,x11names]{xcolor}
\definecolor{mintbg}{rgb}{.63,.79,.95}
\colorlet{lightmintbg}{mintbg!40}


\usepackage{booktabs}
\usepackage{nicematrix,tikz}

\begin{document}

\begin{table}
\small
\renewcommand{\arraystretch}{1.4}
\begin{NiceTabular*}{\textwidth}{@{}>{\scriptsize\bfseries}c*{9}{@{\extracolsep{\fill}}c}@{}}[colortbl-like]
\toprule 
\normalsize Time & \bfseries Rep. 1 & \bfseries 2-fold & \Block{}<\bfseries>{$+$ 5-fold\\ (10-fold)} & \Block{}<\bfseries>{$+$ 2-fold\\ (20-fold)}  &
\bfseries Rep. 2 & \bfseries 2-fold & \Block{}<\bfseries>{$+$ 5-fold\\ (10-fold)} & \Block{}<\bfseries>{$+$ 2-fold\\ (20-fold)}\\ 
\midrule
\Block{3-1}{5}& 1.1 & & & & 2.1 &\\
\rowcolor{lightmintbg} & 1.2& & & &  2.2 & & & &\\
& 1.3& & & &  2.3 &\\
\midrule
\Block{3-1}{10}& 1.1& & & & 2.1 &\\
&1.2& & & &  2.2 &\\
& 1.3& & & &  2.3 &\\
\midrule
\Block{3-1}{15}& 1.1& & & & 2.1 &\\
& 1.2& & & &  2.2 &\\
& 1.3& & & &  2.3 &\\
\midrule
\Block{3-1}{20}& 1.1& & & & 2.1 &\\
& 1.2& & & &  2.2 &\\
& 1.3& & & &  2.3 &\\
\midrule
\Block{3-1}{30}& 1.1& & & & 2.1 &\\
& 1.2& & & &  2.2 &\\
& 1.3& & & &  2.3 &\\
\midrule
\Block{3-1}{45}& 1.1& & & & 2.1 &\\
& 1.2& & & &  2.2 &\\
& 1.3& & & &  2.3 &\\
\bottomrule
\CodeAfter
  \tikz \draw ([xshift=3mm]1-|6) |- ([xshift=3mm]last-|6)  ;
\end{NiceTabular*}
\end{table}

\end{document}

您需要多次编译(因为nicematrix使用 PGF/Tikz 节点)。

上述输出

相关内容