答案1
看着https://www.latextemplates.com/template/the-legrand-orange-book在 中structure.tex
,找到第 434 至 455 行。这些行如下所示:
434 \def\@makechapterhead#1{%
...
455 \fi\fi\par\vspace*{270\p@}}}
将整个 22 行替换为以下内容:
\newlength\chaptertitleheight
\newsavebox\chaptertitlebox
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\setbox\chaptertitlebox=\hbox{%
\parbox{15cm}{\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut}}
\setlength\chaptertitleheight{\dimexpr\ht\chaptertitlebox+\dp\chaptertitlebox}
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt,minimum height=1.2\chaptertitleheight]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node [text width=15cm] {\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt,minimum height=1.2\chaptertitleheight]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node [text width=15cm] {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{270\p@}}}
四个示例页面,分别包含短标题和长标题、未编号标题和编号标题的章节标题: