我正在尝试将我的变量分成两个不同的面板(面板 A 和 Pabel B)。
这是我想要的输出:
我的代码:
\documentclass[12pt,notitlepage]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{booktabs} % For better looking tables
\usepackage{natbib}
\usepackage{amsmath}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{empheq}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{multirow}
\usepackage{mathtools}
\usepackage{array}
\usepackage[justification=centering]{caption}
\usepackage{slashed}
\usepackage[english]{babel}
\usepackage[figurename=Fig.]{caption}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{varioref}
\usepackage{multirow}
\begin{document}
\newcommand\mc[1]{\multicolumn{1}{c}{\scriptsize #1}}
\newcolumntype{P}{>{\raggedright\scriptsize}p{4.5cm}}
\newcolumntype{R}{*{5}{>{\scriptsize}c}}
\begin{table}[H]
\caption{Descriptive statistics}
\label{tab:tab_Descriptive statistics}
\begin{center}
\begin{tabular}{@{}P@{\kern-30pt}R@{}}\toprule
\texttt{variables}
& \mc{No of observations}
&\mc{Mean}
&\mc{Standard Deviation}
&\mc{Minimum}&\mc{Maximum}\\[-2pt]
\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(lr){5-5} \cmidrule(lr)
{6-6}
Recession & 17,460 & 6.626403 & 13.00181 & 0 &100\\
Conspiracy Theory & 17,460 & 5.200745 & 11.1865 &0 & 100 \\
Stock Market Crash \newline & 17,460 & 2.293414 & 7.142563 & 0 &100\\[-8pt]
Survivalism &17,460& 1.903379& 6.063206 &0 &100\\
covid confirmed cases & 3,276& 605.0104& 6179.405&0&80151\\
covid death & 3,276 & 17.40781 &191.2796 & 0 &2945\\
covid recovered &3,276&158.1761&2133.75&0 &47404\\
\bottomrule %
\end{tabular}
\end{center}
\end{table}
\end{document}
我的输出:
答案1
我看不出\scriptsize
在这个表中使用的理由。不过,我会缩短一些列标题。
我还会 (a) 借助包siunitx
及其S
列类型,将数字对齐到其(隐式或显式)小数标记上,以及 (b) 将数字四舍五入到小数点后 2 位。毕竟,告诉读者某个变量等于 真的更好吗6.626403
,还是告诉他们 更适合6.63
?S
列类型允许自动四舍五入。
题外话:不要同时加载enumerate
和enumitem
;我只会加载后者的包。
\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=4]}
\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 T{5.0} U{3.2} U{4.2} c T{5.0} @{}}
\toprule
Variables & {No of obs.} & {Mean} & {St.\ Dev.} & {Minimum} & {Maximum} \\
\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4}
\cmidrule(lr){5-5} \cmidrule(l){6-6}
\textbf{Panel A}\\
Recession & 17460 & 6.626403 & 13.00181 & 0 & 100\\
Conspiracy Theory & 17460 & 5.200745 & 11.1865 & 0 & 100\\
Stock Market Crash & 17460 & 2.293414 & 7.142563 & 0 & 100\\
Survivalism & 17460 & 1.903379 & 6.063206 & 0 & 100\\[0.5ex]
\textbf{Panel B}\\
Covid confirmed cases & 3276 & 605.0104 & 6179.405 & 0 & 80151\\
Covid deaths & 3276 & 17.40781 & 191.2796 & 0 & 2945\\
Covid recovered & 3276 & 158.1761 & 2133.75 & 0 & 47404\\
\bottomrule
\end{tabular}
\end{table}
\end{document}