# Inconsistent math font size in table cell with dcolumn

Some cells in my table contain numbers that have to be aligned around the decimal separator. So, I use dcolumn to produce the desired alignment. Some of the cells, however, have to be written out with a smaller font size while keeping the same alignment around the decimal separator. Unfortunately, these latter cells display an inconsistent behavior in their font size: the font size remains smaller up to the decimal separator, while returning to the normal font size in the subsequent digits. I produce hereby a MWE using the standalone class for mere purposes of representation.

I have already attempted some alternatives, for instance using the package relsize and its related command \mathsmaller. None of my numerous attempts took me anywhere. Moreover, I could not find this type of issue being documented anywhere else.

Can anybody help solve this inconsistency in the font size?

% Minimal Working Example
\documentclass[varwidth=\maxdimen]{standalone}
\usepackage{multicol}
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{.}{D{.}{.}{2.3}}

\begin{document}

\begin{table}
\begin{tabular}{c.}
Item 1  & -0.522 \\
\scriptsize(Item 2)  & \scriptstyle 0.001
\end{tabular}
\end{table}

\end{document}


• the D column type splits the contents on the decimal and then typesets things in a special way. So if you have \foo L.R you end up with SOMETHING{\too L}.{SOMETHING{R} and this \foo never reaches the R part in the typesetting. As an alternative to dcolumn have a look at siunitx, besides typesetting units it also typesets table data, and its font handling is a lot better, though you'd use \scriptsize not \scriptstyle. Dec 9 '21 at 9:01

Adding additional \scriptstyle solves the problem:

\documentclass[varwidth=\maxdimen]{standalone}
\usepackage{multicol}
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{.}{D{.}{.}{2.3}}

\begin{document}

\begin{table}
\begin{tabular}{c.}
Item 1  & -0.522 \\
\scriptsize(Item 2)  & \scriptstyle 0.\scriptstyle001
\end{tabular}
\end{table}

\end{document}


• Sure, but how can that be automatized into a new column type via dcolumn? For instance, one may first define a colum type T which aligns numbers around the separator and then define a further colum type t that simply smallens the font size of T. By means of an example, one could add the column types \newcolumntype{T}{D{.}{.}{2.3}} and \newcolumntype{t}{{\scriptstyle}>T} . Except that the inconsistency highlighted in the question prevents this type of automation. Dec 9 '21 at 9:02

If you're not tied to dcolumn, you could try with siunitx.

\documentclass{article}
\usepackage{siunitx}

\begin{document}

\begin{tabular}{c S[table-format=-1.3]}