![传统而花哨的章节标题](https://linux22.com/image/359607/%E4%BC%A0%E7%BB%9F%E8%80%8C%E8%8A%B1%E5%93%A8%E7%9A%84%E7%AB%A0%E8%8A%82%E6%A0%87%E9%A2%98.png)
答案1
我知道我有点晚了,但无论如何:P
titlesec
我使用了维多利亚装饰品的功能psvectorian
以及其他一些简单的命令。
该psvectorian
包旨在用于 XeLaTeX。要将其与 pdfLaTeX 一起使用,您需要该auto-pst-pdf
包并需要在-shell-escape
启用的情况下编译文档(pdflatex -shell-escape document.tex
)。如果您使用它arara
来构建文档,您只需添加一个指令% arara: pdflatex: { shell: yes }
即可使事情变得更容易。
他们来了:
第一个
章节名称上方有一行,下方有双行,两侧有两个装饰。
\documentclass{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[sc,compact,explicit]{titlesec} % Titlesec for configuring the header
\usepackage{tikz} % Tikz for the double underline (from: https://superuser.com/questions/1136672/double-underline-one-of-them-dashed)
\usepackage{auto-pst-pdf} % Vectorian Ornaments XeTeX auxiliary (from: https://tex.stackexchange.com/questions/253477/how-to-use-psvectorian-with-pdflatex)
\usepackage{psvectorian} % Vectorian Ornaments
\let\clipbox\relax % PSTricks (used by PSVectorian) already defines a \clipbox, so we need this workaround
\usepackage{adjustbox} % Adjustbox to rescale the ornaments (scalebox breaks titlesec for some reason...)
\makeatletter % Defining a overline (from: https://tex.stackexchange.com/questions/24132/overline-outside-of-math-mode)
\newcommand*{\textoverline}[1]{$\overline{\hbox{#1}}\m@th$}
\makeatother
\newcommand{\specdash}[1]{% % Defining a double underline (from: https://superuser.com/questions/1136672/double-underline-one-of-them-dashed)
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
\draw ([yshift=-5pt]todotted.south west) -- ([yshift=-5pt]todotted.south east); % 5 pt below
\draw ([yshift=-7pt]todotted.south west) -- ([yshift=-7pt]todotted.south east); % and 7 pt below
}%
}%
\newcommand{\fancydraw}{% Defining a command to shorten things
\begin{adjustbox}{max height=0.5\baselineskip}% Rescaling to have height of 0.5\baselineskip
\rotatebox{90}{% And rotating 90 degrees
\psvectorian{26}% Ornament n° 26 (http://melusine.eu.org/syracuse/pstricks/vectorian/psvectorian.pdf)
}%
\end{adjustbox}%
}
\titleformat% Formatting the header
{\chapter} % command
[block] % shape - Only managed to get it working with block
{\normalfont\bfseries\sc\huge} % format - Change here as needed
{} % label - Not using labels
{0pt} % sep
{\centering % Centering the title
\textoverline{% Overlined
\specdash{% And double-underlined
\fancydraw% Inserting the ornament
\hspace{1em}% Adding a space to the text
#1% The actual chapter name
\hspace{1em}% Another space after the title
\rotatebox[origin=c]{180}{\fancydraw}% and a 180 degree rotated version of the ornament
}}}%
\begin{document}
\chapter{The beginning}
\blindtext
\end{document}
结果
第二个
“章节编号”、两边各有一条规则的装饰物以及下方的章节名称。
\documentclass{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[sc,compact,explicit]{titlesec} % Titlesec for configuring the header
\usepackage{auto-pst-pdf} % Vectorian Ornaments XeTeX auxiliary (from: https://tex.stackexchange.com/questions/253477/how-to-use-psvectorian-with-pdflatex)
\usepackage{psvectorian} % Vectorian Ornaments
\let\clipbox\relax % PSTricks (used by PSVectorian) already defines a \clipbox, so we need this workaround
\usepackage{adjustbox} % Adjustbox to rescale the ornaments (scalebox breaks titlesec for some reason...)
\newcommand{\otherfancydraw}{% Defining a command to shorten things
\begin{adjustbox}{max height=0.5\baselineskip}% Rescaling to have height of 0.5\baselineskip
\raisebox{-0.25\baselineskip}{
\rotatebox[origin=c]{45}{% And rotating 90 degrees
\psvectorian{7}% Ornament n° 26 (http://melusine.eu.org/syracuse/pstricks/vectorian/psvectorian.pdf)
}}%
\end{adjustbox}%
}
% A command to create a rule centered vertically on the text (from: https://tex.stackexchange.com/questions/15119/draw-horizontal-line-left-and-right-of-some-text-a-single-line/15122#15122)
\newcommand*\ruleline[1]{\par\noindent\raisebox{.8ex}{\makebox[\linewidth]{\hrulefill\hspace{1ex}\raisebox{-.8ex}{#1}\hspace{1ex}\hrulefill}}}
\titleformat% Formatting the header
{\chapter} % command
[block] % shape - Only managed to get it working with block
{\normalfont\bfseries\sc\huge} % format - Change here as needed
{\centering Chapter \thechapter\\} % The Chapter N° label
{0pt} % sep
{\centering \ruleline{\otherfancydraw}\\ % The horizontal rule
\centering #1} % And the actual title
\begin{document}
\chapter{The beginning}
\blindtext
\end{document}