4
  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}
  \addfontfeature{Numbers={Lining}}
  \begin{tabular}{>{\bfseries}ll} \toprule
    3 & 3 \\ \bottomrule
  \end{tabular}
\end{table}
\end{document}

This yields:

numerals in <code>\bfseries</code> still are <code>OldStyle</code>

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

3
  • Have you read section 7.3 Changing the currently selected features of the fontspec documentation (p 19)?
    – Werner
    Commented Feb 22, 2016 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
    Commented Feb 22, 2016 at 22:57
  • Yes. Your problem is referenced there, but there's no apparent solution provide, just a suggestion about a future implementation.
    – Werner
    Commented Feb 22, 2016 at 23:06

2 Answers 2

3

The problem is reproducible without a tabular:

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

\begin{document}

1234567890

{\addfontfeatures{Numbers=Lining}

1234567890

\normalfont 1234567890

\bfseries 1234567890}

1234567890

\end{document}

enter image description here

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}

enter image description here

1

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}

enter image description here

3
  • 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
    Commented Feb 22, 2016 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
    – user2478
    Commented Feb 23, 2016 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
    Commented Feb 23, 2016 at 10:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .