Cmidrule 使用 arraystretch 对齐同一行

Cmidrule 使用 arraystretch 对齐同一行

即使使用 arraystretch,连续的 cmidrule 也需要对齐相同的行(如表的第二部分所示)吗?在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage[table]{xcolor}

% Correct for \cmidrule colour adjustment/vertical skip
\newcommand{\corcmidrule}[1][2pt]{% \corcmidrule[<len>]
  \\[\dimexpr-\normalbaselineskip-\belowrulesep-\aboverulesep-#1\relax]%
}

\begin{document}
\begin{tabular}{lll}
column 1 & column 2 & column 3 \\
  \cmidrule[2pt](lr){1-1}\corcmidrule\arrayrulecolor{blue}%
  \cmidrule[2pt](lr){2-2}\corcmidrule\arrayrulecolor{black}%
  \cmidrule[2pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
\end{tabular}

\begin{tabular}{lll}
column 1 & column 2 & column 3 \\
  \cmidrule[5pt](lr){1-1}\corcmidrule[5pt]\arrayrulecolor{blue}%
  \cmidrule[3pt](lr){2-2}\corcmidrule[3pt]\arrayrulecolor{orange}%
  \cmidrule[7pt](lr){3-3}\arrayrulecolor{black}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
\end{tabular}

\bigskip\bigskip\def\arraystretch{1.4}
\begin{tabular}{lll}
column 1 & column 2 & column 3 \\
  \cmidrule[5pt](lr){1-1}\corcmidrule[5pt]\arrayrulecolor{blue}%
  \cmidrule[3pt](lr){2-2}\corcmidrule[3pt]\arrayrulecolor{orange}%
  \cmidrule[7pt](lr){3-3}\arrayrulecolor{black}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
\end{tabular}

\end{document}

答案1

考虑到\arraystretch的定义中的 的值\corcmidrule

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage[table]{xcolor}

% Correct for \cmidrule colour adjustment/vertical skip
\newcommand{\corcmidrule}[1][2pt]{% \corcmidrule[<len>]
  \\[\dimexpr-\arraystretch\normalbaselineskip-\belowrulesep-\aboverulesep-#1\relax]%
}

\begin{document}
\begin{tabular}{lll}
column 1 & column 2 & column 3 \\
  \cmidrule[2pt](lr){1-1}\corcmidrule\arrayrulecolor{blue}%
  \cmidrule[2pt](lr){2-2}\corcmidrule\arrayrulecolor{black}%
  \cmidrule[2pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
\end{tabular}

\begin{tabular}{lll}
column 1 & column 2 & column 3 \\
  \cmidrule[5pt](lr){1-1}\corcmidrule[5pt]\arrayrulecolor{blue}%
  \cmidrule[3pt](lr){2-2}\corcmidrule[3pt]\arrayrulecolor{orange}%
  \cmidrule[7pt](lr){3-3}\arrayrulecolor{black}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
\end{tabular}

\bigskip\bigskip\def\arraystretch{1.4}


\begin{tabular}{lll}
column 1 & column 2 & column 3 \\
  \cmidrule[5pt](lr){1-1}\corcmidrule[5pt]\arrayrulecolor{blue}%
  \cmidrule[3pt](lr){2-2}\corcmidrule[3pt]\arrayrulecolor{orange}%
  \cmidrule[7pt](lr){3-3}\arrayrulecolor{black}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
text & text & text\\ \cmidrule[0.4pt](lr){1-1}\cmidrule[0.4pt](lr){2-2}\cmidrule[0.4pt](lr){3-3}
\end{tabular}

\end{document}

相关内容