Automatic change of the color for each part

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















With reference to a question previously asked,



Replace part of the appendix of Legrand Orange Book with letters of the alphabet instead of arabic numbers



I would like to understand which commands are necessary to alternate or change randomly the colors of each part with between 10 colors chosen at my pleasure.
I have selected only the part of the .tex file that refers to Legrande Orange Book that I considered necessary for the correct compilation of the code that I reported.



To be more clear I would like each part to be coloured, at random, not with the same colour.



Here's an image of two snapshots made with paint.
enter image description here



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackage[svgnames,dvipsnames]xcolor
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%


newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two



enddocument









share|improve this question



















  • 2





    Off-topic: You have to load usepackage[svgnames,dvipsnames]xcolor before usepackagetikz to avoid an Option clash error.

    – Phelype Oleinik
    Jan 12 at 21:21






  • 1





    May I ask why do you want to introduce such a feature? Just because it is possible? Alternating colors for titles? This is not a proof of good typography.

    – Christian Hupfer
    Jan 12 at 21:54











  • At the moment, your document shows apricot-like colored rectangles only

    – Christian Hupfer
    Jan 12 at 21:56











  • @ChristianHupfer I like pastel colors and in my opinion it will also provide a better aesthetic for my book. I simply extrapolated the entire code. In summary, I only took the compilable part.

    – Sebastiano
    Jan 12 at 21:58












  • My code was edited and I put usepackage[svgnames,dvipsnames]xcolor before usepackagetikz and put typography.

    – Sebastiano
    Jan 12 at 22:01
















2















With reference to a question previously asked,



Replace part of the appendix of Legrand Orange Book with letters of the alphabet instead of arabic numbers



I would like to understand which commands are necessary to alternate or change randomly the colors of each part with between 10 colors chosen at my pleasure.
I have selected only the part of the .tex file that refers to Legrande Orange Book that I considered necessary for the correct compilation of the code that I reported.



To be more clear I would like each part to be coloured, at random, not with the same colour.



Here's an image of two snapshots made with paint.
enter image description here



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackage[svgnames,dvipsnames]xcolor
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%


newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two



enddocument









share|improve this question



















  • 2





    Off-topic: You have to load usepackage[svgnames,dvipsnames]xcolor before usepackagetikz to avoid an Option clash error.

    – Phelype Oleinik
    Jan 12 at 21:21






  • 1





    May I ask why do you want to introduce such a feature? Just because it is possible? Alternating colors for titles? This is not a proof of good typography.

    – Christian Hupfer
    Jan 12 at 21:54











  • At the moment, your document shows apricot-like colored rectangles only

    – Christian Hupfer
    Jan 12 at 21:56











  • @ChristianHupfer I like pastel colors and in my opinion it will also provide a better aesthetic for my book. I simply extrapolated the entire code. In summary, I only took the compilable part.

    – Sebastiano
    Jan 12 at 21:58












  • My code was edited and I put usepackage[svgnames,dvipsnames]xcolor before usepackagetikz and put typography.

    – Sebastiano
    Jan 12 at 22:01














2












2








2








With reference to a question previously asked,



Replace part of the appendix of Legrand Orange Book with letters of the alphabet instead of arabic numbers



I would like to understand which commands are necessary to alternate or change randomly the colors of each part with between 10 colors chosen at my pleasure.
I have selected only the part of the .tex file that refers to Legrande Orange Book that I considered necessary for the correct compilation of the code that I reported.



To be more clear I would like each part to be coloured, at random, not with the same colour.



Here's an image of two snapshots made with paint.
enter image description here



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackage[svgnames,dvipsnames]xcolor
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%


newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two



enddocument









share|improve this question
















With reference to a question previously asked,



Replace part of the appendix of Legrand Orange Book with letters of the alphabet instead of arabic numbers



I would like to understand which commands are necessary to alternate or change randomly the colors of each part with between 10 colors chosen at my pleasure.
I have selected only the part of the .tex file that refers to Legrande Orange Book that I considered necessary for the correct compilation of the code that I reported.



