大写标题和大写数字

大写标题和大写数字

我试图获取带有大写数字的大写章节标题,但由于某种原因\addfontfeature无法在 中使用\titleformat。这是为什么?我该如何实现它?

\documentclass{article}
\usepackage{fontspec}
\usepackage{titlesec}

\setmainfont{ebgaramond}

\titleformat{\section}{\filcenter\uppercase}
  {\addfontfeature{Numbers=Lining}\thesection. }{0pt}{}

\begin{document}
\section{Uppercase numbers}
Uppercase letters should be accompanied by uppercase numbers.
\end{document}

>

ERROR: LaTeX error: "kernel/key-unknown"

--- TeX said ---
! 
! The key 'fontspec/NUMBERS' is unknown and is being ignored.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.10 \section{Uppercase numbers}

--- HELP ---
From the .log file...

|'''''''''''''''''''''''''''''''''''''''''''''''
| The module 'fontspec' does not have a key called 'fontspec/NUMBERS'.
| Check that you have spelled the key name correctly.
|...............................................

答案1

最简单的方法是定义一个新的字体系列:

\documentclass{article}
\usepackage{fontspec}
\usepackage{titlesec}

\setmainfont{EB Garamond}
\newfontfamily{\titlefont}{EB Garamond}[Numbers=Lining]

\titleformat{\section}
  {\filcenter\titlefont}
  {\thesection. }
  {0pt}
  {\MakeUppercase}

\begin{document}
\section{Uppercase numbers}
Uppercase letters should be accompanied by uppercase numbers.
\end{document}

在此处输入图片描述

\MakeUppercase注意(不是\uppercase)和字体声明的正确位置。

相关内容