在 latex 中使用 \textbf 时,它会改变里面值的位置

When using \textbf in latex , it change the position of the value inside

我正在尝试使用乳胶显示 table 我的结果,但我在显示时遇到了一些问题:应用粗体时数字没有居中,你能帮我找出原因吗,在代码下面以及它的外观:


\documentclass[a4paper, 11pt, french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}% Include the listings-package
\usepackage{listings} 
\lstset{language=python} 
\usepackage[table]{xcolor}
\usepackage{collcell}
\usepackage{hhline}
\usepackage{pgf}
\usepackage{comment} % habilita el uso de comentarios en varias lineas (\ifx \fi) 
\usepackage{lipsum} %Este paquete genera texto del tipo  Lorem Ipsum. 
\usepackage{fullpage} % cambia el margen
\usepackage{booktabs} % Required for better horizontal rules in tables
\usepackage{fouriernc} % Use the New Century Schoolbook font
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{graphicx}


\begin{document}

\begin{table}[ht]
  \begin{tabular}{lSSS}
    \toprule
    \multirow{2}{*}{Models} &
      \multicolumn{1}{c}{POS} \
      & {N+POS - P}  \ % & {V+N+L-P, S} & {V+N+L-P, S, Ne}
      \midrule
    LinearSVC & 0.44 \ %& \textbf{0.58} & \textbf{0.58}  \
    MultinomialNb & 0.51 \ %& 0.51 & 0.51  \
    LogisticRegression & 0.53 \ %& 0.51 & 0.51  \
    RandomForestClassifier & \textbf{0.55} \ %& 0.56 & 0.57  \
    KNeighborsClassifier & 0.48 \ %& 0.50 & 0.49  \
    \bottomrule
  \end{tabular}
\end{table}


\end{document}

结果是这样的:

如您所见,0.55 与其他值并不完全一致

我认为这与您对列的对齐方式有关。

在您的 \begin{tabular}{lSSS} 行中,您声明了 4 列,即使您注释了其中的 2 列。它对我来说仍然是这样,但考虑到 l 是左对齐的,并且由于粗体效果增加了字母的宽度,如果你向左对齐,它看起来仍然会更大。如果你想让值居中,我建议你使用c而不是S.

我就是这样做的,希望对你有用:

  1. 使用左对齐的解决方案:
\begin{table}[ht]
  \begin{tabular}{ll}
    \toprule
    \multirow{2}{*}{Models} &
      \multicolumn{1}{c}{POS} \
      & {N+POS - P}  \ % & {V+N+L-P, S} & {V+N+L-P, S, Ne}
      \midrule
    LinearSVC & 0.44 \ %& \textbf{0.58} & \textbf{0.58}  \
    MultinomialNb & 0.51 \ %& 0.51 & 0.51  \
    LogisticRegression & 0.53 \ %& 0.51 & 0.51  \
    RandomForestClassifier & \textbf{0.55} \ %& 0.56 & 0.57  \
    KNeighborsClassifier & 0.48 \ %& 0.50 & 0.49  \
    \bottomrule
  \end{tabular}
\end{table}

在我看来是这样的:

  1. 使用中心对齐的解决方案
\begin{table}[ht]
  \begin{tabular}{lc}
    \toprule
    \multirow{2}{*}{Models} &
      \multicolumn{1}{c}{POS} \
      & {N+POS - P}  \ % & {V+N+L-P, S} & {V+N+L-P, S, Ne}
      \midrule
    LinearSVC & 0.44 \ %& \textbf{0.58} & \textbf{0.58}  \
    MultinomialNb & 0.51 \ %& 0.51 & 0.51  \
    LogisticRegression & 0.53 \ %& 0.51 & 0.51  \
    RandomForestClassifier & \textbf{0.55} \ %& 0.56 & 0.57  \
    KNeighborsClassifier & 0.48 \ %& 0.50 & 0.49  \
    \bottomrule
  \end{tabular}
\end{table}

它看起来像这样:

现在您需要决定哪一个更适合您。