改变每个章节的颜色

改变每个章节的颜色

在我的论文中,我在页面的两侧有“缩略图”,即带有章节号的小方块,从侧面可以看到。每个后续章节的缩略图都比前一章的位置低一点。我从网上找到了这个脚本。现在,我还想随着章节号的增加逐渐将颜色从浅变深。我怎样才能自动实现这一点?

制作缩略图的脚本部分如下所示:

\definecolor{julia-green}{RGB}{67,182,75}

%% The lthumb command prints the current chapter number in a thumb index on the
%% left (even) page.
\newcommand*\lthumb{%
    \ifthumb%
        \begin{tikzpicture}[remember picture,overlay]
            \coordinate (top margin) at (0pt,1in+\topmargin+\headheight+\headsep);
            \coordinate (left margin) at (1.1in+\evensidemargin,0pt);
            %% Calculate the corners of the thumb index based on the current
            %% chapter number.
            \coordinate (top left) at ($(current page.north west)-(top margin)-(0pt,\value{chapter}\thumbvspace-\thumbvspace)$);
            \coordinate (bottom right) at ($(top left)+(left margin)-(\thumbhspace,\thumbheight)$);
            %% Shift the left edge to prevent the rounded corner from showing.
            \coordinate (top left) at ($(top left)-(\thumbedge,0pt)$);
            %% Draw the thumb index.
            \colorlet{thumb2}{julia-green}
            \fill[fill=thumb2,rounded corners=\thumbedge](top left) rectangle (bottom right);
            %% Print the chapter number at the center right in the thumb index.
            \coordinate (center right) at ($(bottom right)+(0pt,0.5\thumbheight)$);
            \node at (center right)[anchor=east,inner sep=2\thumbedge]{
                \titlefont\bfseries\color{tudelft-white}
                \fontsize{0.75\thumbheight}{0.75\thumbheight}\selectfont
                \thechapter
            };
        \end{tikzpicture}%
    \fi%
}

我尝试添加类似

\definecolor{julia-green}{RGB}{67,182,$\value{chapter}$}

之前

\colorlet{thumb2}{julia-green}

命令,但这会出现错误。

答案1

这似乎有效:

\documentclass{book}
\usepackage{xcolor}

\begin{document}
\chapter{First}
\definecolor{julia-green}{RGB}{67,182,\arabic{chapter}}
\textcolor{julia-green}{COLOR}
\chapter{Second}
\definecolor{julia-green}{RGB}{67,182,\arabic{chapter}}
\textcolor{julia-green}{COLOR}
\end{document} 

我会预先定义一个调色板并将其纳入\thechapter名称中。

\documentclass{book}
\usepackage{xcolor}

\definecolor{thumb1}{RGB}{67,182,75}
\definecolor{thumb2}{RGB}{100,0,0}% etc.

\begin{document}
\chapter{First}
\textcolor{thumb\thechapter}{COLOR}
\end{document} 

相关内容