![如何在 fncychap 中的章节样式中获得矩形的颜色渐变?(\usepackage[Bjornstrup]{fncychap})?](https://linux22.com/image/453749/%E5%A6%82%E4%BD%95%E5%9C%A8%20fncychap%20%E4%B8%AD%E7%9A%84%E7%AB%A0%E8%8A%82%E6%A0%B7%E5%BC%8F%E4%B8%AD%E8%8E%B7%E5%BE%97%E7%9F%A9%E5%BD%A2%E7%9A%84%E9%A2%9C%E8%89%B2%E6%B8%90%E5%8F%98%EF%BC%9F(%5Cusepackage%5BBjornstrup%5D%7Bfncychap%7D)%EF%BC%9F.png)
我点击此链接更改了 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}}
%%*******************************************************************************