TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  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?

share|improve this question
    
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
up vote 3 down vote accepted

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

share|improve this answer

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

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.