
取以下程式碼:
\documentclass{article}
\usepackage[oldstyle, tabular]{libertine}
\usepackage{array}
\newlength{\period}
\settowidth{\period}{9999--9999}
\begin{document}
\begin{tabular}{>{\raggedleft}p{\period}l}
2002--2005 & Put some text and numbers 0123456789 here
\end{tabular}
\end{document}
在此範例中,我將左列的寬度(設定為左側參差不齊)定義為八個表格(即等寬)數字和一個連字符的寬度。
但我真正想要的是如上所述設置左列的寬度,但在第一列之外使用比例數字。下面的範例顯然不起作用,因為這會將文件中的所有數字設定為比例:
\documentclass{article}
\usepackage[oldstyle, proportional]{libertine} % <- change is here only
\usepackage{array}
\newlength{\period}
\settowidth{\period}{9999--9999}
\begin{document}
\begin{tabular}{>{\raggedleft}p{\period}l}
2002--2005 & Put some text and numbers 0123456789 here
\end{tabular}
\end{document}
所以我的問題是:如何將第一列的寬度設定為基於表格數字,然後在文件的該列中使用表格數字,而在其他地方使用比例數字?
如果最好使用 來完成此操作fontspec
,那麼我願意使用它。
答案1
您可以定義一個\tabfig
以表格格式選擇舊式數字的指令:
\documentclass{article}
\usepackage[
oldstyle,
proportional
]{libertine}
\usepackage{array}
\newlength{\period}
\newcommand{\tabfig}{\fontfamily{LinuxLibertineT-TOsF}\selectfont}
\AtBeginDocument{\settowidth{\period}{\tabfig 0000--0000}}
\begin{document}
\begin{tabular}{>{\raggedleft\tabfig}p{\period}l}
2002--2005 & Put some text and numbers 0123456789 here
\end{tabular}
\end{document}
請注意 LaTeX 發出後測量的延遲\normalfont
。