테이블 열 오류
Aug 30 2020
각 변수에 대한 설명 열을 포함하고 싶지만이 오류가 발생했습니다.
여기 내 코드 :
\documentclass[a4paper, 12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{booktabs}
\usepackage{natbib}
\usepackage{eucal}
\usepackage{lmodern}
\usepackage[showframe]{geometry}
\usepackage{textcomp}
\usepackage{cuted}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{multirow}
\usepackage{array}
\usepackage[latin1]{inputenc}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{varioref}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{siunitx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage[onehalfspacing]{setspace}
\usepackage{rotating}
\usepackage{siunitx}
\usepackage{makecell, threeparttable}
\usepackage{xparse,xstring} % ditto
\newcommand\mc[1]{\multicolumn{1}{c}{\scriptsize #1}}
\newcolumntype{P}{>{\raggedright\scriptsize}p{4.5cm}}
\newcolumntype{R}{*{5}{>{\scriptsize}c}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{table}[h!]
\caption{Descriptive Statistics for Banks’ financial data and macro variables}
\label{tab1}
\centering
\begin{tabular}{@{}P@{\kern-30pt}R@{}}
\toprule
\texttt{Variables}
& \mc{Description}
& \mc{No of observations}
&\mc{Mean}
&\mc{Standard Deviation}
&\mc{Maximum}
&\mc{Minimum}\\[-2pt]
\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(lr){5-5} \cmidrule(lr)
{6-6} \cmidrule(lr){7-7}
Specialization & total loans-to-total assets ratio & 8743 & 0.164 & 7.144 & 0659 & 0.046\\
Credit quality & Loans loss provision-to-total loans &8950 & 0.152 &5.102 &0.338 & 1.766 \\
Diversification & Non-interest income-to-total income &8945 &0.245&10.172 &0.509 &0.396\\
Profitability &Return on assets (ROA) &8746 &0.146&4.514 &0.132 &0.115\\
Real GDP growth & Quarter-over-Quarter growth &8456 &0.045&0.612 &1.192 &0.010\\
Log (Inflation) &Quarter-over-Quarter growth &8752 &0.123&3.890 &0.134 &0.118\\
Log (unemployment rate) &Quarter-over-Quarter growth &8563 &0.315&13.072 &0.508 &0.396\\
Exchange rate &Quarter-over-Quarter growth &8745 &0.278&11.156 &0.543 &0.016\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
답변
3 Mico Aug 30 2020 at 05:00
몇 가지 의견 및 관찰 :
geometry패키지를 두 번 로드합니다 .inputenc호환되지 않는 옵션으로 두 번 로드합니다.\mc두 번 정의 합니다. 두 번째 (재) 정의를 들어, 사용해야\renewcommand하지\newcommand.tabular전체적으로 6 개의 열을 갖도록 환경을 정의 하지만 데이터는 실제로 7 개의 열이 있음을 보여줍니다.- 일부 사용자 정의 열 유형을 정의했지만 그다지 많이 사용하지 않는 것 같습니다.
어쨌든 헤더 셀의 일부를 축약하려는 한 기본 l및 c열 유형으로 할 수 있습니다.
\documentclass[a4paper, 12pt]{article}
%% (reduced the preamble to its bare minimum)
\usepackage[margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{lmodern,eucal}
\usepackage[english]{babel}
\usepackage[onehalfspacing]{setspace}
\usepackage{siunitx}
\begin{document}
\begin{table}[h!]
\caption{Descriptive statistics for banks' financial
data and macro variables\strut}
\label{tab1}
\setlength\tabcolsep{0pt} % make LaTex determine inter-col. whitespace
\small
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
ll cc S[table-format=2.3] cc @{}}
\toprule
Variables & Description & No of obs & Mean
& {Std Dev} & Max & Min \\
\midrule
Specialization & total loans-to-total assets ratio & 8743 & 0.164 & 7.144 & 0659 & 0.046\\
Credit quality & Loans loss provision-to-total loans&8950 & 0.152 & 5.102 &0.338 & 1.766\\
Diversification & Non-interest income-to-total income&8945 & 0.245 &10.172 &0.509 & 0.396\\
Profitability &Return on assets (ROA) &8746 & 0.146 & 4.514 &0.132 & 0.115\\
\addlinespace
Real GDP growth & q-o-q growth &8456 & 0.045 & 0.612 &1.192 & 0.010\\
Log (Inflation) &q-o-q growth &8752 & 0.123 & 3.890 &0.134 & 0.118\\
Log (unempl.\ rate) &q-o-q growth &8563 & 0.315 &13.072 &0.508 & 0.396\\
Exchange rate &q-o-q growth &8745 & 0.278 &11.156 &0.543 & 0.016\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
4 Zarko Aug 30 2020 at 04:59
문서 프리앰블 (질문 아래 주석 참조)을 정리하고 테이블에 필요하지 않은 모든 패키지와 새 명령 정의를 제거한 후 다음 결과를 얻습니다.
보시다시피, 두 줄로 작성하고 이름에 약어를 사용하는 긴 열 헤더가 있습니다. 이로 인해 열이 좁아지고 글꼴 크기 조정을 \textwidth사용할 수 있습니다 \footnotesize.
\documentclass[a4paper, 12pt]{article}
\usepackage[showframe,
margin=2cm]{geometry}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{booktabs, makecell, tabularx}
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\caption{Descriptive Statistics for Banks’ financial data and macro variables}
\label{tab1}
\centering
\footnotesize
\begin{tabularx}{\linewidth}{@{} l X cc S[table-format=2.3] cc @{}}
\toprule
\texttt{Variables}
& \makecell[b]{Description}
& \makecell[b]{No of\\ observ.}
& \makecell[b]{Mean}
& {\makecell[b]{Standard\\ Deviation}}
& \makecell[b]{Max}
& \makecell[b]{Min} \\
\midrule
%\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(lr){5-5} \cmidrule(lr)
%{6-6} \cmidrule(lr){7-7}
Specialization & total loans-to-total assets ratio & 8743 & 0.164 & 7.144 & 0.659 & 0.046 \\
Credit quality & Loans loss provision-to-total loans & 8950 & 0.152 & 5.102 & 0.338 & 1.766 \\
Diversification & Non-interest income-to-total income & 8945 & 0.245 & 10.172 & 0.509 & 0.396 \\
Profitability & Return on assets (ROA) & 8746 & 0.146 & 4.514 & 0.132 & 0.115 \\
Real GDP growth & Quarter-over-Quarter growth & 8456 & 0.045 & 0.612 & 1.192 & 0.010 \\
Log (Inflation) & Quarter-over-Quarter growth & 8752 & 0.123 & 3.890 & 0.134 & 0.118 \\
Log (unemployment rate)
& Quarter-over-Quarter growth & 8563 & 0.315 & 13.072 & 0.508 & 0.396 \\
Exchange rate & Quarter-over-Quarter growth & 8745 & 0.278 & 11.156 & 0.543 & 0.016 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}