3

I followed this link to change the color of the background on the chapter style in fncychap :

How do I change the color of the background on my chapter style in fncychap? (\usepackage[Bjornstrup]{fncychap})

However, I tried to add a color gradient so the blue at the left of the rectangle is darker than the blue at the right of the rectangle, but I could not. Any suggestions?

1 Answer 1

3

Try this code. The gradient was done using tikz. To have the left side darker change path fading=west, to path fading=east, (and also change the color of the chapter title, see below).

d

\documentclass[a4paper,12pt]{report}

\usepackage[Bjornstrup]{fncychap}

%%% ******************************************************* added
\definecolor{titlechap}{rgb}{0.9,0.9,0.9} % color of the chapter title <<<
\definecolor{numberchap}{rgb}{0.6,0.6,0.6}% color of the chapter number <<<<

\usepackage{tikz}
\usetikzlibrary{fadings,positioning}
\newcommand{\gradient}[1]{
\begin{tikzpicture}
    \node (rect) at (0,0) [fill=blue,,path fading=west,minimum width=\linewidth,minimum height=2.5cm] {};
    \node(title)[above left = 10pt and 10pt of rect.south east, anchor=south east, font=\CTV] {\textcolor{titlechap}{#1}};
    \ifnum \thechapter>0\node[left = 10pt of rect.north east,  anchor=center, font=\CNoV] {\textcolor{numberchap}{\thechapter}};\fi%
\end{tikzpicture}%
\vskip 40pt%
}

\renewcommand{\DOCH}{}
\renewcommand{\DOTI}[1]{\gradient{#1}}
\renewcommand{\DOTIS}[1]{\gradient{#1}}

%%*******************************************************************************
\begin{document}
    
    \tableofcontents   
    \chapter{Introduccion}
    \section{One}   
    \chapter{Technical content}
    \section{Two}
    
\end{document}

This is another variant:

e

%%% ******************************************************* added
\definecolor{titlechap}{rgb}{0.4,0.4,0.4} % color of the chapter title <<<
\definecolor{numberchap}{rgb}{0.6,0.6,0.6}% color of the chapter number <<<<

\usepackage{tikz}
\usetikzlibrary{fadings,positioning}
\newcommand{\gradient}[1]{
\begin{tikzpicture}
    \node (rect) at (0,0) [fill=blue,,path fading=east,minimum width=\linewidth,minimum height=2.5cm] {};
    \node(title)[above left = 10pt and 10pt of rect.south east, anchor=south east, font=\CTV] {\textcolor{titlechap}{#1}};
    \ifnum \thechapter>0\node[left = 10pt of rect.north east,  anchor=center, font=\CNoV] {\textcolor{numberchap}{\thechapter}};\fi%
\end{tikzpicture}%
\vskip 40pt%
}

\renewcommand{\DOCH}{}
\renewcommand{\DOTI}[1]{\gradient{#1}}
\renewcommand{\DOTIS}[1]{\gradient{#1}}

%%*******************************************************************************
1
  • Thanks a lot !!!!
    – Norman
    Aug 21, 2022 at 11:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .