书页标签和行颜色

书页标签和行颜色

您可能知道,当您尝试使用书本标签为行着色时,会出现空白问题。我找到了上述解决方案。

但是,当您使用时@{}\begin{tabular}{@{}*{6}{>$c<$}@{}} 为了抑制边缘的空间),左侧和右侧会残留一些颜色,我不知道如何将其消除。

谢谢

\documentclass[9pt]{extbook}
\usepackage[french]{keystroke}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[table]{xcolor}

\usepackage{array,multicol}

\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage[francais]{babel}

\usepackage{booktabs}



\colorlet{tableheadcolor}{gray!25} % Table header colour = 25% gray
\newcommand{\headcol}{\rowcolor{tableheadcolor}} %he
\colorlet{tablerowcolor}{gray!10} % Table row separator colour = 10% gray
\newcommand{\rowcol}{\rowcolor{tablerowcolor}} %
    % Command \topline consists of a (slightly modified) \toprule followed by a \heavyrule rule of colour tableheadcolor (hence, 2 separate rules)
\newcommand{\topline}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0.5pt}%
            \arrayrulecolor{tableheadcolor}\specialrule{\belowrulesep}{0pt}{-3pt}%
            \arrayrulecolor{black}
            }
    % Command \midline consists of 3 rules (top colour tableheadcolor, middle colour black, bottom colour white)
\newcommand{\midline}{\arrayrulecolor{tableheadcolor}\specialrule{\aboverulesep}{-1pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{-3pt}%
            \arrayrulecolor{black}
            }
    % Command \rowmidlinecw consists of 3 rules (top colour tablerowcolor, middle colour black, bottom colour white)
\newcommand{\rowmidlinecw}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
         \arrayrulecolor{black}}
    % Command \rowmidlinewc consists of 3 rules (top colour white, middle colour black, bottom colour tablerowcolor)
\newcommand{\rowmidlinewc}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{tablerowcolor}\specialrule{\belowrulesep}{0pt}{0pt}%
            \arrayrulecolor{black}}
    % Command \rowmidlinew consists of 1 white rule
\newcommand{\rowmidlinew}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}}
    % Command \rowmidlinec consists of 1 tablerowcolor rule
\newcommand{\rowmidlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}}
    % Command \bottomline consists of 2 rules (top colour
\newcommand{\bottomline}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{-2pt}%
            \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%
\newcommand{\bottomlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%

\begin{document}

\renewcommand{\arraystretch}{1.3}

\begin{tabular}{@{}*{6}{>$c<$}@{}} 
\topline \headcol
x_i&y_i&\Delta[x_{i-1},x_i]&\Delta[x_{i-2},x_{i-1},x_i]&\Delta[x_{i-3},x_{i-2},x_{i-1},x_i]&\Delta[x_{i-4},x_{i-3},x_{i-2},x_{i-1},x_i]\\ \midline
x_0&{y_0}&&&& \\
\rowcol x_1&y_1&{\Delta[x_0,x_1]}&&& \\
x_2&y_2&\Delta[x_1,x_2]&{\Delta[x_0,x_1,x_2]}&& \\
\rowcol x_3&y_3&\Delta[x_2,x_3]&\Delta[x_1,x_2,x_3]&{\Delta[x_0,x_1,x_2,x_3]}& \\
x_4&y_4&\Delta[x_3,x_4]&\Delta[x_2,x_3,x_4]&\Delta[x_1,x_2,x_3,x_4]&{\Delta[x_0,x_1,x_2,x_3,x_4]} \\
\rowcol \vdots &\vdots &\vdots &\vdots &\vdots &\vdots  \\
\bottomline
\end{tabular}
\vspace{1cm}

\begin{tabular}{*{6}{>$c<$}} 
\topline \headcol
x_i&y_i&\Delta[x_{i-1},x_i]&\Delta[x_{i-2},x_{i-1},x_i]&\Delta[x_{i-3},x_{i-2},x_{i-1},x_i]&\Delta[x_{i-4},x_{i-3},x_{i-2},x_{i-1},x_i]\\ \midline
x_0&{y_0}&&&& \\
\rowcol x_1&y_1&{\Delta[x_0,x_1]}&&& \\
x_2&y_2&\Delta[x_1,x_2]&{\Delta[x_0,x_1,x_2]}&& \\
\rowcol x_3&y_3&\Delta[x_2,x_3]&\Delta[x_1,x_2,x_3]&{\Delta[x_0,x_1,x_2,x_3]}& \\
x_4&y_4&\Delta[x_3,x_4]&\Delta[x_2,x_3,x_4]&\Delta[x_1,x_2,x_3,x_4]&{\Delta[x_0,x_1,x_2,x_3,x_4]} \\
\rowcol \vdots &\vdots &\vdots &\vdots &\vdots &\vdots  \\
\bottomline
\end{tabular}
\end{document}

在此处输入图片描述

答案1

你可以使用一些\kern

\begin{tabular}{>{\kern-\tabcolsep}*{6}{>$c<$}<{\kern-\tabcolsep}}

代码:

\documentclass[9pt]{extbook}
\usepackage[french]{keystroke}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[table]{xcolor}

\usepackage{array,multicol}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[francais]{babel}

\usepackage{booktabs}



\colorlet{tableheadcolor}{gray!25} % Table header colour = 25% gray
\newcommand{\headcol}{\rowcolor{tableheadcolor}} %he
\colorlet{tablerowcolor}{gray!10} % Table row separator colour = 10% gray
\newcommand{\rowcol}{\rowcolor{tablerowcolor}} %
    % Command \topline consists of a (slightly modified) \toprule followed by a \heavyrule rule of colour tableheadcolor (hence, 2 separate rules)
\newcommand{\topline}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0.5pt}%
            \arrayrulecolor{tableheadcolor}\specialrule{\belowrulesep}{0pt}{-3pt}%
            \arrayrulecolor{black}
            }
    % Command \midline consists of 3 rules (top colour tableheadcolor, middle colour black, bottom colour white)
