剑桥大学出版社使用以下类型的章节标题。
我怎样才能在不使用他们的代码的情况下创建相同的花哨标题?
答案1
titlesec
使用和的一种可能性TikZ
:
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{lipsum}
\titleformat{\chapter}[block]
{\normalfont\huge\bfseries}
{\tikz\node[
font=\huge\bfseries\color{white},
fill=gray!50,
rounded corners=20pt,
minimum height=1.6cm,
text width=3em,
align=center,
inner xsep=0pt] {\parbox{1.5em}{\thechapter\hfill}};%
}
{-1em}
{\tikz\node[
fill=gray,
font=\Large\sffamily\color{white},
minimum height=1.6cm,
text width=\the\dimexpr\textwidth-2em\relax,
align=center,inner xsep=0pt] {#1};%
}
\titleformat{name=\chapter,numberless}[block]
{\normalfont\huge\bfseries}
{\tikz\node[
font=\huge\bfseries\color{white},
fill=gray!50,
rounded corners=20pt,
minimum height=1.6cm,
text width=3em,
align=center,
inner xsep=0pt] {\parbox{1.5em}{\mbox{}\hfill}};%
}
{-1em}
{\tikz\node[
fill=gray,
font=\Large\sffamily\color{white},
minimum height=1.6cm,
text width=\the\dimexpr\textwidth-2em\relax,
align=center,
inner xsep=0pt] {#1};%
}
\begin{document}
\tableofcontents
\chapter{Tomaras-Tsamis-Woodard Solution}
\lipsum[4]
\end{document}
带星号章节的示例:
对于编号章节: