如何使该表格适合文本宽度?

如何使该表格适合文本宽度?

表格列宽相差太大。表格中的第一列占用了页面太多空间。如能提供任何帮助,我们将不胜感激

\begin{table}[htbp]
\renewcommand{\arraystretch}{1.5}
  \centering
\caption{Table 1)}
 \begin{adjustbox}{width=1.3\textwidth,center=\textwidth}
\begin{tabular}{rrrr}
\toprule
\textbf{Dependent variable: Y} &       &       &  \\
\hline
\midrule
\multicolumn{1}{c}{}& \multicolumn{1}{c}{\textbf{1}} & \multicolumn{1}{c}{\textbf{2}} & \multicolumn{1}{c}{\textbf{3}} \\
\hline
\multicolumn{1}{l}{A} & \multicolumn{1}{c}{-3.5685***} & \multicolumn{1}{c}{-15.4852***} & \multicolumn{1}{c}{-18.9664***} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.000)} & \multicolumn{1}{c}{(0.000)} & \multicolumn{1}{c}{(0.000)} \\
\multicolumn{1}{l}{B} & \multicolumn{1}{c}{-0.03} & \multicolumn{1}{c}{-0.2269} & \multicolumn{1}{c}{-0.0297} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.521)} & \multicolumn{1}{c}{(0.387)} & \multicolumn{1}{c}{(0.719)} \\
\multicolumn{1}{l}{C} & \multicolumn{1}{c}{-0.2425***} & \multicolumn{1}{c}{-0.0543} & \multicolumn{1}{c}{-0.101} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.000)} & \multicolumn{1}{c}{(0.807)} & \multicolumn{1}{c}{(0.276)} \\
\multicolumn{1}{l}{D} & \multicolumn{1}{c}{0.0404} & \multicolumn{1}{c}{0.2300**} & \multicolumn{1}{c}{-0.2082} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.663)} & \multicolumn{1}{c}{(0.028)} & \multicolumn{1}{c}{(0.308)} \\
\multicolumn{1}{l}{E} & \multicolumn{1}{c}{0.6449***} & \multicolumn{1}{c}{0.308} & \multicolumn{1}{c}{0.478} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.003)} & \multicolumn{1}{c}{(0.457)} & \multicolumn{1}{c}{(0.141)} \\
\multicolumn{1}{l}{F} & \multicolumn{1}{c}{0} & \multicolumn{1}{c}{0} & \multicolumn{1}{c}{0.0000**} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.540)} & \multicolumn{1}{c}{(0.197)} & \multicolumn{1}{c}{(0.012)} \\
\multicolumn{1}{l}{G} & \multicolumn{1}{c}{0} & \multicolumn{1}{c}{-0.0005*} & \multicolumn{1}{c}{0} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.746)} & \multicolumn{1}{c}{(0.081)} & \multicolumn{1}{c}{(0.963)} \\
\multicolumn{1}{l}{H} & \multicolumn{1}{c}{0.1527} & \multicolumn{1}{c}{-0.0431} & \multicolumn{1}{c}{-0.1837} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.247)} & \multicolumn{1}{c}{(0.901)} & \multicolumn{1}{c}{(0.443)} \\
\multicolumn{1}{l}{I} & \multicolumn{1}{c}{36.4518} & \multicolumn{1}{c}{-103.7022} & \multicolumn{1}{c}{39.1401} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.282)} & \multicolumn{1}{c}{(0.191)} & \multicolumn{1}{c}{(0.415)} \\
\multicolumn{1}{l}{J} & \multicolumn{1}{c}{-2.0652} & \multicolumn{1}{c}{6.268} & \multicolumn{1}{c}{-2.2654} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.287)} & \multicolumn{1}{c}{(0.175)} & \multicolumn{1}{c}{(0.412)} \\
\multicolumn{1}{l}{K} & \multicolumn{1}{c}{0.002} & \multicolumn{1}{c}{-0.0066} & \multicolumn{1}{c}{0.0023} \\
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(0.278)} & \multicolumn{1}{c}{(0.148)} & \multicolumn{1}{c}{(0.393)} \\
\hline
\multicolumn{1}{c}{\textbf{Number of observations}} & \multicolumn{3}{c}{\textbf{1154}} \\
\hline
\multicolumn{3}{l}{\multirow{\textbf{* p\textless0.1; ** p\textless0.05; *** p\textless0.01}}} & \multicolumn{1}{c}{} \\
\multicolumn{3}{l}{}  & \multicolumn{1}{l}{} \\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{adjustbox}
\end{table}%

答案1

使用工具将内容转换为无人能读懂的 LaTeX 代码非常方便。不,事实并非如此。像这样的简单表格应该有简单的代码。

我的建议:

