在\ tabularx {}中切割线

发布于 2025-02-03 08:55:03 字数 3040 浏览 7 评论 0 原文

我有下面的代码。我想在突出显示的部分之前卸下空白。

 \documentclass[10pt,english,8pt]{beamer}
\usetheme{default}
\usepackage{booktabs}
\usepackage{tabularx}
%\newcommand{\iid}{\stackrel{\mathrm{iid}}{\sim}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}{>{\raggedleft\arraybackslash}X}


\title{Beamer Template}
\author{TeXstudio Team}
\begin{document}


\begin{frame}{Frame Title}

    \begin{table}[htbp]
        %\begin{table}[!ht]
        \centering
        \scriptsize
        %\caption{Title }
        \label{tab:5}
        \begin{tabularx}{1\textwidth}
            {>{\raggedright\arraybackslash}p{2cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
            }
            %\multicolumn{11}{@{}p{1\textwidth}@{}}{\footnotesize 
                %   Caption }\\
            \toprule 
            
            & Log Probability of Default & Log Recovery Rate
            & Log Spread & Log Leverage  \\ [0.5ex] 
            & (1) & (2) & (3) & (4)  \\
            \midrule
            Log Damage 
            &0.017**    &-0.003***   & 0.002 & -0.157    \\
            &(0.0008)   &(0.003)   & (0.075) & (0.178)  \\
            Log Adaptation
            &-0.157***  &0.012  &-0.463** & 0.514*** \\
            &(0.021)    &(0.007)    &(0.182)    &(0.193)\\
            Log Damage X Log Adaptation
            &0.006  &0.018* &-0.398 &0.535 \\
            &(0.030) &(0.011) &(0.249) &(0.513)\\
            Constant
            &-1.227***&-0.117***&2.244***&0.101\\
            &(0.026)&(0.009)&(0.187)&(0.237)\\                      
            \midrule
            Observations &926 &925 &458 &177 \\
            $R^2$ &41\% &19\% &8\%  &38\%\\
            Adjusted $R^2$ &40\%&17\%&4\%&32\%\\
            Residual Std. Error 
            & 0.071 &   0.025 & 0.373 & 0.264 \\
            & (df = 907) & (df = 906) & (df = 439) & (df = 159)\\
            F Statistic 
            & 35.253*** &   11.455*** & 2.104***  & 5.811***  \\
            & (df = 18; 907)&   (df = 18; 906)& (df = 18; 439)& (df = 17; 159)\\
            
            
            \bottomrule 
            \addlinespace
            \multicolumn{4}{@{}p{0.8\textwidth}@{}}{\footnotesize \tiny{Note: *p<0.1; **p<0.05; ***p<0.01 }} \\
        \end{tabularx}
        %\end{table}
    \end{table}
    
\end{frame}

    

\end{document}

I have a code below. I would like to remove the white space before the highlighted part. image

 \documentclass[10pt,english,8pt]{beamer}
\usetheme{default}
\usepackage{booktabs}
\usepackage{tabularx}
%\newcommand{\iid}{\stackrel{\mathrm{iid}}{\sim}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}{>{\raggedleft\arraybackslash}X}


\title{Beamer Template}
\author{TeXstudio Team}
\begin{document}


\begin{frame}{Frame Title}

    \begin{table}[htbp]
        %\begin{table}[!ht]
        \centering
        \scriptsize
        %\caption{Title }
        \label{tab:5}
        \begin{tabularx}{1\textwidth}
            {>{\raggedright\arraybackslash}p{2cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
            }
            %\multicolumn{11}{@{}p{1\textwidth}@{}}{\footnotesize 
                %   Caption }\\
            \toprule 
            
            & Log Probability of Default & Log Recovery Rate
            & Log Spread & Log Leverage  \\ [0.5ex] 
            & (1) & (2) & (3) & (4)  \\
            \midrule
            Log Damage 
            &0.017**    &-0.003***   & 0.002 & -0.157    \\
            &(0.0008)   &(0.003)   & (0.075) & (0.178)  \\
            Log Adaptation
            &-0.157***  &0.012  &-0.463** & 0.514*** \\
            &(0.021)    &(0.007)    &(0.182)    &(0.193)\\
            Log Damage X Log Adaptation
            &0.006  &0.018* &-0.398 &0.535 \\
            &(0.030) &(0.011) &(0.249) &(0.513)\\
            Constant
            &-1.227***&-0.117***&2.244***&0.101\\
            &(0.026)&(0.009)&(0.187)&(0.237)\\                      
            \midrule
            Observations &926 &925 &458 &177 \\
            $R^2$ &41\% &19\% &8\%  &38\%\\
            Adjusted $R^2$ &40\%&17\%&4\%&32\%\\
            Residual Std. Error 
            & 0.071 &   0.025 & 0.373 & 0.264 \\
            & (df = 907) & (df = 906) & (df = 439) & (df = 159)\\
            F Statistic 
            & 35.253*** &   11.455*** & 2.104***  & 5.811***  \\
            & (df = 18; 907)&   (df = 18; 906)& (df = 18; 439)& (df = 17; 159)\\
            
            
            \bottomrule 
            \addlinespace
            \multicolumn{4}{@{}p{0.8\textwidth}@{}}{\footnotesize \tiny{Note: *p<0.1; **p<0.05; ***p<0.01 }} \\
        \end{tabularx}
        %\end{table}
    \end{table}
    
\end{frame}

    

\end{document}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不弃不离 2025-02-10 08:55:03
  • 日志损坏x log Autaptation 太长了,无法适应单个单元格。最简单的修复是手动将短语的第二部分移至下一行。

  • 如果您使用的是 tabularx ,则应使用至少一个 x 列来确保表可以适应可用空间

  • 我将使用@ {} 在其他列中和之后摆脱额外的空间

  • 以使读取表更容易,我会在块之间添加一些额外的垂直空间

  • 您是否滥用糟糕的 x 作为乘法标志?不要!

  • 语法 \ tiny {...} 是错误的。这是一个开关,没有参数。使用 {\ tiny ...} 而不是。

  • 缺少&lt; 符号

    的数学模式

  • 您表格的数学模式应处于数学模式,以获取正确的负符号和操作员周围的正确间距,但是我懒得在示例中添加它下面...

 \documentclass[10pt,english,8pt]{beamer}
\usetheme{default}
\usepackage{booktabs}
\usepackage{tabularx}

%\newcommand{\iid}{\stackrel{\mathrm{iid}}{\sim}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}{>{\raggedleft\arraybackslash}X}


\title{Beamer Template}
\author{TeXstudio Team}
\begin{document}


\begin{frame}{Frame Title}

    \begin{table}[htbp]
        %\begin{table}[!ht]
        \centering
        \scriptsize
        %\caption{Title }
        \label{tab:5}
        \begin{tabularx}{1\textwidth}
            {
                @{}
                >{\raggedright\arraybackslash}X
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                @{}
            }
            %\multicolumn{11}{@{}p{1\textwidth}@{}}{\footnotesize 
                %   Caption }\\
            \toprule 
            
            & Log Probability of Default & Log Recovery Rate
            & Log Spread & Log Leverage  \\ [0.5ex] 
            & (1) & (2) & (3) & (4)  \\
            \midrule
            Log Damage 
            &0.017**    &-0.003***   & 0.002 & -0.157    \\
            &(0.0008)   &(0.003)   & (0.075) & (0.178)  \\\addlinespace
            Log Adaptation
            &-0.157***  &0.012  &-0.463** & 0.514*** \\
            &(0.021)    &(0.007)    &(0.182)    &(0.193)\\\addlinespace
            Log Damage $\times$ 
            &0.006  &0.018* &-0.398 &0.535 \\
            Log Adaptation &(0.030) &(0.011) &(0.249) &(0.513)\\\addlinespace
            Constant
            &-1.227***&-0.117***&2.244***&0.101\\
            &(0.026)&(0.009)&(0.187)&(0.237)\\                      
            \midrule
            Observations &926 &925 &458 &177 \\
            $R^2$ &41\% &19\% &8\%  &38\%\\
            Adjusted $R^2$ &40\%&17\%&4\%&32\%\\\addlinespace
            Residual Std. Error 
            & 0.071 &   0.025 & 0.373 & 0.264 \\
            & (df = 907) & (df = 906) & (df = 439) & (df = 159)\\\addlinespace
            F Statistic 
            & 35.253*** &   11.455*** & 2.104***  & 5.811***  \\
            & (df = 18; 907)&   (df = 18; 906)& (df = 18; 439)& (df = 17; 159)\\
            
            
            \bottomrule 
            \addlinespace
            \multicolumn{4}{@{}p{0.8\textwidth}@{}}{\footnotesize {\tiny Note: *$p<0.1$; **$p<0.05$; ***$p<0.01$ }} \\
        \end{tabularx}
        %\end{table}
    \end{table}
    
\end{frame}

\end{document}

  • Log Damage X Log Adaptation is too long to fit into a single cell. The easiest fix is to manually move the second part of the phrase into the next line.

  • If you are using a tabularx, you should use at least one X column to make sure the table can adapt to the available space

  • I would use @{} in front and after the other columns to get rid of the extra space

  • To make reading the table easier, I would add some additional vertical space between the blocks

  • Are you abusing the poor X as multiplication sign? Don't!

  • the syntax \tiny{...} is wrong. It is a switch and does not take an argument. Use {\tiny ...} instead.

  • Missing math mode around the < signs

  • most of your table should be in math mode to get correct minus sign and proper spacing around operators, but I'm too lazy to add this in the example below...

 \documentclass[10pt,english,8pt]{beamer}
\usetheme{default}
\usepackage{booktabs}
\usepackage{tabularx}

%\newcommand{\iid}{\stackrel{\mathrm{iid}}{\sim}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}{>{\raggedleft\arraybackslash}X}


\title{Beamer Template}
\author{TeXstudio Team}
\begin{document}


\begin{frame}{Frame Title}

    \begin{table}[htbp]
        %\begin{table}[!ht]
        \centering
        \scriptsize
        %\caption{Title }
        \label{tab:5}
        \begin{tabularx}{1\textwidth}
            {
                @{}
                >{\raggedright\arraybackslash}X
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                >{\centering\arraybackslash}p{1.75cm}
                @{}
            }
            %\multicolumn{11}{@{}p{1\textwidth}@{}}{\footnotesize 
                %   Caption }\\
            \toprule 
            
            & Log Probability of Default & Log Recovery Rate
            & Log Spread & Log Leverage  \\ [0.5ex] 
            & (1) & (2) & (3) & (4)  \\
            \midrule
            Log Damage 
            &0.017**    &-0.003***   & 0.002 & -0.157    \\
            &(0.0008)   &(0.003)   & (0.075) & (0.178)  \\\addlinespace
            Log Adaptation
            &-0.157***  &0.012  &-0.463** & 0.514*** \\
            &(0.021)    &(0.007)    &(0.182)    &(0.193)\\\addlinespace
            Log Damage $\times$ 
            &0.006  &0.018* &-0.398 &0.535 \\
            Log Adaptation &(0.030) &(0.011) &(0.249) &(0.513)\\\addlinespace
            Constant
            &-1.227***&-0.117***&2.244***&0.101\\
            &(0.026)&(0.009)&(0.187)&(0.237)\\                      
            \midrule
            Observations &926 &925 &458 &177 \\
            $R^2$ &41\% &19\% &8\%  &38\%\\
            Adjusted $R^2$ &40\%&17\%&4\%&32\%\\\addlinespace
            Residual Std. Error 
            & 0.071 &   0.025 & 0.373 & 0.264 \\
            & (df = 907) & (df = 906) & (df = 439) & (df = 159)\\\addlinespace
            F Statistic 
            & 35.253*** &   11.455*** & 2.104***  & 5.811***  \\
            & (df = 18; 907)&   (df = 18; 906)& (df = 18; 439)& (df = 17; 159)\\
            
            
            \bottomrule 
            \addlinespace
            \multicolumn{4}{@{}p{0.8\textwidth}@{}}{\footnotesize {\tiny Note: *$p<0.1$; **$p<0.05$; ***$p<0.01$ }} \\
        \end{tabularx}
        %\end{table}
    \end{table}
    
\end{frame}

\end{document}

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文