尝试将表格移到左侧,但失败了

时间:2019-11-12 00:53:06

标签: latex tex

我试图将表格重新定位到页面的左侧,所以我尝试使用\hskip -2cm\hspace{-2cm},但是这些都不可以移动表格,这是我的代码:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{array}
\usepackage{booktabs,caption}
\usepackage[flushleft]{threeparttable}
\usepackage{indentfirst}
\setlength\extrarowheight{2pt}


\title{}
\author{}


\begin{document}


\maketitle
\section{Introduction}



\section{Data Summary}





\begin{table}[H]
\begin{threeparttable}
\small

\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\hskip -2cm
\caption{Summary of numeric variables}

\begin{tabular}{l*{1}{ccccc}}
\hline\hline
                    &\multicolumn{5}{c}{(1)}                                         \\
                    &\multicolumn{5}{c}{}                                            \\
                    &       count&        mean&          sd&         min&         max\\
\hline
Unemployment Rate   &         170&      8.3323&      4.1395&      3.1000&     26.0919\\
log of spending per person for secondary education&         168&      9.0229&      0.4344&      7.6109&      9.9616\\
log of spending per person for teriary education&         165&      9.5241&      0.3967&      8.7797&     10.7478\\
log of exchange rate&         170&      1.0983&      2.0997&     -0.4986&      7.0522\\
log of GDP per person&         168&     10.5306&      0.3592&      9.7330&     11.5213\\
log of GDP fixed purchasing power&         165&     27.0045&      1.4905&     23.3668&     30.5051\\
log of GDP growth   &         159&      1.2268&      0.7896&     -1.7458&      3.0063\\
Long-term interest rate on government bonds&         165&      3.8447&      2.1387&      0.5511&     10.5465\\
Short-term interest rate&         170&      1.7675&      1.9971&      0.0078&     10.3317\\
\hline\hline
\end{tabular}
\begin{tablenotes}
\small
\item Source: OECD (2019), Education at a Glance Database, http://stats.oecd.org
\end{tablenotes}
\end{threeparttable}
\end{table}


\section{Methodology}

\end{document}

我的桌子看起来像这样: enter image description here

,我想让桌子离开至少约1.5厘米。 还有其他方法吗?

1 个答案:

答案 0 :(得分:2)

对于未专门设计为在页边距中留出额外空间的布局,将表格项目置于页边距并不是一种好的样式。页边距应属于读者,可以轻松保存文档,添加注释等。如果空间不足,例如Fermat的Last定理是您的错:)

相反,我建议使用tabularx使表格适合可用空间:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{array}
\usepackage{booktabs,caption}
\usepackage[flushleft]{threeparttable}
\usepackage{indentfirst}
\setlength\extrarowheight{2pt}
\usepackage{tabularx}
\usepackage{siunitx}


\title{}
\author{}


\begin{document}


\maketitle
\section{Introduction}



\section{Data Summary}





\begin{table}[H]
\begin{threeparttable}
\small

\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\hskip -2cm
\caption{Summary of numeric variables}
\begin{tabularx}{\linewidth}{@{}XS[table-format=3.0]S[table-format=2.4]S[table-format=1.4]S[table-format=-1.4]S[table-format=2.4]@{}}
\toprule
                    &\multicolumn{5}{c}{(1)}                                        \\\addlinespace 
                    &       {count}&        {mean}&          {sd}&         {min}&         {max}\\
\midrule
Unemployment Rate   &         170&      8.3323&      4.1395&      3.1000&     26.0919\\
log of spending per person for secondary education&         168&      9.0229&      0.4344&      7.6109&      9.9616\\
log of spending per person for teriary education&         165&      9.5241&      0.3967&      8.7797&     10.7478\\
log of exchange rate&         170&      1.0983&      2.0997&     -0.4986&      7.0522\\
log of GDP per person&         168&     10.5306&      0.3592&      9.7330&     11.5213\\
log of GDP fixed purchasing power&         165&     27.0045&      1.4905&     23.3668&     30.5051\\
log of GDP growth   &         159&      1.2268&      0.7896&     -1.7458&      3.0063\\
Long-term interest rate on government bonds&         165&      3.8447&      2.1387&      0.5511&     10.5465\\
Short-term interest rate&         170&      1.7675&      1.9971&      0.0078&     10.3317\\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\small
\item Source: OECD (2019), Education at a Glance Database, http://stats.oecd.org
\end{tablenotes}
\end{threeparttable}
\end{table}


\section{Methodology}

\end{document}

enter image description here

其他一些评论:

  • 请尽量避免使用[H],这通常可以避免浮标的次优放置。我建议改用[htbp]

  • *{1}{ccccc}可以缩写为ccccc*{5}{c}

  • 您已经加载了booktabs包,所以我建议使用\toprule\midrule\bottomrule而不是\hline,因为它们有很多周围的空间更好

  • 我建议不要使用\addlinespace包中的booktabs宏,而不是手动在表中添加空行

  • 使用S包中的siunitx列,您可以通过数字的十进制标记对齐数字,并使用实际的负号来代替连字号

  • 您应该检查您的价值观的重要数字。如果您的标准偏差在0.3到4.1之间,那么给这些值加上小数点后4位是没有意义的。