我点击此链接更改了 fncychap 中章节样式的背景颜色:
如何在 fncychap 中更改章节样式的背景颜色?(\usepackage[Bjornstrup]{fncychap})
但是,我尝试添加颜色渐变,使矩形左侧的蓝色比矩形右侧的蓝色更深,但做不到。有什么建议吗?
答案1
试试这个代码。渐变是使用 完成的tikz
。要使左侧变暗,请更改path fading=west,
为path fading=east,
(并更改章节标题的颜色,见下文)。
\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}
这是另一种变体:
%%% ******************************************************* 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}}
%%*******************************************************************************