3

I stumbled across an interesting feature of dcolumn today.

I am using ITC Stone Serif fonts as they have been defined in our corporate design. I prepared an LaTeX document via lualatex, using the Stone fonts. That document also contained a tabular, using a D column from package dcolumn. In the D-columns, LateX uses a different font than the loaded Stone font.

I was able, to replicate this problem, with package bookman (as Stone is copyrighted and hence not reproducible freely).

UPDATE Ulrike Fischer suggested to use package siunitx and instead of a D-Column a S-column. I updated my MWE to incorporate this suggestion. As you can see, the S-column produces the exact same result (in respect to the fonts), as the D-column before. (To be true, there is a slight difference: in the S-column the input had a comma as decimal separator, while the output presents a dot.)

Here is my updated MWE, I added package siunitx and a tabular consisting of column S.

\documentclass[12pt]{article}
\usepackage{bookman}
\usepackage{dcolumn}
\usepackage{siunitx}
\begin{document}
\begin{center}
12,34\\
\begin{tabular}{S}
  12,34
\end{tabular}\\
\begin{tabular}{D{,}{,}{2}}
  12,34
\end{tabular}
\end{center}
\end{document}% 

And this is the updated result.

enter image description here

This is an excerpt from my original problem file, using the stone fonts:

enter image description here

Please compare the digit "2" in that case.

How can I achieve, that the default font (Stone in this case) is used?

2
  • 1
    As the documentation says on its first page "It should be noted that dcolumn always uses math mode for the digits as well as the separator.". Use siunitx and its S-column if you want text mode (easy) or setup the math fonts so that they use your text font for numbers (not so easy). Commented Jun 21, 2017 at 14:55
  • @UlrikeFischer thank you for your suggestion. siunitx doesn't make a difference, instead it transposes the comma from the input to a dot in the output. I believe, I have to do it the hard way, by defining text digits to be the math digits ...
    – Jan
    Commented Jun 22, 2017 at 8:39

1 Answer 1

5

enter image description here

You just need a math setup using the text font for digits:

\documentclass[12pt]{article}
\usepackage{bookman}
\usepackage{dcolumn}
\makeatletter
\newcolumntype{T}[3]{>{\textfont0=\the\font\DC@{#1}{#2}{#3}}c<{\DC@end}}
\makeatother
\begin{document}
\begin{center}
12,34\\
\begin{tabular}{T{,}{,}{2}}
  12,34
\end{tabular}
\end{center}
\end{document}% 

or better to get the comma as well, T{,}{\mbox{,}}{2}

7
  • Hello David, thank you very much for your suggestion. I marked it solved, as it indeed solves the problem given in my MWE. Unfortunately it does not solve my original problem with the Stone fonts I am using. Yet, I do not understand, what the \textfont0=\the\font\DCmagic does and how to adapt it to my fonts.
    – Jan
    Commented Jun 22, 2017 at 8:44
  • (I replaced my package for Stone with package bookman due to copyright reasons.)
    – Jan
    Commented Jun 22, 2017 at 8:54
  • 1
    @Jan math uses up to 16 fonts (0 to 15) and \textfont0=\the\font says that at text (as opposed to subscript) size in font 0 use the current text font at this point. normally digits are set up to use \fam0 so this changes the digits, but if some package changes that they will not. just make a simple document that just uses the package and has $123\showlists$ and see what \fam it uses for digits, change the 0 to whatever number is needed Commented Jun 22, 2017 at 8:57
  • Thank you very much for the explanation. But I cannot get \showlists to work. Unknown command. Even if I strip the document to be \documentclass{article}\begin{document}$123\showlists$\end{document}. I found some other docs on the internet using \showlists but neither is loading an extra package. What is going wrong? Even if I run latex or pdflatex
    – Jan
    Commented Jun 22, 2017 at 9:10
  • @Jan \showlists is a tex primitive it shouldn't be undefined:-) use \documentclass{article} \begin{document} \showoutput$12\showlists$ \end{document} and you should see .\fam0 1 Commented Jun 22, 2017 at 9:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .