统计表中中心值

统计表中中心值

如何使值居中以使表格看起来更好看,这是我的建议和输出。

 \documentclass[12pt,notitlepage]{article}
 \usepackage[margin=2cm]{geometry}
 \usepackage{booktabs} % For better looking tables
 \usepackage{natbib}
 \usepackage{amsmath}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}                 
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{array}
\usepackage[figurename=Fig.,skip=0.333\baselineskip]{caption}
\usepackage[english]{babel}

 \usepackage{siunitx}
  \newcolumntype{T}[1]{S[table-format=#1,group-separator={,},group-minimum-digits=3]}
  \newcolumntype{U}[1]{S[table-format=#1,round-precision=2,round-mode=places]}


  \begin{document}
  \begin{table}[ht]
 \caption{Descriptive statistics}
 \label{tab:tab_Descriptive statistics}
 \centering
 \begin{tabular}{@{} l U{3.0} U{4.2}U{4.2} U{4.2} U{4.2}  @{}}
 \toprule 
 Variables & {Price} & {Open} & {High} & {Low} & {Vol}&  \\
\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4}
\cmidrule(lr){5-5} \cmidrule(l){6-6}  

No of obs.              & 3643     &    3643     & 3643      & 3643      &   3643\\  
Mean                    & 70.814   &   70.83     & 71.885    & 69.687    &  \\ 
St.\ Dev.               & 23.701979&    23.65      &    23.768370&  23.543701&   100\\
    Miximum                 &-37.63    &    -14.0      &    13.69    &  -40.32   &   100\\
Manimum                 & 145.29   &    145.19     &    147.27   &  143.22   &  100\\
    25\%                    & 50.99    &    51.0       &51.98      &    50.13    &  10\\
50\%                    & 68.10    &    68.15      &    69.31    &  67.0     &     100\\
75\%                    & 91.86   & 91.77        &  92.92    &  90.70    &     100\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

输出 :

在此处输入图片描述

答案1

您需要将数字括No of obs.在花括号中:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
 
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{booktabs} % For better looking tables
\usepackage[figurename=Fig.,skip=0.333\baselineskip]{caption}
\usepackage{siunitx}

\begin{document}
    \begin{table}[ht]
    \caption{Descriptive statistics}
    \label{tab:tab_Descriptive statistics}
    \centering
\begin{tabular}{@{} l *{4}{S[table-format=3.2,
                             round-mode=places,
                             round-precision=2]}
                           S[table-format=2]  
                @{}}
    \toprule
 Variables      & {Price}   & {Open}    & {High}        & {Low}         & {Vol}  \\ % <---
    \midrule
No of obs.      & {3643}    & {3643}    & {3643}        & {3643}        & {3643}\\
Mean            & 70.814    &  70.83    &  71.885       &   69.687      &       \\
St. Dev.        & 23.701979 &  23.65    &  23.768370    &   23.543701   & 100   \\
    Miximum     &-37.63     & -14.0     &  13.69        &  -40.32       & 100   \\
    Manimum     & 145.29    & 145.19    & 147.27        &  143.22       & 100   \\
\qty{25}{\%}    & 50.99     &  51.0     &  51.98        &   50.13       &  10   \\
\qty{55}{\%}    & 68.10     &  68.15    &  69.31        &   67.0        & 100   \\
\qty{75}{\%}    & 91.86     &  91.77    &  92.92        &   90.70       & 100   \\
\bottomrule
\end{tabular}
    \end{table}
\end{document}

在此处输入图片描述

相关内容