To be more clear I would like each part to be coloured, at random, not with the same colour.



Here's an image of two snapshots made with paint.
enter image description here



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackage[svgnames,dvipsnames]xcolor
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%


newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two



enddocument






color typography parts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 12 at 22:01







Sebastiano

















asked Jan 12 at 21:10









SebastianoSebastiano

9,60741858




9,60741858







  • 2





    Off-topic: You have to load usepackage[svgnames,dvipsnames]xcolor before usepackagetikz to avoid an Option clash error.

    – Phelype Oleinik
    Jan 12 at 21:21






  • 1





    May I ask why do you want to introduce such a feature? Just because it is possible? Alternating colors for titles? This is not a proof of good typography.

    – Christian Hupfer
    Jan 12 at 21:54











  • At the moment, your document shows apricot-like colored rectangles only

    – Christian Hupfer
    Jan 12 at 21:56











  • @ChristianHupfer I like pastel colors and in my opinion it will also provide a better aesthetic for my book. I simply extrapolated the entire code. In summary, I only took the compilable part.

    – Sebastiano
    Jan 12 at 21:58












  • My code was edited and I put usepackage[svgnames,dvipsnames]xcolor before usepackagetikz and put typography.

    – Sebastiano
    Jan 12 at 22:01













  • 2





    Off-topic: You have to load usepackage[svgnames,dvipsnames]xcolor before usepackagetikz to avoid an Option clash error.

    – Phelype Oleinik
    Jan 12 at 21:21






  • 1





    May I ask why do you want to introduce such a feature? Just because it is possible? Alternating colors for titles? This is not a proof of good typography.

    – Christian Hupfer
    Jan 12 at 21:54











  • At the moment, your document shows apricot-like colored rectangles only

    – Christian Hupfer
    Jan 12 at 21:56











  • @ChristianHupfer I like pastel colors and in my opinion it will also provide a better aesthetic for my book. I simply extrapolated the entire code. In summary, I only took the compilable part.

    – Sebastiano
    Jan 12 at 21:58












  • My code was edited and I put usepackage[svgnames,dvipsnames]xcolor before usepackagetikz and put typography.

    – Sebastiano
    Jan 12 at 22:01








2




2





Off-topic: You have to load usepackage[svgnames,dvipsnames]xcolor before usepackagetikz to avoid an Option clash error.

– Phelype Oleinik
Jan 12 at 21:21





Off-topic: You have to load usepackage[svgnames,dvipsnames]xcolor before usepackagetikz to avoid an Option clash error.

– Phelype Oleinik
Jan 12 at 21:21




1




1





May I ask why do you want to introduce such a feature? Just because it is possible? Alternating colors for titles? This is not a proof of good typography.

– Christian Hupfer
Jan 12 at 21:54





May I ask why do you want to introduce such a feature? Just because it is possible? Alternating colors for titles? This is not a proof of good typography.

– Christian Hupfer
Jan 12 at 21:54













At the moment, your document shows apricot-like colored rectangles only

– Christian Hupfer
Jan 12 at 21:56





At the moment, your document shows apricot-like colored rectangles only

– Christian Hupfer
Jan 12 at 21:56













@ChristianHupfer I like pastel colors and in my opinion it will also provide a better aesthetic for my book. I simply extrapolated the entire code. In summary, I only took the compilable part.

– Sebastiano
Jan 12 at 21:58






@ChristianHupfer I like pastel colors and in my opinion it will also provide a better aesthetic for my book. I simply extrapolated the entire code. In summary, I only took the compilable part.

– Sebastiano
Jan 12 at 21:58














My code was edited and I put usepackage[svgnames,dvipsnames]xcolor before usepackagetikz and put typography.

– Sebastiano
Jan 12 at 22:01






My code was edited and I put usepackage[svgnames,dvipsnames]xcolor before usepackagetikz and put typography.

– Sebastiano
Jan 12 at 22:01











1 Answer
1






active

oldest

votes


















3














