Using package 'libertine' overrides my sans-font with Libertine instead of Biolinum
The problem is \oldstylenums
which switches the font. Just use the fontspec syntax.
\documentclass{book}
\usepackage{fontspec}
\usepackage{libertine}
%\setmainfont{Linux Libertine O}
%\setsansfont{Linux Biolinum O}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\sffamily\bfseries\LARGE}
{\filright \sffamily\mdseries
\fontsize{10em}{0em}\selectfont
{\addfontfeature{Numbers=OldStyle}\thechapter}}
{1em}
{\filright}
\begin{document}
\chapter{Chapter 1}
\end{document}
The fontspec
Way
The libertine
package redefines \oldstylenums{}
to switch the font. You can change back to a definition like the one from fontspec
, which adds the OpenType font feature to the currently-selected font. Note that this is an incompatibility between the libertine
and fontspec
packages!
\documentclass{book}
\usepackage{fontspec}
\usepackage{libertine}
%% \oldstylenums and \liningums will change the style of the current font, as
%% in fontspec, not switch to the serif font, as in libertine.
\renewcommand\oldstylenums[1]{{\addfontfeatures{Numbers=OldStyle}{#1}}}
\renewcommand\liningnums[1]{{\addfontfeatures{Numbers=Lining}{#1}}}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\sffamily\bfseries\LARGE}
{\filright \sffamily\mdseries
\fontsize{10em}{0em}\selectfont
\oldstylenums{\thechapter}}
{1em}
{\filright}
\begin{document}
\chapter{Chapter 1}
\oldstylenums{1234567890} vs. \liningnums{1234567890}.
\end{document}
You could alternatively give the command a new, unambiguous name or save the definitions after loading fontspec
and before loading libertine
.
The libertine
Way
The libertine
package provides a second command, \oldstylenumsf{}
, to switch the font to Biolinum with old-style numbers. You could simply replace \textsf{\oldstylenums{}}
with \oldstylenumsf{}
.
The package defines the \biolinumOsF
font:
\usepackage{libertine}
and
\titleformat{\chapter}[display]
{\normalfont\sffamily\bfseries\LARGE}
{\filright\mdseries\fontsize{10em}{0em}\selectfont
\biolinumOsF\thechapter}
{1em}
{\filright}