# SourceSansPro: tabular numbers in a beamer presentation

I'm displaying some data with pgfplotstable in a beamer presentation for my history lesson.

The main font is SourceSansPro. I'm using it with \usepackage[semibold]{sourcesanspro} with default lining numbers for normal text.

But I'd like to use the tabular numbers in the tables. It appears I cannot change the math mode font to use SourceSansPro-TLF whitch is the variation with monospaced numbers. On the following example, it works only for string type columns.

\documentclass{beamer}
\usepackage{pgfplotstable}
\usepackage{sourcesanspro}
\usepackage[T1]{fontenc}
\begin{document}
Louis XIV was born in 1638.

\newcolumntype{i}{>{\fontfamily{SourceSansPro-TLF}\selectfont}r}
\pgfplotstabletypeset[%
fixed,
column type=i,
columns/A/.style={string type},
]{%
A      B      C
123121 121121 718121
456324 314123 192322
789425 141425 212422
101121 161121 223121
}%

He died in 1715.
\end{document}


The result is looking like this:

I'd like tabular numbers of SourceSansPro like in the first column, and thousand separators too, like in the math mode columns.

With unicode-math, you can \addfontfeature in text mode and select tabular figures in math mode. Note that the sourcesanspro package defaults to using OTF on some engines!

\documentclass{beamer}
\usepackage{pgfplotstable}
\usepackage{unicode-math}
\usepackage{sourcesanspro}

\pgfplotsset{compat=1.16}

\setmathfont{Fira Math} % Or your preferred default.
\setmathfont[range=up]{SourceSansPro-Regular.otf}
\setmathfont[range=it]{SourceSansPro-RegularIt.otf}
\setmathfont[range=bfup]{SourceSansPro-Bold.otf}
\setmathfont[range=bfit]{SourceSansPro-BoldIt.otf}

\begin{document}
Louis XIV was born in 1638.

% For most fonts, you would select the font feature Numbers=Tabular (tnum).
% Source Sans Pro is unusual in that it does not support the tnum OpenType
% feature, but makes it the default.  Selecting it will still work, but
% turning the pnum feature off instead suppresses numerous spurious error
% messages.
\pgfplotstabletypeset[%
fixed,
column type=i,
columns/A/.style={string type},
]{%
A      B      C
123121 121121 718121
456324 314123 192322
789425 141425 212422
101121 161121 223121
}%

He died in 1715.
\end{document}


If you want to be able to switch between tabular and proportional numbers in math mode, what you want to do is set up a tabular math version. Unfortunately, as of March 2019, the range= option of \setmathfont does not work properly with math versions.

To briefly repeat what I said in the comment, you would normally add the feature Numbers=Tabular, or tnum. Source Sans Pro is unusual in that it does not support that feature, and you select tabular numbers by turning the pnum feature off. (Numbers = Tabular still works, but gives you many spurious error messages.)

• It works compiling with lualatex. In between I switched to another font but Source Sans pro is still very legible, and your answer very interesting. I wonder if there is some drawback to use \pgfplotsset{compat=1.16} – omisson Mar 9 at 9:14
• @omisson That really depends on whether any future version 1: adds features that it disables in backwards-compatibility mode, 2: you want to be enabled, and 3: makes no changes that break your code. – Davislor Mar 9 at 14:41