Changing the color on a random base can be done easily with pdflatex or lualatex and applying clist_rand_item:N for example, which contains list of colors.



Use SebastianosColorListRed,..., to store the color names and a colorletocreRandomColor to change from ocre to a random color.



The macro SebastianosRandSeed sets the random number seed, with the given seed 12345678 and the used colors the sequence of part colors is



red, blue, yellow, brown, green (in pastel like variations)



Please note that random numbers are random in the sense that red could be followed by red as well, i.e. there is no guarantee that no repetition will occur.



Please note also that this code does not work with XeLaTeX, since the random number generator code of expl3 is not working with XeLaTeX.



I will update the code ...



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackage[svgnames,dvipsnames]xcolor
usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

usepackagexparse

ExplSyntaxOn

clist_new:N g_sebastiano_color_clist

NewDocumentCommandSebastianosColorList+m
clist_gset:Nn g_sebastiano_color_clist #1


NewExpandableDocumentCommandRandomColor
clist_rand_item:N g_sebastiano_color_clist


NewDocumentCommandSebastianosRandSeed+m
sys_gset_rand_seed:n #1


ExplSyntaxOff


%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%



newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
colorletocreRandomColor
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




SebastianosRandSeed12345678
SebastianosColorListRed,Green,Yellow,Blue,Violet,Brown,Orange


begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two


partPart Three

partPart Four

partPart Five


enddocument





share|improve this answer

























  • For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

    – Sebastiano
    Jan 12 at 22:16










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469877%2fautomatic-change-of-the-color-for-each-part%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Changing the color on a random base can be done easily with pdflatex or lualatex and applying clist_rand_item:N for example, which contains list of colors.



Use SebastianosColorListRed,..., to store the color names and a colorletocreRandomColor to change from ocre to a random color.



The macro SebastianosRandSeed sets the random number seed, with the given seed 12345678 and the used colors the sequence of part colors is



red, blue, yellow, brown, green (in pastel like variations)



Please note that random numbers are random in the sense that red could be followed by red as well, i.e. there is no guarantee that no repetition will occur.



Please note also that this code does not work with XeLaTeX, since the random number generator code of expl3 is not working with XeLaTeX.



I will update the code ...



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackage[svgnames,dvipsnames]xcolor
usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

usepackagexparse

ExplSyntaxOn

clist_new:N g_sebastiano_color_clist

NewDocumentCommandSebastianosColorList+m
clist_gset:Nn g_sebastiano_color_clist #1


NewExpandableDocumentCommandRandomColor
clist_rand_item:N g_sebastiano_color_clist


NewDocumentCommandSebastianosRandSeed+m
sys_gset_rand_seed:n #1


ExplSyntaxOff


%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%



newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
colorletocreRandomColor
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




SebastianosRandSeed12345678
SebastianosColorListRed,Green,Yellow,Blue,Violet,Brown,Orange


begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two


partPart Three

partPart Four

partPart Five


enddocument





share|improve this answer

























  • For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

    – Sebastiano
    Jan 12 at 22:16















3














Changing the color on a random base can be done easily with pdflatex or lualatex and applying clist_rand_item:N for example, which contains list of colors.



Use SebastianosColorListRed,..., to store the color names and a colorletocreRandomColor to change from ocre to a random color.



The macro SebastianosRandSeed sets the random number seed, with the given seed 12345678 and the used colors the sequence of part colors is



red, blue, yellow, brown, green (in pastel like variations)



Please note that random numbers are random in the sense that red could be followed by red as well, i.e. there is no guarantee that no repetition will occur.



Please note also that this code does not work with XeLaTeX, since the random number generator code of expl3 is not working with XeLaTeX.



I will update the code ...



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackage[svgnames,dvipsnames]xcolor
usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

usepackagexparse

ExplSyntaxOn

clist_new:N g_sebastiano_color_clist

NewDocumentCommandSebastianosColorList+m
clist_gset:Nn g_sebastiano_color_clist #1


NewExpandableDocumentCommandRandomColor
clist_rand_item:N g_sebastiano_color_clist


NewDocumentCommandSebastianosRandSeed+m
sys_gset_rand_seed:n #1


ExplSyntaxOff


%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%



newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
colorletocreRandomColor
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




SebastianosRandSeed12345678
SebastianosColorListRed,Green,Yellow,Blue,Violet,Brown,Orange


begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two


partPart Three

partPart Four

partPart Five


enddocument





share|improve this answer

























  • For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

    – Sebastiano
    Jan 12 at 22:16













3












3








3







Changing the color on a random base can be done easily with pdflatex or lualatex and applying clist_rand_item:N for example, which contains list of colors.



Use SebastianosColorListRed,..., to store the color names and a colorletocreRandomColor to change from ocre to a random color.



The macro SebastianosRandSeed sets the random number seed, with the given seed 12345678 and the used colors the sequence of part colors is



red, blue, yellow, brown, green (in pastel like variations)



Please note that random numbers are random in the sense that red could be followed by red as well, i.e. there is no guarantee that no repetition will occur.



Please note also that this code does not work with XeLaTeX, since the random number generator code of expl3 is not working with XeLaTeX.



I will update the code ...



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackage[svgnames,dvipsnames]xcolor
usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

usepackagexparse

ExplSyntaxOn

clist_new:N g_sebastiano_color_clist

NewDocumentCommandSebastianosColorList+m
clist_gset:Nn g_sebastiano_color_clist #1


NewExpandableDocumentCommandRandomColor
clist_rand_item:N g_sebastiano_color_clist


NewDocumentCommandSebastianosRandSeed+m
sys_gset_rand_seed:n #1


ExplSyntaxOff


%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%



newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
colorletocreRandomColor
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




SebastianosRandSeed12345678
SebastianosColorListRed,Green,Yellow,Blue,Violet,Brown,Orange


begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two


partPart Three

partPart Four

partPart Five


enddocument





share|improve this answer















Changing the color on a random base can be done easily with pdflatex or lualatex and applying clist_rand_item:N for example, which contains list of colors.



Use SebastianosColorListRed,..., to store the color names and a colorletocreRandomColor to change from ocre to a random color.



The macro SebastianosRandSeed sets the random number seed, with the given seed 12345678 and the used colors the sequence of part colors is



red, blue, yellow, brown, green (in pastel like variations)



Please note that random numbers are random in the sense that red could be followed by red as well, i.e. there is no guarantee that no repetition will occur.



Please note also that this code does not work with XeLaTeX, since the random number generator code of expl3 is not working with XeLaTeX.



I will update the code ...



documentclass[11pt,fleqn]book % Default font size and left-justified equations

usepackage[svgnames,dvipsnames]xcolor
usepackagegraphicx % Required for including pictures
usepackagelipsum % Inserts dummy text
usepackagetikz % Required for drawing custom shapes
usepackage[english]babel % English language/hyphenation

definecolorocreRGB243,102,25 % Define the orange color used for highlighting throughout the book

%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------

usepackagemathptmx

usepackagexparse

ExplSyntaxOn

clist_new:N g_sebastiano_color_clist

NewDocumentCommandSebastianosColorList+m
clist_gset:Nn g_sebastiano_color_clist #1


NewExpandableDocumentCommandRandomColor
clist_rand_item:N g_sebastiano_color_clist


NewDocumentCommandSebastianosRandSeed+m
sys_gset_rand_seed:n #1


ExplSyntaxOff


%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]biblatex
addbibresourcebibliography.bib % BibTeX bibliography file
defbibheadingbibempty

usepackagecalc % For simpler calculation - used for spacing the index letter headings correctly
usepackagemakeidx % Required to make an index
makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

usepackagetitletoc % Required for manipulating the table of contents

contentsmargin0cm % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
titlecontentspart
[0cm] % Left indentation
addvspace20ptbfseries % Spacing and font options for parts