\newcommand{\midline}{\arrayrulecolor{tableheadcolor}\specialrule{\aboverulesep}{-1pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{-3pt}%
            \arrayrulecolor{black}
            }
    % Command \rowmidlinecw consists of 3 rules (top colour tablerowcolor, middle colour black, bottom colour white)
\newcommand{\rowmidlinecw}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
         \arrayrulecolor{black}}
    % Command \rowmidlinewc consists of 3 rules (top colour white, middle colour black, bottom colour tablerowcolor)
\newcommand{\rowmidlinewc}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{tablerowcolor}\specialrule{\belowrulesep}{0pt}{0pt}%
            \arrayrulecolor{black}}
    % Command \rowmidlinew consists of 1 white rule
\newcommand{\rowmidlinew}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}}
    % Command \rowmidlinec consists of 1 tablerowcolor rule
\newcommand{\rowmidlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}}
    % Command \bottomline consists of 2 rules (top colour
\newcommand{\bottomline}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{-2pt}%
            \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%
\newcommand{\bottomlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%

\begin{document}

\renewcommand{\arraystretch}{1.3}

\begin{tabular}{>{\kern-\tabcolsep}*{6}{>$c<$}<{\kern-\tabcolsep}}
\topline \headcol
x_i&y_i&\Delta[x_{i-1},x_i]&\Delta[x_{i-2},x_{i-1},x_i]&\Delta[x_{i-3},x_{i-2},x_{i-1},x_i]&\Delta[x_{i-4},x_{i-3},x_{i-2},x_{i-1},x_i]\\ \midline
x_0&{y_0}&&&& \\
\rowcol x_1&y_1&{\Delta[x_0,x_1]}&&& \\
x_2&y_2&\Delta[x_1,x_2]&{\Delta[x_0,x_1,x_2]}&& \\
\rowcol x_3&y_3&\Delta[x_2,x_3]&\Delta[x_1,x_2,x_3]&{\Delta[x_0,x_1,x_2,x_3]}& \\
x_4&y_4&\Delta[x_3,x_4]&\Delta[x_2,x_3,x_4]&\Delta[x_1,x_2,x_3,x_4]&{\Delta[x_0,x_1,x_2,x_3,x_4]} \\
\rowcol \vdots &\vdots &\vdots &\vdots &\vdots &\vdots  \\
\bottomline
\end{tabular}
\vspace{1cm}

\begin{tabular}{>{\kern-\tabcolsep}*{6}{>$c<$}<{\kern-\tabcolsep}}
\topline \headcol
x_i&y_i&\Delta[x_{i-1},x_i]&\Delta[x_{i-2},x_{i-1},x_i]&\Delta[x_{i-3},x_{i-2},x_{i-1},x_i]&\Delta[x_{i-4},x_{i-3},x_{i-2},x_{i-1},x_i]\\ \midline
x_0&{y_0}&&&& \\
\rowcol x_1&y_1&{\Delta[x_0,x_1]}&&& \\
x_2&y_2&\Delta[x_1,x_2]&{\Delta[x_0,x_1,x_2]}&& \\
\rowcol x_3&y_3&\Delta[x_2,x_3]&\Delta[x_1,x_2,x_3]&{\Delta[x_0,x_1,x_2,x_3]}& \\
x_4&y_4&\Delta[x_3,x_4]&\Delta[x_2,x_3,x_4]&\Delta[x_1,x_2,x_3,x_4]&{\Delta[x_0,x_1,x_2,x_3,x_4]} \\
\rowcol \vdots &\vdots &\vdots &\vdots &\vdots &\vdots  \\
\bottomline
\end{tabular}
\end{document}

在此处输入图片描述

答案2

通过,您{NiceTabular}可以nicematrix直接轻松地获得预期的输出。

\documentclass[9pt]{extbook}
\usepackage{xcolor}

\usepackage{nicematrix}

\usepackage{booktabs}


\begin{document}

\renewcommand{\arraystretch}{1.3}

\begin{NiceTabular}{@{}*{6}{>$c<$}@{}}
\CodeBefore 
    \rowcolor{gray!25}{1} 
    \rowcolors{3}{gray!10}{}
\Body
\toprule 
x_i&y_i&\Delta[x_{i-1},x_i]&\Delta[x_{i-2},x_{i-1},x_i]&\Delta[x_{i-3},x_{i-2},x_{i-1},x_i]&\Delta[x_{i-4},x_{i-3},x_{i-2},x_{i-1},x_i]\\ 
\midrule
x_0&{y_0}&&&& \\
x_1&y_1&{\Delta[x_0,x_1]}&&& \\
x_2&y_2&\Delta[x_1,x_2]&{\Delta[x_0,x_1,x_2]}&& \\
x_3&y_3&\Delta[x_2,x_3]&\Delta[x_1,x_2,x_3]&{\Delta[x_0,x_1,x_2,x_3]}& \\
x_4&y_4&\Delta[x_3,x_4]&\Delta[x_2,x_3,x_4]&\Delta[x_1,x_2,x_3,x_4]&{\Delta[x_0,x_1,x_2,x_3,x_4]} \\
\vdots &\vdots &\vdots &\vdots &\vdots &\vdots  \\
\bottomrule
\end{NiceTabular}

\end{document}

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

上述代码的输出

相关内容