我采用第 399 页中的 Veelo 章节样式代码memman.pdf
并对字体大小和颜色做了一些细微的更改。当我编译时,它会打印单词“Chapter”,但没有章节号。我有两个问题:
为什么不打印章节号?我是不是漏掉了什么?
我如何手动对章节进行编号?例如,打印
\chapter[n]{ABC}
“第 n 章:ABC”
这是 MWE
\documentclass[a4paper, 11pt]{memoir}
\usepackage{graphicx, xcolor}
\usepackage{lipsum}
\makeatletter
\newlength{\numberheight}
\newlength{\barlength}
\makechapterstyle{veelo}{%
\setlength{\afterchapskip}{40pt}
\renewcommand*{\chapterheadstart}{\vspace*{40pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright\color{magenta}}
\renewcommand*{\chapnumfont}{\normalfont\HUGE}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries\flushright\color{cyan}}
\renewcommand*{\printchaptername}{%
\chapnamefont\scshape{\@chapapp}}
\renewcommand*{\chapternamenum}{}
\setlength{\beforechapskip}{18mm}
\setlength{\midchapskip}{\paperwidth}
\addtolength{\midchapskip}{-\textwidth}
\addtolength{\midchapskip}{-\spinemargin}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{\hspace{.8em}%
\resizebox{!}{\numberheight}{\chapnumfont\thechapter}%
\hspace{.8em}%
\rule{\midchapskip}{\beforechapskip}%
}}%
}
\makeatother
\chapterstyle{veelo}
\begin{document}
\chapter{Applications of the Derivative}
\lipsum[2]
\end{document}
答案1
您已将数字大小调整为零维度。
\newlength{\numberheight}
定义长度。默认情况下,该长度为零。由于您没有更改它,因此数字消失了。替换默认尺寸后,数字会重新出现,但您显然可以将其定义\numberheight
为您想要的任何值,然后在重新定义中替换它。
\documentclass[a4paper, 11pt]{memoir}
\usepackage{graphicx, xcolor}
\usepackage{lipsum}
\makeatletter
\newlength{\numberheight}
\newlength{\barlength}
\makechapterstyle{veelo}{%
\setlength{\afterchapskip}{40pt}
\renewcommand*{\chapterheadstart}{\vspace*{40pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright\color{magenta}}
\renewcommand*{\chapnumfont}{\normalfont\HUGE}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries\flushright\color{cyan}}
\renewcommand*{\printchaptername}{%
\chapnamefont\scshape{\@chapapp}}
\renewcommand*{\chapternamenum}{}
\setlength{\beforechapskip}{18mm}
\setlength{\midchapskip}{\paperwidth}
\addtolength{\midchapskip}{-\textwidth}
\addtolength{\midchapskip}{-\spinemargin}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{\hspace{.8em}%
\resizebox{!}{\beforechapskip}{\chapnumfont \thechapter}%
\hspace{.8em}%
\rule{\midchapskip}{\beforechapskip}%
}}%
}
\makeatother
\chapterstyle{veelo}
\begin{document}
\chapter{Applications of the Derivative}
\lipsum[2]
\end{document}
为了避免混淆,我建议使用除“veelo
因为veelo
已经定义”之外的样式名称。这样虽然可以正常工作,但会不必要地引发后续麻烦。