3

I want to use the \chaperstyle{VZ43} in writing my book. How to color the vertical lines, section number box and chapter name in different colors?

  • 1
    And where is that style defined? Which document class do you use? – Gonzalo Medina Sep 18 '15 at 16:38
  • This chapter style is defined in memoir class – SG Sekaran Sep 18 '15 at 16:48
4

Adjust the colors to your liking:

\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}

If you want the style for the book class, you can use the original definition of the style by Vincent Zoonekynd which can be found in this page and introduce the coloring commands:

\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}

enter image description here

  • Instead of using \chapter{\textcolor{red}{Test chapter}} to color the chapter title, give suggestion to use command in preamble. – SG Sekaran Sep 18 '15 at 17:14
  • @SGSekaran It's already in my answer. Use \definecolor or \colorlet to define chaptertitlecolor; in my example it is set to magenta!60, so you can say \colorlet{chaptertitlecolor}{red}. – Gonzalo Medina Sep 18 '15 at 17:31
  • Well, it is smoothly working in \documentclass{memoir}. If I use \documentclass{book}, so many errors are there. Let me know the changes to be done to use in \documentclass{book} – SG Sekaran Sep 19 '15 at 9:41
  • @SGSekaran Please see my updated answer. – Gonzalo Medina Sep 19 '15 at 14:50
  • Well. I am not good in using Latex. I got the expected answer. It is working well. Thanks – SG Sekaran Sep 20 '15 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.