Alinhe os números em itálico na dcolumn

Alinhe os números em itálico na dcolumn

A questão é semelhante a esta:Os decimais na tabela não se alinham com dcolumn quando em negrito

Quero que certos números em uma tabela com dcolumn fiquem em itálico e alinhados com os outros. Tentei algo semelhante ao que foi proposto para números em negrito:

\newcolumntype{I}[3]{>{\textit\DC@{#1}{#2}{#3}}c<{\DC@end}}

No entanto, isso não funciona.

Exemplo:

\documentclass[12pt]{article}
\usepackage{dcolumn}

\newcolumntype{.}{D{.}{.}{-1}}
\makeatletter
\newcolumntype{B}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}}
\makeatother
\begin{document}
    \begin{tabular}{..}
        \hline 
        1.5 & 0.19 \\ 
        \multicolumn{1}{B{.}{.}{-1}}{2.75} & 4.2 \\ 
        3.4 & \textit{8.0} \\ 
        \hline 
    \end{tabular} 
\end{document}

insira a descrição da imagem aqui

Responder1

Provavelmente é mais fácil especificar a fonte duas vezes

insira a descrição da imagem aqui

\documentclass[12pt]{article}
\usepackage{dcolumn}
\newcolumntype{.}{D{.}{.}{-1}}
\makeatletter
\newcolumntype{B}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}}
\makeatother
\begin{document}
    \begin{tabular}{..}
        \hline 
        1.5 & 0.19 \\ 
        \multicolumn{1}{B{.}{.}{-1}}{2.75} & 4.2 \\ 
        3.4 & \mathit{8}.\mathit{0} \\ 
        \hline 
    \end{tabular} 
\end{document}

Responder2

Você pode definir uma nova versão matemática para obter dígitos em itálico, mas primeiro apresentarei uma solução baseada em siunitx(as partes são dehttps://tex.stackexchange.com/a/334323/4427)

\documentclass[12pt]{article}
\usepackage{siunitx,booktabs,etoolbox}

\begin{document}

\begin{table}
\centering

%% local redefinitions
\renewrobustcmd{\bfseries}{\fontseries{b}\selectfont}
\renewrobustcmd{\boldmath}{}

\begin{tabular}{
  S[table-format=1.2,detect-weight,mode=text]
  S[table-format=1.2,detect-weight,mode=text]
}
\toprule
          1.5  &          0.19 \\
\bfseries 2.75 &          4.2  \\
          3.4  & \itshape 8.0  \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

insira a descrição da imagem aqui

Alternativa, com dcolumn:

\documentclass[12pt]{article}
\usepackage{dcolumn}

\DeclareMathVersion{italic}
\SetSymbolFont{operators}{italic}{OT1}{\familydefault}{m}{it}

\newcolumntype{.}{D{.}{.}{-1}}
\makeatletter
\newcolumntype{B}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}}
\newcolumntype{I}[3]{>{\mathversion{italic}\DC@{#1}{#2}{#3}}c<{\DC@end}}
\makeatother
\begin{document}
    \begin{tabular}{..}
        \hline
        1.5 & 0.19 \\
        \multicolumn{1}{B{.}{.}{-1}}{2.75} & 4.2 \\
        3.4 & \multicolumn{1}{I{.}{.}{-1}}{8.0} \\
        \hline
    \end{tabular}
\end{document}

insira a descrição da imagem aqui

Responder3

A mesma ideia de David, mas agrupada em uma macro por conveniência:

\documentclass[12pt]{article}
\usepackage{dcolumn}

\newcolumntype{.}{D{.}{.}{-1}}
\makeatletter
\newcolumntype{B}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}}
\makeatother

% call \mathit separately for integer and decimal parts
\newcommand{\itnum}[2]{\mathit{#1}.{\mathit{#2}}}

\begin{document}
    \begin{tabular}{..}
        \hline 
        1.5 & 0.19 \\ 
        \multicolumn{1}{B{.}{.}{-1}}{2.75} & 4.2 \\ 
        3.4 & \itnum{8}{0} \\ 
        \hline 
    \end{tabular} 

informação relacionada