我想要章节编号随着章节标题。 章节编号它应该位于左侧上方。
\documentclass{book}
\usepackage{tikz}
\usepackage{fourier}
\usepackage[explicit,calcwidth]{titlesec}
\usepackage{lipsum}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}
\newlength{\titleheight}
\setlength{\titleheight}{\dimexpr 1in+\topmargin+\headheight+\headsep+4cm}
\titleformat{\chapter}{}{}{0pt}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[myblueiii]
(current page.north west) rectangle ([yshift=-\titleheight]current page.north east);
\node[
fill=mybluei,
text width=2\paperwidth,
rounded corners=6cm,
text height=1.5\titleheight,
anchor=center,
inner sep=0pt] at (current page.north east) (chaptop) {};
\node[above left, inner xsep=0pt] at (chaptop.south)
{\fontsize{90}{90}\color{white}\scshape\bfseries #1};
\end{tikzpicture}%
}
\begin{document}
\chapter{Problem}
\lipsum[1]
\section{Problem Statement 1}
\lipsum[1]
\chapter{Solution}
\section{Solution Statement 1}
\lipsum[1]
\section{Solution Statement 2}
\lipsum[1]
\appendix
\chapter{Appendix}
\lipsum[1]
\chapter{References}
\lipsum[1]
\end{document}
答案1
下面介绍了一个根据或\ifstarredchapter
的使用而打开/关闭的条件。这允许人们放置适当的章节标签,而不需要其他麻烦\chapter*
\chapter
titlesec
内部。
带圆圈的章节编号使用的内容来自自定义带圆圈的数字。
\documentclass{book}
\usepackage{tikz}
\usepackage{fourier}
\usepackage[explicit,calcwidth]{titlesec}
\usepackage{lipsum}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}
\newlength{\titleheight}
\setlength{\titleheight}{\dimexpr 1in+\topmargin+\headheight+\headsep+4cm}
\usetikzlibrary{tikzmark}
\tikzset{
mycircled/.style = {circle,draw,inner sep=0.1em,line width=0.04em}
}
\titleformat{\chapter}{}{}{0pt}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[myblueiii]
(current page.north west) rectangle ([yshift=-\titleheight]current page.north east);
\node[
fill=mybluei,
text width=2\paperwidth,
rounded corners=6cm,
text height=1.5\titleheight,
anchor=center,
inner sep=0pt] at (current page.north east) (chaptop) {};
\node[above left, inner xsep=0pt] at (chaptop.south)
{\fontsize{90}{90}\color{white}\scshape\bfseries #1%
\ifstarredchapter\else
\makebox[0pt][r]{%
\raisebox
{1.2\baselineskip} % Distance above chapter title
{\Huge % Chapter X font size
Chapter~\tikzmarknode[mycircled,white]{C-\thechapter}{\thechapter}}}%
\fi};
\end{tikzpicture}%
}
\makeatletter
\newif\ifstarredchapter
\let\old@chapter\@chapter
\renewcommand{\@chapter}{\starredchapterfalse\old@chapter}
\let\old@schapter\@schapter
\renewcommand{\@schapter}{\starredchaptertrue\old@schapter}
\makeatother
\begin{document}
\chapter*{Intro}
\chapter{Problem}
\lipsum[1]
\section{Problem Statement 1}
\lipsum[1]
\chapter{Solution}
\section{Solution Statement 1}
\lipsum[1]
\section{Solution Statement 2}
\lipsum[1]
\appendix
\chapter{Appendix}
\lipsum[1]
\chapter{References}
\lipsum[1]
\end{document}
元素内的注释\raisebox
显示了在哪里调整标题和标题之间的间隙,以及字体(当前设置为\Huge
)。