% Chapter text styling
titlecontentschapter
[1.25cm] % Left indentation
addvspace12ptlargesffamilybfseries % Spacing and font options for chapters
colorocre!60contentslabel[Largethecontentslabel]1.25cmcolorocre % Formatting of numbered sections of this type
colorocre % Formatting of numberless sections of this type
colorocre!60normalsize;titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Section text styling
titlecontentssection
[1.25cm] % Left indentation
addvspace3ptsffamilybfseries % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
hfillcolorblackthecontentspage % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
titlecontentssubsection
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Figure text styling
titlecontentsfigure
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for figures
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

% Table text styling
titlecontentstable
[1.25cm] % Left indentation
addvspace1ptsffamilysmall % Spacing and font options for tables
thecontentslabelhspace*1em % Formatting of numbered sections of this type
% Formatting of numberless sections of this type
titlerule*[.5pc].;thecontentspage % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
titlecontentslchapter
[0em] % Left indentation
addvspace15ptlargesffamilybfseries % Spacing and font options for chapters
colorocrecontentslabel[Largethecontentslabel]1.25cmcolorocre % Chapter number

colorocrenormalsizesffamilybfseries;titlerule*[.5pc].;thecontentspage % Page number

% Section text styling
titlecontentslsection
[0em] % Left indentation
sffamilysmall % Spacing and font options for sections
contentslabel[thecontentslabel]1.25cm % Section number



% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
titlecontentslsubsection
[.5em] % Left indentation
sffamilyfootnotesize % Spacing and font options for subsections
contentslabel[thecontentslabel]1.25cm



%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------

usepackagefancyhdr % Required for header and footer configuration

pagestylefancy % Enable the custom headers and footers

renewcommandchaptermark[1]markbothsffamilynormalsizebfserieschaptername thechapter. #1 % Styling for the current chapter in the header
renewcommandsectionmark[1]markrightsffamilynormalsizethesectionhspace5pt#1 % Styling for the current section in the header

fancyhf % Clear default headers and footers
fancyhead[LE,RO]sffamilynormalsizethepage % Styling for the page number in the header
fancyhead[LO]rightmark % Print the nearest section name on the left side of odd pages
fancyhead[RE]leftmark % Print the current chapter name on the right side of even pages
%fancyfoot[C]thepage % Uncomment to include a footer

renewcommandheadrulewidth0.5pt % Thickness of the rule under the header

fancypagestyleplain% Style for when a plain pagestyle is specified
fancyheadrenewcommandheadrulewidth0pt%


% Removes the header from odd empty pages at the end of chapters
makeatletter
renewcommandcleardoublepage
clearpageifoddc@pageelse
hbox
vspace*fill
thispagestyleempty
newpage
fi




%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

makeatletter
renewcommand@seccntformat[1]llaptextcolorocrecsname the#1endcsnamehspace1em
renewcommandsection@startsectionsection1z@
-4ex @plus -1ex @minus -.4ex
1ex @plus.2ex
normalfontlargesffamilybfseries
renewcommandsubsection@startsection subsection2z@
-3ex @plus -0.1ex @minus -.4ex
0.5ex @plus.2ex
normalfontsffamilybfseries
renewcommandsubsubsection@startsection subsubsection3z@
-2ex @plus -0.1ex @minus -.2ex
.2ex @plus.2ex
normalfontsmallsffamilybfseries
renewcommandparagraph@startsectionparagraph4z@
-2ex @plus-.2ex @minus .2ex
.1ex
normalfontsmallsffamilybfseries

%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------

% Numbered part in the table of contents
newcommand@mypartnumtocformat[2]%
setlengthfboxsep0pt%
noindentcolorboxocre!20strutparbox[c][.7cm]ecartcolorocre!70Largesffamilybfseriescentering#1hskipespcolorboxocre!40strutparbox[c][.7cm]linewidth-ecart-espLargesffamilycentering#2%


% Unnumbered part in the table of contents
newcommand@myparttocformat[1]%
setlengthfboxsep0pt%
noindentcolorboxocre!40strutparbox[c][.7cm]linewidthLargesffamilycentering#1%



