如何在 \chapterstyle{VZ43} 中为线条和标题着色

如何在 \chapterstyle{VZ43} 中为线条和标题着色

我想\chaperstyle{VZ43}在写书中使用。如何用不同的颜色标记垂直线、章节编号框和章节名称?

答案1

根据您的喜好调整颜色:

\documentclass{memoir}
\usepackage{calc,xcolor}

\definecolor{rulecolor}{RGB}{153,51,51}
\definecolor{chapternumcolor}{RGB}{228,154,74}
\colorlet{chaptertitlecolor}{magenta!60}
\colorlet{boxcolor}{green!80!black!40}

\newif\ifNoChapNumber
\newcommand\Vlines{%
\def\VL{\textcolor{rulecolor}{\rule[-2cm]{1pt}{5cm}}\hspace{1mm}\relax}
\VL\VL\VL\VL\VL\VL\VL}
\makeatletter
\setlength\midchapskip{0pt}
\makechapterstyle{VZ43}{
\renewcommand\chapternamenum{}
\renewcommand\printchaptername{}
\renewcommand\printchapternum{}
\renewcommand\chapnumfont{\Huge\bfseries\centering}
\renewcommand\chaptitlefont{\Huge\bfseries\raggedright}
\renewcommand\printchaptertitle[1]{%
\Vlines\hspace*{-2em}%
\begin{tabular}{@{}p{1cm} p{\textwidth-3cm}}%
\ifNoChapNumber\relax\else%
\colorbox{boxcolor}{\color{chapternumcolor}%
\makebox[.8cm]{\chapnumfont\strut \thechapter}}
\fi
& \chaptitlefont\textcolor{chaptertitlecolor}{##1}
\end{tabular}
\NoChapNumberfalse
}
\renewcommand\printchapternonum{\NoChapNumbertrue}
}
\makeatother
\chapterstyle{VZ43}

\begin{document}

\chapter{Test chapter}

\end{document}

如果你想要该类的样式book,你可以使用 Vincent Zoonekynd 对该样式的原始定义,该定义可以在以下网址找到:在此页面并介绍着色命令:

\documentclass{book}
\usepackage{xcolor}

\definecolor{rulecolor}{RGB}{153,51,51}
\definecolor{chapternumcolor}{RGB}{228,154,74}
\colorlet{chaptertitlecolor}{magenta!60}
\colorlet{boxcolor}{green!80!black!40}

\makeatletter
\def\LigneVerticale{{\color{rulecolor}\vrule height 5cm depth 2cm}\hspace{0.1cm}\relax}
\def\LignesVerticales{%
  \let\LV\LigneVerticale\LV\LV\LV\LV\LV\LV\LV\LV\LV\LV}
\def\GrosCarreAvecUnChiffre#1{%
  \rlap{\textcolor{boxcolor}{\vrule height 0.8cm width 1cm depth 0.2cm}}%
  \rlap{\hbox to 1cm{\hss\mbox{\textcolor{chapternumcolor}{#1}}\hss}}%
  \vrule height 0pt width 1cm depth 0pt}

\def\@makechapterhead#1{\hbox{%
    \huge 
    \LignesVerticales
    \hspace{-0.5cm}%
    \GrosCarreAvecUnChiffre{\thechapter}
    \hspace{0.2cm}\hbox{\textcolor{chaptertitlecolor}{#1}}%
}\par\vskip 2cm}
\def\@makeschapterhead#1{\hbox{%
    \huge 
    \LignesVerticales
    %\hspace{0.5cm}%
    \hbox{\textcolor{chaptertitlecolor}{#1}}%
}\par\vskip 2cm}

\begin{document}
\chapter{A test chapter}
\end{document}

在此处输入图片描述

相关内容