![테이블 끝의 추가 열을 제거하는 방법](https://rvso.com/image/476250/%ED%85%8C%EC%9D%B4%EB%B8%94%20%EB%81%9D%EC%9D%98%20%EC%B6%94%EA%B0%80%20%EC%97%B4%EC%9D%84%20%EC%A0%9C%EA%B1%B0%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
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}}
물론 이는 나머지 4개 열의 사양에 문제가 없다고 가정합니다. 그렇지 않다면 더 나은 선택을 해보세요.
세 가지 추가 의견:
패키지 의 기계를 거의 사용하지 않기 때문에
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}