1

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): enter image description here

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): enter image description here

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"?

3

The solution that you refer to has the following:

\makeatletter
\AtBeginDocument{\def\libertine@figurealign{}\libertineOsF}
\newcommand\libertineTabular{\def\libertine@figurealign{T}\libertineLF}
\makeatother

and then it uses \libertineTabular before the tabular environment. That will also work in your case.

\begin{center}\libertineTabular
 \begin{tabular}{S[table-format=4.0] S[table-format=0.2]}

You can also make it automatic with the use of the etoolbox package:

\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}
\newcommand\libertineTabular{\def\libertine@figurealign{T}\libertineLF}
\makeatother
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{\libertineTabular}

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

result

  • I just realised that now the page numbers in the table of contents (+ table of figures etc. are not monospaced anymore). Is there an easy way to change this? – phx Nov 23 '16 at 9:36
  • 1
    I think {\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.