newlengthesp
setlengthesp4pt
newlengthecart
setlengthecart1.2cm-esp
newcommandthepartimage%
newcommandpartimage[1]renewcommandthepartimage#1%
def@part[#1]#2%
ifnum c@secnumdepth >-2relax%
refstepcounterpart%
addcontentslinetocparttexorpdfstringprotect@mypartnumtocformatthepart#1partname~thepart --- #1
else%
addcontentslinetocparttexorpdfstringprotect@myparttocformat#1#1%
fi%
startcontents%
markboth%
thispagestyleempty%
colorletocreRandomColor
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north] at (4cm,-3.25cm)colorocre!40fontsize220100sffamilybfseriesthepart;
node[anchor=south east] at (paperwidth-1cm,-paperheight+1cm)parbox[t][t]8.5cm
printcontentsl0setcountertocdepth1% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
;
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#2;
endtikzpicture;
endtikzpicture%
@endpart
def@spart#1%
startcontents%
phantomsection
thispagestyleempty%
begintikzpicture[remember picture,overlay]%
node at (current page.north west)begintikzpicture[remember picture,overlay]%
fill[ocre!20](0cm,0cm) rectangle (paperwidth,-paperheight);
node[anchor=north east] at (paperwidth-1.5cm,-3.25cm)parbox[t][t]15cmstrutraggedleftcolorwhitefontsize3030sffamilybfseries#1;
endtikzpicture;
endtikzpicture
addcontentslinetocparttexorpdfstring%
setlengthfboxsep0pt%
noindentprotectcolorboxocre!40strutprotectparbox[c][.7cm]linewidthLargesffamilyprotectcentering #1quadmbox#1%
@endpart
def@endpartvfilnewpage
if@twoside
if@openright
null
thispagestyleempty%
newpage
fi
fi
if@tempswa
twocolumn
fi

%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
newififusechapterimage
usechapterimagetrue
newcommandthechapterimage%
newcommandchapterimage[1]ifusechapterimagerenewcommandthechapterimage#1fi%
newcommandautodot.
def@makechapterhead#1%
parindent z@ raggedright normalfont
ifnum c@secnumdepth >m@ne
if@mainmatter
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblackthechapterautodot~#1strut;
endtikzpicture;
endtikzpicture
else
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
fifiparvspace*270p@

%-------------------------------------------

def@makeschapterhead#1%
begintikzpicture[remember picture,overlay]
node at (current page.north west)
begintikzpicture[remember picture,overlay]
node[anchor=north west,inner sep=0pt] at (0,0) ifusechapterimageincludegraphics[width=paperwidth]thechapterimagefi;
draw[anchor=west] (Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]strutmakebox[22cm];
draw[anchor=west] (Gm@lmargin+.3cm,-9cm) node hugesffamilybfseriescolorblack#1strut;
endtikzpicture;
endtikzpicture
parvspace*270p@
makeatother

%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------

usepackagehyperref
hypersetuphidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false

usepackagebookmark
bookmarksetup
open,
numbered,
addtohook=%
ifnumbookmarkgetlevel=0 % chapter
bookmarksetupbold%
fi
ifnumbookmarkgetlevel=-1 % part
bookmarksetupcolor=ocre,bold%
fi




SebastianosRandSeed12345678
SebastianosColorListRed,Green,Yellow,Blue,Violet,Brown,Orange


begindocument



%----------------------------------------------------------------------------------------
% PART
%----------------------------------------------------------------------------------------

partPart One
partPart Two


partPart Three

partPart Four

partPart Five


enddocument






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 12 at 22:18

























answered Jan 12 at 22:06









Christian HupferChristian Hupfer

149k14196391




149k14196391












  • For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

    – Sebastiano
    Jan 12 at 22:16

















  • For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

    – Sebastiano
    Jan 12 at 22:16
















For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

– Sebastiano
Jan 12 at 22:16





For me it is extraordinary and the effect is very beautiful indeed beautiful. Thank you very much with all my heart.

– Sebastiano
Jan 12 at 22:16

















draft saved

draft discarded
















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469877%2fautomatic-change-of-the-color-for-each-part%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?