# \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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9706227779388428, "perplexity": 4186.6015860943735}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-26/segments/1466783396872.10/warc/CC-MAIN-20160624154956-00045-ip-10-164-35-72.ec2.internal.warc.gz"}