raq表格

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
    \centering
    \caption{Dependency on the variable Y. No Wombats can be found in this table.}
    \medbreak
    \label{tab:addlabel}%
    \begin{tabular}{crrr}
        \toprule
        Y        &            &             & \\
        \midrule
                 & 1          & 2           & 3 \\
        A        & -3.5685*** & -15.4852*** & -18.9664*** \\
                 & (0.000)    & (0.000)     & (0.000) \\\addlinespace
        B        & -0.03      & -0.2269     & -0.0297 \\
                 & (0.521)    & (0.387)     & (0.719) \\\addlinespace
        C        & -0.2425*** & -0.0543     & -0.101 \\
                 & (0.000)    & (0.807)     & (0.276) \\\addlinespace
        D        & 0.0404     & 0.2300**    & -0.2082 \\
                 & (0.663)    & (0.028)     & (0.308) \\\addlinespace
        E        & 0.6449***  & 0.308       & 0.478 \\
                 & (0.003)    & (0.457)     & (0.141) \\\addlinespace
        F        & 0          & 0           & 0.0000** \\
                 & (0.540)    & (0.197)     & (0.012) \\\addlinespace
        G        & 0          & -0.0005*    & 0 \\
                 & (0.746)    & (0.081)     & (0.963) \\\addlinespace
        H        & 0.1527     & -0.0431     & -0.1837 \\
                 & (0.247)    & (0.901)     & (0.443) \\\addlinespace
        I        & 36.4518    & -103.7022   & 39.1401 \\
                 & (0.282)    & (0.191)     & (0.415) \\\addlinespace
        J        & -2.0652    & 6.268       & -2.2654 \\
                 & (0.287)    & (0.175)     & (0.412) \\\addlinespace
        K        & 0.002      & -0.0066     & 0.0023 \\
                 & (0.278)    & (0.148)     & (0.393) \\
        \bottomrule\addlinespace
    \end{tabular}%
    \par
    Number of observations: 1154 \par
    * $p<0.1$; ** $p<.05$; *** $p<.01$
\end{table}%
\end{document}

答案2

您发布的代码简直太糟糕了。究竟是谁教您这样编程的?!您是否在使用某种转换为 LaTeX 的工具?如果是,请立即停止使用它!它弊大于利。

正如@Johannes_B 在他的回答中所做的那样,我必须首先删除所有\multicolumn包装器。我还删除了所有\textbf突出显示 -根本就没有必要。(讽刺意味。)然后我删除了所有\hline指令(既然您似乎正在使用该booktabs包,那么它们为什么还在那里)并使用该siunitx包及其S列类型将数字数据与相应的小数标记对齐。

顺便问一下,为什么系数估计值的小数点后显示 4 位数字,而相关标准误差只显示 3 位数字?显示 4 位数字而不是 3 位数字可能传达什么含义?这是自学的习惯,还是有人教你这种相当可疑的做法?

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage[skip=0.333\baselineskip]{caption}
\begin{document}

\begin{table}[htbp]
\sisetup{table-format=-1.4,
         input-symbols={()},
         table-space-text-post={***}}

\caption{A fairly simple table} \label{tab:addlabel}
\centering
Dependent variable: $Y$

\begin{tabular}{@{} lSSS @{}}
\toprule
& {1} & {2} & {3} \\
\midrule
A & -3.5685*** & -15.4852*** & -18.9664*** \\
 & (0.000) & (0.000) & (0.000) \\
B & -0.03 & -0.2269 & -0.0297 \\
 & (0.521) & (0.387) & (0.719) \\
C & -0.2425*** & -0.0543 & -0.101 \\
 & (0.000) & (0.807) & (0.276) \\
D & 0.0404 & 0.2300** & -0.2082 \\
 & (0.663) & (0.028) & (0.308) \\
E & 0.6449*** & 0.308 & 0.478 \\
 & (0.003) & (0.457) & (0.141) \\
F & 0 & 0 & 0.0000** \\
 & (0.540) & (0.197) & (0.012) \\
G & 0 & -0.0005* & 0 \\
 & (0.746) & (0.081) & (0.963) \\
H & 0.1527 & -0.0431 & -0.1837 \\
 & (0.247) & (0.901) & (0.443) \\
I & 36.4518 & -103.7022 & 39.1401 \\
 & (0.282) & (0.191) & (0.415) \\
J & -2.0652 & 6.268 & -2.2654 \\
 & (0.287) & (0.175) & (0.412) \\
K & 0.002 & -0.0066 & 0.0023 \\
 & (0.278) & (0.148) & (0.393) \\
\midrule
No.\ of obs. & {1154} \\ 
\addlinespace
\multicolumn{4}{@{}l}{* $p<0.1$; ** $p<0.05$; *** $p<0.01$} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

相关内容