\addfontfeatures 屬性在下一個 fontspec 指令後遺失(如 \textbf{})

\addfontfeatures 屬性在下一個 fontspec 指令後遺失(如 \textbf{})
  1. 我正在使用 Linux Libertine 字體(來自系統)XeTeX.
  2. 在正文中,我使用OldStyle數字,而我希望Lining在表格中使用數字。
  3. 我正在排版包含一些帶有\bfseries文字的單元格的表格。

但是,該\addfontfeature設定僅適用於常規文本,而不適用於 中設定的文本\bfseries

微量元素

\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}

這產生:

<code>\bfseries</code> 中的數字還是 <code>OldStyle</code>

如何設定\addfontfeatures{Numbers={Lining}}應用到群組中的所有文字?

答案1

無需表格即可重現問題:

\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}

在此輸入影像描述

如您所見,呼叫將\normalfont功能重設回開頭所述的功能。該\bfseries命令會使\fontseries{\bfdefault}\selectfont所選功能無效。

\addfontfeatures我的建議是盡可能避免,即使以一些程式碼重複為代價。

\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}

在此輸入影像描述

答案2

使用

 \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}

在此輸入影像描述

相關內容