I am trying to set a text where monospaced lining figures are used within tables (tabulars, longtable etc.), proportional lining figures in tikz pictures and math environments, as well as proportional oldstyle figures throughout the normal text.
Something similar has been asked before in the this question.
However, I am not quite happy with the answers since they do not work flawless for me. That is why I would like to ask this question again relating to the specific issues I observe.
At the moment I use the following code in my header:
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\makeatletter
\AtBeginDocument{\libertineOsF}
\makeatother
This more or less accomplishes the task. However, please note the 11 at the end of the sentence. There is too much kerning between both single numbers. It might not look a lot, however, I find it rather annoying.
Example a (Correct table, annoying inline figures):

Here is another example where the 11 looks right but I do not have monospaced figures in the table (i.e., the figures do not align in the table anymore):
Example b (Incorrect table, inline figures are ok):

I tried all the solutions proposed in the thread above. However, nothing really helped.
Update:
The solution should make sure that the table of content is unaffected by the changes. The current solution proposed by Piet van Oostrum changes both the chapter/section numbers as well as the page numbers (originally the chapter/section numbers were monospaced oldstyle figures whereby the page numbers where monospaced lining figures).
Here are the MWEs:
Example a:
\documentclass[a4paper,
11pt]{scrbook}
\usepackage{libertine}
\usepackage{siunitx}
\sisetup{
group-digits=true,
group-minimum-digits=4,
add-integer-zero=false,
detect-all = true,
mode=math
}
\usepackage[british]{babel}
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\makeatletter
\AtBeginDocument{\libertineOsF}
\makeatother
\begin{document}
\begin{center}
\begin{tabular}{S[table-format=4.0] S[table-format=0.2]}
\hline
{Big number} & {Small number} \\ \hline
1711 & .22 \\
3333 & .11 \\ \hline
\end{tabular}
\end{center}
This is just some meaningless text where I want to show you, what is going on (see Figure~3; $p < .33$). Really, this text does not mean anything. Nevertheless, it is useful and contains probably more than 55 letters. Here you see the annoying fact with some of the figures: 11.
\end{document}
Example b:
\documentclass[a4paper,
11pt]{scrbook}
\usepackage{libertine}
\usepackage{siunitx}
\sisetup{
group-digits=true,
group-minimum-digits=4,
add-integer-zero=false,
detect-all = true,
mode=math
}
\usepackage[british]{babel}
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\makeatletter
\AtBeginDocument{\def\libertine@figurealign{}\libertineOsF}
\makeatother
\begin{document}
\begin{center}
\begin{tabular}{S[table-format=4.0] S[table-format=0.2]}
\hline
{Big number} & {Small number} \\ \hline
1711 & .22 \\
3333 & .11 \\ \hline
\end{tabular}
\end{center}
This is just some meaningless text where I want to show you, what is going on (see Figure 3; $p < .33$). Really, this text does not mean anything. Nevertheless, it is useful and contains probably more than 55 letters. Here you see the annoying fact with some of the figures: 11.
\end{document}
This might also be a good question for meta: How to ask a question that has already been asked but is not fully answered although it is marked as "answered"?

{\libertineTabular\tableofcontents}and similar for the others, will be the simplest, but then all figures in these tables will be monospaced, not just the page numbers. – Pieter van Oostrum Nov 23 '16 at 10:04