I'm using LuaTeX with a font that has proportional, lining and tabular numbers available.
Is it possible to set things up so tables automatically use tabular numbers - but proportional numbers are used in the text?
I'm using LuaTeX with a font that has proportional, lining and tabular numbers available.
Is it possible to set things up so tables automatically use tabular numbers - but proportional numbers are used in the text?
Yes, please provide an MWE so we know more about your specific situation. If for now we assume you're using fontspec like most people, what you're looking for is pretty easily done. I'd use the \AtBeginEnvironment from the etoolbox package to automatically invoke a font change at the begin of every tabular. This is a matter of just one line:
\AtBeginEnvironment{tabular}{\setmainfont[Numbers={OldStyle,Monospaced}]{Minion Pro}}
so, as figure style selection is already implemented in fontspec, there is no need for an additional package -- etoolbox is likely to get loaded by other common packages anyways (biblatex etc.). Here's the complete example:
\documentclass{article}
\usepackage{fontspec, etoolbox}
\setmainfont[Numbers={OldStyle,Proportional}]{Minion Pro}
\AtBeginEnvironment{tabular}{\setmainfont[Numbers={OldStyle,Monospaced}]{Minion Pro}}
\begin{document}
\raggedright
12345\\
00000
\begin{table}[h]
\begin{tabular}{l}
12345\\
00000\\
\end{tabular}
\end{table}
12345\\
00000
\end{document}

NB: besides its simplicity, another nice thing here is you can insert additional table formatting as well. E.g., I usually want my tables \footnotesize:
\AtBeginEnvironment{tabular}{\setmainfont{...}\footnotesize}
\addfontfeature{RawFeature=+tnum}. This also would keep the settings regarding lining and old-style numbers. Also, you do not need to change the tabular fix if you change the main font or switch to another font by other means.
– Qrrbrbirlbel
Feb 24 '13 at 17:51
\setmainfont method didn't seem to have any real drawbacks except being a tad less comfortable, and (2) the RawFeature method is a bit more low-level IMHO, making it something I'd suggest only to people who seem to know what they're doing :)
– Nils L
Feb 24 '13 at 19:22
\setmainfont locally that we're not aware of, let us know...
– Nils L
Feb 24 '13 at 19:25
@<user> to notify the author you respond to.) The RawFeatures are explained right alongside the textual options in Table 4 (p. 24) of the fontspec manual. The same effect can be achieved by \addfontfeatures{Numbers=Monospaced}, it keeps the lining/old-style setting as well. The drawback of \setmainfont is that you have to change the font in the fix manually, if you change the (actual) main font. If you export this fix in another file (say your own package) you may have to change the fix every time you switch documents.
– Qrrbrbirlbel
Feb 24 '13 at 20:52