创建章节颜色的函数

创建章节颜色的函数

我正在为课程编写一个项目,我想让每个部分的章节的第一页侧面有不同的颜色。这是我的代码。(我%在问题中加入了(注释)以便代码运行。)

\documentclass[10pt]{book}

\usepackage{geometry}                %Borders of the text
\geometry{
        a4paper,
        total={470pt,660pt},
        left=64pt,
        top=70pt,
        footskip=25pt,
        headsep=25pt,
        voffset=17pt,
        headheight=12.2pt
        }

\usepackage{ifthen}
\usepackage{lmodern}                                    %Whritting in greek
\usepackage{xgreek}                                     
\usepackage{xltxtra}
\setmainfont{CMU Serif} 

\usepackage[pagestyles ,newparttoc, explicit]{titlesec}     %Chapter/Titles design
\usepackage{titletoc}

\usepackage{lipsum}

\usepackage[usenames, dvipsnames]{xcolor}
\usepackage{tikz,pgfplots}                              %Pictures, Graphics and backgrounds
\usepackage{tikzpagenodes} 
\pgfplotsset{compat=newest}
\usepackage{graphicx}
\usepackage[pages=some]{background}
\usetikzlibrary{positioning,calc}
%-----------------------------------------------------------------------
\newcommand{\PartColor}[1]
    {
     \ifthenelse{\equal{#1}{I}}{\colorlet{partcolor}{blue!30!black!80!white}}{}
     \ifthenelse{\equal{#1}{II}}{\colorlet{partcolor}{cyan!30!black!80!white}}{}
     \ifthenelse{\equal{#1}{III}}{\colorlet{partcolor}{green!30!black!80!white}}{}
     }
%-----------------Chapter format----------------------------------------
\titlespacing*{\chapter}{245pt}{-15pt}{0pt}
\titleformat{\chapter}
[display]   
{\bfseries}
 {
 \titlespacing*{\chapter}{0pt}{50pt}{0pt}
 \tikzstyle{mybox} = [circle,                       
 color=blue!30!black!15!white]
 \tikzstyle{input} = [coordinate]
 \begin{tikzpicture}[remember picture,overlay]  
 %\PartColor{\thepart}                      %THE PROBLEM IS HERE
 \fill[bottom color=white,top color=blue!30!black!80!white] 
 (-15,4) .. controls (15,9) and (13,-30) .. (-17,-30)--(10,-30)--(11,9)--(-18,9);
\end{tikzpicture}
\begin{tikzpicture}                                     %chapter and     number fonts
\node [right] (ChapterText) {\fontsize{60}{5}{\selectfont\color{blue!30!black!15!white} Chapter}};
\node [mybox, below right=20pt and -85pt of ChapterText] (box){\fontsize{60}{5}\selectfont\thechapter};
\end{tikzpicture}
}  
{50pt}                                                  %space before Chapter title
{\huge\selectfont\centering #1\vspace{35pt}}
%-----------------------------------------------------------------------

\begin{document}
\part{Cookies}
\chapter{Oreo cookie}
\part{Ducks}
\chapter{Donald Duck}
\part{Dogs}
\chapter{Hot Dog}

\end{document}

但正如我所说的,我希望每个部分都有不同的颜色,所以当我删除时,它%无法读取命令\PartColor{\thepart}。我该怎么做才能在我写入时\chapter{Some Chapter name},函数 \PartColor{}运行并返回一个特定的参数\fill。我也在使用 XeLateX,因为我用希腊语写作。

(抱歉,我的英语不是很好。)

相关内容