I'm trying to get uppercase section titles with uppercase numbers,
but for some reason \addfontfeature
can't be used inside \titleformat
.
Why is that and how could I get this to work?
\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.
|...............................................
Best Answer
The simplest way is to define a new font family:
Note the right position of
\MakeUppercase
(not\uppercase
) and of the font declaration.