开普勒字体 ( kpfonts
) 包含一个oldstylenums
选项,可将包括计数器在内的所有数字转换为旧式数字。有没有办法使用类在标题中使用现代衬线数字作为章节和节计数器,report
同时为文档的其余部分保留旧式数字?
示例代码:
\documentclass{report}
\usepackage[oldstylenums]{kpfonts}
\begin{document}
\chapter{Chapter 1234567890}
Here is some random text 1234567890...Here is some random text 1234567890...
\section{Section 1234567890}
Here is some random text 1234567890...Here is some random text 1234567890...
\end{document}
答案1
如果你真的想要它:
\documentclass{report}
\usepackage[oldstylenums]{kpfonts}
\usepackage{etoolbox}
\makeatletter
\DeclareRobustCommand{\useclassicstylenums}{%
\fontfamily{jkp\kp@stylemath\kp@famillem}\selectfont
}
\MakeRobust{\classicstylenums}
\patchcmd{\@makechapterhead}{\normalfont}{\normalfont\useclassicstylenums}{}{}
\patchcmd{\@makeschapterhead}{\normalfont}{\normalfont\useclassicstylenums}{}{}
\patchcmd{\@sect}{\interlinepenalty\@M}{\interlinepenalty\@M\useclassicstylenums}{}{}
\patchcmd{\@ssect}{\interlinepenalty\@M}{\interlinepenalty\@M\useclassicstylenums}{}{}
\renewcommand{\@seccntformat}[1]{\classicstylenums{\csname the#1\endcsname}\quad}
\patchcmd{\l@chapter}{#1}{\classicstylenums{#1}}{}{}
\patchcmd{\@dottedtocline}{#4}{\useclassicstylenums#4}{}{}
\makeatother
\begin{document}
\renewcommand{\contentsname}{Contents 1234567890}% just to test \chapter*
\tableofcontents
\chapter{Chapter 1234567890}
Here is some random text 1234567890...
\section{Section 1234567890}
Here is some random text 1234567890...
\section*{Section 1234567890}
Here is some random text 1234567890...
\subsection{Section 1234567890}
Here is some random text 1234567890...
\end{document}
注意:重新定义\contentsname
只是为了测试一个实例\chapter*
,对于您的文档来说显然没有必要。
答案2
您可以在加载后添加kpfonts
\renewcommand{\thechapter}{\classicstylenums{\arabic{chapter}}}
\renewcommand{\thesection}{\classicstylenums{\arabic{section}}}