使用 Tikz 自定义章节和部分样式

使用 Tikz 自定义章节和部分样式

如何将章节编号和标题放入指定的框中,并且章节可能是可变的。

\documentclass{book}
\usepackage{fourier}% change to lmodern if fourier is no available
\usepackage{tikz}
\usepackage[explicit]{titlesec}

\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}
\definecolor{mybluen}{RGB}{190,234,253}

\renewcommand\thechapter{\arabic{chapter}}

\newcommand\chapternumfont{% font specification for the number
  \fontsize{380}{130}\color{myblueii}\selectfont%
}

\newcommand\chapternamefont{% font specification for the name "chapter"
  \normalfont\color{white}\scshape\small\bfseries 
}

\titleformat{\chapter}
  {\normalfont\huge\filleft}
  {}
  {20pt}
  {\begin{tikzpicture}[remember picture,overlay]
  \fill[myblueiii] 
    (current page.north west) rectangle ([yshift=-12cm]current page.north east);    
\draw[myblueiii,draw,fill=mybluen] 
    ([xshift=15cm,yshift=-16cm]current page.north west) rectangle ([yshift=-22cm]current page.north east);    
\draw[mybluei] 
    ([xshift=13cm,yshift=-18cm]current page.north west) rectangle ([xshift=-6.6cm,yshift=-17cm]current page.north east);    
\draw[mybluei] 
    ([xshift=13cm,yshift=-20cm]current page.north west) rectangle ([xshift=-6.6cm,yshift=-21cm]current page.north east);    
  \node[
      fill=mybluei,
      text width=2\paperwidth,
      rounded corners=6cm,
      text depth=18cm,
      anchor=center,
      inner sep=0pt] at (current page.north east) (chaptertop)
    {\thechapter};%
    \node[
      anchor=south east,
      inner sep=0pt,
      outer sep=0pt] (chapternum) at ([xshift=-20pt]chaptertop.south) 
    {\chapternumfont\thechapter};
    \node[
      anchor=south,
      inner sep=0pt] (chaptername) at ([yshift=2pt]chapternum.south)   
  {\chapternamefont }; %\rl{Chapter}
    \node[
      anchor=north east,
      align=right,
      inner xsep=0pt] at ([xshift=3cm,yshift=-9cm]chaptername.east|-chapternum.south) 
  {\parbox{.7\textwidth}{\raggedleft#1}};
  \end{tikzpicture}%
  }

\begin{document}

\chapter{Chapter Nema}
\newpage
\section{Section one }
\section{Section two}

\end{document}

在此处输入图片描述

相关内容