花式章节风格 - 一种新类型

花式章节风格 - 一种新类型

我找到了一种好看的章节样式,想把它实现到我的书中。有人能帮我写代码吗?章节看起来类似于下面的内容。提前谢谢! 在此处输入图片描述

答案1

从你之前的问题开始花式章节风格 - 自定义,我已经做了一个与您的图像类似的布局。

\documentclass[12pt]{book}
\usepackage{geometry}
\usepackage{miama}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}
\usepackage{lipsum}% for dummy text
\usepackage[inline]{showlabels}% to show the labels
\renewcommand{\showlabelfont}{\small\ttfamily\color{red}}

\usepackage{tikz}
\usetikzlibrary{fadings}
\usetikzlibrary{positioning}
\usetikzlibrary{backgrounds,scopes}
\usepackage{tabularray}
\usepackage{xcolor}

\usepackage[explicit]{titlesec}
\titleformat{\chapter}
  {}
  {}
  {0pt}
  {\makebox[0pt][l]{\hspace{-2pt}\begin{tikzpicture}
  \node[text width=18cm, inner sep=0pt,  outer sep=0pt] (A) {\color{brown!70!black}\fmmfamily\Huge\bfseries\chaptername~\Numberstringnum{\thechapter}};
  \begin{scope}[on background layer]
  \draw[brown, line width=4pt, path fading=east] ([yshift=-3pt]A.base west) --  ([yshift=-3pt, xshift=-30pt]A.base);
  \draw[brown, line width=4pt, path fading=west] ([yshift=-3pt, xshift=-30pt]A.base) -- ([yshift=-3pt]A.base east);
  \end{scope}
  \node[text width=18cm, anchor=north west, inner sep=0pt, orange, outer sep=0pt] (B) at (A.south west) {\begin{tblr}{leftsep=0pt,rightsep=0pt,colspec={X[l,b]Q[r,t]}}
  \Huge\sffamily\bfseries\fontfamily{phv}\selectfont #1&\raisebox{0pt}[0pt][0pt]{\sffamily\bfseries\fontsize{70}{60}\fontfamily{phv}\selectfont\thechapter}\\
  \end{tblr}};
  \draw[brown, line width=4pt, path fading=east] ([yshift=2mm]B.south west) -- ([yshift=2mm]B.south);
   \draw[brown, line width=4pt, path fading=west] ([yshift=2mm]B.south) -- ([yshift=2mm]B.south east);
  \end{tikzpicture}}}
  []

\titleformat{\section}
  {\sffamily\large}
  {}
  {0pt}
  {\textcolor{orange}{\bfseries\thesection\quad\raggedright #1}}
  []

\raggedbottom

\begin{document}
\chapter{Introduction}\label{chs:introduction}
\lipsum[1]
\section{Repetition of High Shool Mechanics}\label{chs:repetition_of_highshool_mechanics}
\lipsum[2]
\section{Repetition of Vector Analysis}\label{chs:repetition_of_vector_analysis}
\lipsum[3]

\chapter[Another]{Another chapter with a long long long title}
\lipsum[1]
\section{A section with a long long long long title}
\lipsum[2]
\section{Another section with a long long long long title}
\lipsum[3]

\chapter[Another chapter]{Another chapter with a long long long long long long long long long long long long title}
\lipsum[1]
\section{A section with a long long long long title}
\lipsum[2]
\section{Another section with a long long long long title}
\lipsum[3]
\end{document}

在此处输入图片描述

无论如何,我想补充一点,在我看来,这种风格一点也不好看。

相关内容