我想要一個使用 package 的 4 個清單\usepackage[flushleft]{threeparttable}
。該表基於以下代碼。
\begin{table} [h]
\caption{Main results after endogeneity correction}
\label{tab:main_results_endog}
\centering
\SingleSpacedXI
\begin{subtable}[c]{\textwidth}
\caption{Cost analysis \label{tbl:main_results_cost}}
\centering
\begin{threeparttable}
\begin{tabular}{p{0.35\textwidth}lcp{0.35\textwidth}lcp{0.35\textwidth}lcp{0.35\textwidth}c}
\hline\hline
& MRO & Repair & Maintenance \\ \hline
$XXX$ & $-0.070^{***}$ & $-0.098^{***}$ & XXX \\
& (0.0032) & (0.0033) & XXX \\
Car attributes controls & Yes & Yes & Yes \\
Driver attributes controls & Yes & Yes & Yes \\
$R^2$ & 0.286 & 0.296 & XXX \\
\# Observations & 19,410,026 & 19,410,026 & XXX \\ \hline\hline
\end{tabular}
\begin{tablenotes}
\item Note: Standard errors in parentheses (* p $<$ 0.05, ** p $<$ 0.01, *** p $<$ 0.001)
\end{tablenotes}
\end{threeparttable}
\end{subtable}
\quad%
\begin{subtable}[c]{\textwidth}
\caption{Frequency analysis \label{tbl:main_results_frequency}}
\centering
\begin{threeparttable}
\begin{tabular}{p{0.35\textwidth}lcp{0.35\textwidth}lcp{0.35\textwidth}lcp{0.35\textwidth}c}
\hline\hline
& MRO & Repair & Maintenance \\ \hline
$XXX$ & $0.055^{***}$ & $0.052^{***}$ & XXX \\
& (0.0025) & (0.0025) & XXX \\
Car attributes controls & Yes & Yes & Yes \\
Driver attributes controls & Yes & Yes & Yes \\
$R^2$ & 0.266 & 0.286 & XXX \\
\# Observations & 18,522,387 & 18,522,387 & XXXX \\ \hline\hline
\end{tabular}
\begin{tablenotes}
\item Note: Standard errors in parentheses (* p $<$ 0.05, ** p $<$ 0.01, *** p $<$ 0.001)
\end{tablenotes}
\end{threeparttable}
\end{subtable}
\end{table}
程式碼輸出如下表。為什麼最後多了一欄?我該如何去除它?
答案1
您目前指定兩個tabular
環境都有 11 [!] 列。由於兩個表實際上只有 4 列,因此解決格式問題的最佳方法是更改兩個實例
\begin{tabular}{p{0.35\textwidth}lcp{0.35\textwidth}lcp{0.35\textwidth}lcp{0.35\textwidth}c}
到
\begin{tabular}{p{0.35\textwidth}lcp{0.35\textwidth}}
當然,這是假設您對其餘四列的規格感到滿意。如果您不是,請隨時提出更好的選擇。
補充三點意見:
由於您幾乎沒有使用該
threeparttable
包的機制,因此我會避免產生其開銷。為了簡化確保表格適合文字區塊的工作,我將從 切換
tabular
到tabularx
環境(目標寬度為\textwidth
)並將第二個實例替換p{0.35\textwidth}
為X
。我將擺脫那些看起來很忙的
\hline\hline
指令,並將它們替換為包的規則繪製巨集booktabs
:\toprule
、\midrule
和\bottomrule
。
\documentclass{article} % or some other suitable document class
\usepackage{subcaption,booktabs,tabularx}
\begin{document}
\begin{table}[h]
\caption{Main results after endogeneity correction}
\label{tab:main_results_endog}
% \SingleSpacedXI % huh?
\begin{subtable}{\textwidth}
\caption{Cost analysis}
\label{tbl:main_results_cost}
\begin{tabularx}{\textwidth}{@{} p{0.35\textwidth} l c X @{}}
\toprule
& MRO & Repair & Maintenance \\
\midrule
\textit{XXX} & $-0.070^{***}$ & $-0.098^{***}$ & XXX \\
& (0.0032) & (0.0033) & XXX \\
\addlinespace
Car attributes controls & Yes & Yes & Yes \\
Driver attributes controls & Yes & Yes & Yes \\
$R^2$ & 0.286 & 0.296 & XXX \\
\# Observations & 19,410,026 & 19,410,026 & XXX \\
\bottomrule
\end{tabularx}
\smallskip\footnotesize
Note: Standard errors in parentheses; $^{*}$ $p < 0.05$, $^{**}$ $p < 0.01$, $^{***}$ $p < 0.001$.
\end{subtable}
\bigskip\bigskip
\begin{subtable}{\textwidth}
\caption{Frequency analysis}
\label{tbl:main_results_frequency}
\begin{tabularx}{\textwidth}{@{} p{0.35\textwidth} l c X @{}}
\toprule
& MRO & Repair & Maintenance \\
\midrule
\textit{XXX} & $0.055^{***}$ & $0.052^{***}$ & XXX \\
& (0.0025) & (0.0025) & XXX \\
\addlinespace
Car attributes controls & Yes & Yes & Yes \\
Driver attributes controls & Yes & Yes & Yes \\
$R^2$ & 0.266 & 0.286 & XXX \\
\# Observations & 18,522,387 & 18,522,387 & XXXX \\
\bottomrule
\end{tabularx}
\smallskip\footnotesize
Note: Standard errors in parentheses; $^{*}$ $p < 0.05$, $^{**}$ $p < 0.01$, $^{***}$ $p < 0.001$.
\end{subtable}
\end{table}
\end{document}