# \addfontfeatures attribute lost after next fontspec command (like \textbf{})

1. I'm using Linux Libertine font (from system) with XeTeX.
2. In the body, I'm using OldStyle numerals while I want Lining numerals in the tables.
3. I'm typesetting tables that have some cells with \bfseries text.

However, the \addfontfeature setting is only applied to regular text, but not text that is set in \bfseries.

### MWE

\documentclass{scrartcl}
\usepackage{array,booktabs,fontspec}
\setmainfont[Ligatures={Common},Numbers={OldStyle}]{Linux Libertine O}

\begin{document}
\begin{table}
\begin{tabular}{>{\bfseries}ll} \toprule
3 & 3 \\ \bottomrule
\end{tabular}
\end{table}
\end{document}


This yields:

## How can I set \addfontfeatures{Numbers={Lining}} to apply to all text in a group?

-
Have you read section 7.3 Changing the currently selected features of the fontspec documentation (p 19)? – Werner Feb 22 at 21:41
@Werner, I have local copies of the packages I frequently use and apparently, my fontspec documentation was from 2012 v2.2b. I read section 7.2 there but it didn't help, neither would I be able to solve my problem with 7.3 in the current one. – Jakob Feb 22 at 22:57
Yes. Your problem is referenced there, but there's no apparent solution provide, just a suggestion about a future implementation. – Werner Feb 22 at 23:06

The problem is reproducible without a tabular:

\documentclass{scrartcl}
\usepackage{array,booktabs,fontspec}
\setmainfont[Ligatures={Common},Numbers={OldStyle}]{Linux Libertine O}

\begin{document}

1234567890

1234567890

\normalfont 1234567890

\bfseries 1234567890}

1234567890

\end{document}


As you see, the call to \normalfont resets the features back to what's stated at the beginning. The \bfseries command does \fontseries{\bfdefault}\selectfont which nullifies the chosen feature.

My advice is to avoid \addfontfeatures whenever possible, even at the cost of some code duplication.

\documentclass{scrartcl}
\usepackage{array,booktabs,fontspec}
\setmainfont[Ligatures={Common},Numbers={OldStyle}]{Linux Libertine O}
\newfontfamily{\mainlining}[Ligatures=Common,Numbers=Lining]{Linux Libertine O}

\begin{document}

\begin{table}
\mainlining

\begin{tabular}{>{\bfseries}ll}
\toprule
3 & 3 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}


-

Use

 \documentclass{scrartcl}
\usepackage{array,booktabs,fontspec}
\usepackage[oldstyle]{libertine}
\defaultfontfeatures{Ligatures=Common}
\begin{document}

\begin{table}[!htb]
\libertineLF
\begin{tabular}{>{\bfseries}ll} \toprule
123 & 31234 \\ \bottomrule
\end{tabular}
\end{table}

\end{document}


-
Thanks for the suggestion! Instead of loading another package, I prefer to use the fonts from the system. If I remember correctly, there were also some benefits of this over the \usepackage{libertine} approach. Though this case here speaks against it. As I prefer @egreg's approach, I'll take his answer. – Jakob Feb 22 at 23:05
The package loads the the same fonts as with \setmainfont{...}. But it does more, defining all those font families for lining and so on – Herbert Feb 23 at 7:55
Ah, 620MiB of disk space for texlive-fontsextra package (Arch Linux) was probably one of the reasons why I preferred the system font approach. But thanks for pointing that out! – Jakob Feb 23 at 10:26