基本上,做每章颜色样本但要做两个,每个半英寸高,并且堆叠起来。
就像是\swatches{black}{yellow}
?
答案1
建议:
\documentclass
%[oneside]
{book}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage[
automark,
autooneside=false,
markcase=noupper,
headsepline,
headwidth=\the\textwidth+12mm:-5mm,
]{scrlayer-scrpage}
\clearpairofpagestyles
\rehead{\leftmark}
\lohead{\rightmark}
\ohead{\pagemark}
\renewcommand\chaptermarkformat{}% no chapternumber in header
\setkomafont{pageheadfoot}{\normalfont}
% define new layers
\DeclareNewLayer[
background,
oddpage,
align=tr,
hoffset=\paperwidth,
voffset=0pt,%distance from top
width=1cm,% width of the swatch
height=1in,% height of the swatch
mode=picture,
contents={%
\put(0,\LenToUnit{.5\layerheight}){\textcolor{swatchcolor1}{\rule{\layerwidth}{.5\layerheight}}}%
\putLL{\textcolor{swatchcolor2}{\rule{\layerwidth}{.5\layerheight}}}%
}
]{swatch.odd}
\DeclareNewLayer[
clone=swatch.odd,
evenpage,
align=l,
hoffset=0pt
]{swatch.even}
% add layers to every pagestyle
\AddLayersToPageStyle{@everystyle@}{swatch.odd,swatch.even}
\newcommand\swatchcolors[2]{\colorlet{swatchcolor1}{#1}\colorlet{swatchcolor2}{#2}}
\swatchcolors{white}{white}
\begin{document}
\tableofcontents
\chapter{First chapter}\swatchcolors{black}{yellow}
\section{First section}
\Blindtext[20]
\chapter{Second chapter}\swatchcolors{gray}{orange}
\section{First section}
\Blindtext[20]
\chapter{Third chapter}\swatchcolors{blue!80!black}{purple}
\section{First section}
\Blindtext[20]
\end{document}