标题和长标签之间的间距很大

标题和长标签之间的间距很大

我遇到了一个问题,我的标题离我的表格太远了,我找不到原因和解决办法。有人能帮我解决这个问题吗?我已经试过了

\usepackage{caption}
\captionsetup{skip=0.8pt}
\captionsetup[longtable]{skip=0pt}

但那没有用:(

     \documentclass[12pt, a4paper]{article}

    %some important packages
    \usepackage[T1]{fontenc}                    %package to set font encoding
    \usepackage[utf8]{inputenc}             %package to set input encoding
    \usepackage[english,ngerman]{babel}                 %option for paper in german
    \usepackage{graphicx}                       %package to include graphics
    \usepackage{setspace}                       %package to set space between lines
    \usepackage{lscape}                         %package to rotate pages
    \usepackage{booktabs}                       %package for nice tables
    \usepackage{amsmath,amsfonts,amssymb}       %packages for LaTeX that provides various features to facilitate writing math   
    %\usepackage{fourier} % fourier calls \usepackage[T1]{fontenc}
    % \usepackage{mathpazo}
    % weitere?
    %\usepackage{fouriernc}
    \usepackage[charter]{mathdesign}
    \setlength{\parindent}{0pt} 
    \parskip1ex % sets paragraph without indent but small space between paragraphs

    \usepackage{abstract}
    \renewcommand{\absnamepos}{flushleft}
    \setlength{\absleftindent}{0pt}
    \setlength{\absrightindent}{0pt}

                                                %formulas and to improve the typographical quality of their output 
\usepackage{array}
       \usepackage{tabularx}                        %package for column width and linebreaks in table cells
    \usepackage{longtable,tabu}
    \usepackage{hhline} % for double line

    \usepackage{caption}
    \captionsetup{skip=0.8pt}
    \captionsetup[longtable]{skip=0pt}

    %adjustment of page parameters
    \renewcommand{\baselinestretch}{1.3}        %line spacing is set to 1.5
    \setlength{\textheight}{22.86cm}            %text height
    \setlength{\textwidth}{14cm}                %text width
    \setlength{\oddsidemargin}{1cm}             %page margin 
    \setlength{\evensidemargin}{1cm}            %page margin
    \setlength{\topmargin}{-0.76cm}             %top margin
    \setlength{\footnotesep}{10.0pt}            %space between footnote and text



     \begin{document}
        \begin{longtabu} to 0.9\textwidth {
                X[2,l] |
                X[2,c]
                X[2,c]
                X[2,c]
                X[3,c] 
                X[2,c] |
                X[2,c]
                X[2,c] |
                X[4,c] }    
                \caption{Country-Specific Characteristics} \\
                \label{table:essexx}    \\ \\\hline   \\ 
                Cntry    & $\widehat{ex}_j$ & SEs & p-Val & \%-Effect & $\hat{S}_i$ & SEs & p-Val & $\lambda_i$ (US=1) 
                \\\hline
            &&&&&&&&\\
            USA & 5.40 & 0.24 & 0.000 & -62.5 & 0.54 & 0.17 & 0.002 & 1.00 \\                                            
            ARG & 1.62 & 0.26 & 0.000 & -25.6 & 0.69 & 0.19 & 0.000 & 2.00 \\                                            
            AUS & 2.50 & 0.25 & 0.000 & -36.5 & 0.11 & 0.18 & 0.541 & 3.00 \\                                            
            AUT & 1.35 & 0.24 & 0.000 & -21.8 & 0.77 & 0.17 & 0.000 & 4.00 \\                                            
            BEL & 5.14 & 0.24 & 0.000 & -60.7 & -1.55 & 0.17 & 0.000 & 5.00 \\                                           
            BEN & -3.71 & 0.41 & 0.000 & 96.3 & -0.25 & 0.23 & 0.277 & 6.00 \\                                           
            BGD & -0.42 & 0.27 & 0.116 & 8.0 & 0.54 & 0.21 & 0.010 & 7.00 \\                                             
            BOL & -2.61 & 0.31 & 0.000 & 60.7 & -0.09 & 0.21 & 0.668 & 8.00 \\                                           
            BRA & 2.21 & 0.25 & 0.000 & -33.1 & 1.27 & 0.18 & 0.000 & 9.00 \\                                            
            CAF & -4.04 & 0.52 & 0.000 & 108.6 & 0.33 & 0.24 & 0.169 & 10.00 \\                                          
            CAN & 3.32 & 0.24 & 0.000 & -45.3 & 0.11 & 0.17 & 0.518 & 11.00 \\                                           
            CHE & 2.19 & 0.24 & 0.000 & -32.8 & 0.75 & 0.17 & 0.000 & 12.00 \\                                           
            CHL & 2.39 & 0.26 & 0.000 & -35.3 & -0.39 & 0.18 & 0.030 & 13.00 \\                                          
            CHN & 4.40 & 0.24 & 0.000 & -55.1 & 0.76 & 0.17 & 0.000 & 14.00 \\                                           
            CMR & -1.50 & 0.30 & 0.000 & 31.5 & -0.43 & 0.20 & 0.032 & 15.00 \\                                          
            COL & -0.45 & 0.26 & 0.084 & 8.5 & 0.63 & 0.19 & 0.001 & 16.00 \\                                            
            CRI & -0.96 & 0.28 & 0.001 & 19.1 & 0.01 & 0.20 & 0.960 & 17.00 \\                                           
            DNK & 1.67 & 0.24 & 0.000 & -26.2 & 0.81 & 0.17 & 0.000 & 18.00 \\                                           
            DOM & -1.45 & 0.29 & 0.000 & 30.1 & -0.49 & 0.21 & 0.020 & 19.00 \\                                          
            ECU & -1.09 & 0.29 & 0.000 & 21.9 & 0.06 & 0.20 & 0.764 & 20.00 \\                                           
            EGY & -2.66 & 0.27 & 0.000 & 62.1 & 1.17 & 0.19 & 0.000 & 21.00 \\                                           
            ESP & 2.82 & 0.24 & 0.000 & -40.1 & 0.53 & 0.17 & 0.002 & 22.00 \\                                           
            ETH & -2.44 & 0.33 & 0.000 & 56.0 & -1.15 & 0.23 & 0.000 & 23.00 \\                                          
            FIN & 0.82 & 0.25 & 0.001 & -13.8 & 1.39 & 0.18 & 0.000 & 24.00 \\                                           
            FRA & 3.69 & 0.24 & 0.000 & -48.8 & 0.68 & 0.17 & 0.000 & 25.00 \\                                           
            GBR & 4.60 & 0.24 & 0.000 & -56.6 & -0.08 & 0.17 & 0.638 & 26.00 \\                                          
            GHA & -0.51 & 0.32 & 0.109 & 9.8 & -1.50 & 0.22 & 0.000 & 27.00 \\                                           
            GRC & -0.68 & 0.25 & 0.007 & 13.1 & 0.75 & 0.18 & 0.000 & 28.00 \\                                           
            GTM & -2.28 & 0.29 & 0.000 & 51.2 & -0.03 & 0.20 & 0.881 & 29.00 \\                                          
            HND & -2.96 & 0.32 & 0.000 & 71.3 & -0.46 & 0.20 & 0.021 & 30.00 \\                                          
            IND & 1.86 & 0.25 & 0.000 & -28.6 & 1.24 & 0.18 & 0.000 & 31.00 \\                                           
            IRL & 2.54 & 0.24 & 0.000 & -37.0 & -0.33 & 0.18 & 0.067 & 32.00 \\                                          
            IRN & -2.35 & 0.31 & 0.000 & 53.4 & 1.20 & 0.23 & 0.000 & 33.00 \\                                           
            ISR & 1.78 & 0.27 & 0.000 & -27.7 & -0.01 & 0.20 & 0.960 & 34.00 \\                                          
            ITA & 3.48 & 0.24 & 0.000 & -46.9 & 0.85 & 0.17 & 0.000 & 35.00 \\                                           
            JAM & -2.04 & 0.30 & 0.000 & 44.9 & -0.50 & 0.19 & 0.009 & 36.00 
muchmoreDATA &&&&&&&&\\
            \hline                                     
        \end{longtabu}}
        \end{spacing}
    \end{document}

很高兴能得到帮助,GZ

答案1

            \caption{Country-Specific Characteristics} \\
            \label{table:essexx}    \\ \\\hline   \\ 
            Cntry    & $\widehat{ex}_j$ & SEs & p-Val & \%-Effect & $\hat{S}_i$ & SEs & p-Val & $\lambda_i$ (US=1) 

在标题行和行号之间放置两个空白行,然后在“Cntry”之前放置另一个空白行,您想要

          \caption{Country-Specific Characteristics\label{table:essexx}}\\
          \hline
           Cntry    & $\widehat{ex}_j$ & SEs & p-Val & \%-Effect & $\hat{S}_i$ & SEs & p-Val & $\lambda_i$ (US=1) 

切勿使用\\after \hline

答案2

您的代码中有很多错误。我已更正这些错误(包括 @DavidCarlisle 指出的那个错误)。我为您的表格制作了漂亮的打印。这样更容易看到数字或&缺失或超出需要的位置... 您booktabs在序言中写过但您没有使用它,为什么?

%我在以下更正后的代码中注释掉了最后一个大错误(见前导):

\documentclass[12pt, a4paper]{article}

%some important packages
\usepackage[T1]{fontenc}                    %package to set font encoding
\usepackage[utf8]{inputenc}             %package to set input encoding
\usepackage[english,ngerman]{babel}                 %option for paper in german
\usepackage{booktabs}                       %package for nice tables

\usepackage[charter]{mathdesign}
\setlength{\parindent}{0pt} 
\parskip1ex % sets paragraph without indent but small space between paragraphs

\usepackage{array}
\usepackage{tabularx}                        %package for column width and linebreaks in table cells
\usepackage{longtable,tabu}

\usepackage{caption}
\captionsetup{skip=0.8pt}
\captionsetup[longtable]{skip=0pt}

    %adjustment of page parameters
    \renewcommand{\baselinestretch}{1.3}        %line spacing is set to 1.5
    \setlength{\textheight}{22.86cm}            %text height
    \setlength{\textwidth}{14cm}                %text width
    \setlength{\oddsidemargin}{1cm}             %page margin 
    \setlength{\evensidemargin}{1cm}            %page margin
    \setlength{\topmargin}{-0.76cm}             %top margin
    \setlength{\footnotesep}{10.0pt}            %space between footnote and text


\begin{document}
\begin{longtabu} to 0.9\textwidth {
  X[2,l] |
  X[2,c]
  X[2,c]
  X[2,c]
  X[3,c] 
  X[2,c] |
  X[2,c]
  X[2,c] |
  X[4,c] } 
  \caption{Country-Specific Characteristics}
  \label{table:essexx} \\ \toprule
  Cntry    & $\widehat{ex}_j$ & SEs & p-Val & \%-Effect & $\hat{S}_i$ & SEs & p-Val & $\lambda_i$ (US=1) 
  \\\midrule
  USA &  5.40 & 0.24 & 0.000 & -62.5 &  0.54 & 0.17 & 0.002 &  1.00 \\
  ARG &  1.62 & 0.26 & 0.000 & -25.6 &  0.69 & 0.19 & 0.000 &  2.00 \\
  AUS &  2.50 & 0.25 & 0.000 & -36.5 &  0.11 & 0.18 & 0.541 &  3.00 \\
  AUT &  1.35 & 0.24 & 0.000 & -21.8 &  0.77 & 0.17 & 0.000 &  4.00 \\
  BEL &  5.14 & 0.24 & 0.000 & -60.7 & -1.55 & 0.17 & 0.000 &  5.00 \\
  BEN & -3.71 & 0.41 & 0.000 &  96.3 & -0.25 & 0.23 & 0.277 &  6.00 \\
  BGD & -0.42 & 0.27 & 0.116 &   8.0 &  0.54 & 0.21 & 0.010 &  7.00 \\                                             
  BOL & -2.61 & 0.31 & 0.000 &  60.7 & -0.09 & 0.21 & 0.668 &  8.00 \\                                           
  BRA &  2.21 & 0.25 & 0.000 & -33.1 &  1.27 & 0.18 & 0.000 &  9.00 \\                                            
  CAF & -4.04 & 0.52 & 0.000 & 108.6 &  0.33 & 0.24 & 0.169 & 10.00 \\                                          
  CAN &  3.32 & 0.24 & 0.000 & -45.3 &  0.11 & 0.17 & 0.518 & 11.00 \\                                           
  CHE &  2.19 & 0.24 & 0.000 & -32.8 &  0.75 & 0.17 & 0.000 & 12.00 \\                                           
  CHL &  2.39 & 0.26 & 0.000 & -35.3 & -0.39 & 0.18 & 0.030 & 13.00 \\                                          
  CHN &  4.40 & 0.24 & 0.000 & -55.1 &  0.76 & 0.17 & 0.000 & 14.00 \\                                           
  CMR & -1.50 & 0.30 & 0.000 &  31.5 & -0.43 & 0.20 & 0.032 & 15.00 \\                                          
  COL & -0.45 & 0.26 & 0.084 &   8.5 &  0.63 & 0.19 & 0.001 & 16.00 \\                                            
  CRI & -0.96 & 0.28 & 0.001 &  19.1 &  0.01 & 0.20 & 0.960 & 17.00 \\                                           
  DNK &  1.67 & 0.24 & 0.000 & -26.2 &  0.81 & 0.17 & 0.000 & 18.00 \\                                           
  DOM & -1.45 & 0.29 & 0.000 &  30.1 & -0.49 & 0.21 & 0.020 & 19.00 \\                                          
  ECU & -1.09 & 0.29 & 0.000 &  21.9 &  0.06 & 0.20 & 0.764 & 20.00 \\                                           
  EGY & -2.66 & 0.27 & 0.000 &  62.1 &  1.17 & 0.19 & 0.000 & 21.00 \\                                           
  ESP &  2.82 & 0.24 & 0.000 & -40.1 &  0.53 & 0.17 & 0.002 & 22.00 \\                                           
  ETH & -2.44 & 0.33 & 0.000 &  56.0 & -1.15 & 0.23 & 0.000 & 23.00 \\                                          
  FIN &  0.82 & 0.25 & 0.001 & -13.8 &  1.39 & 0.18 & 0.000 & 24.00 \\                                           
  FRA &  3.69 & 0.24 & 0.000 & -48.8 &  0.68 & 0.17 & 0.000 & 25.00 \\                                           
  GBR &  4.60 & 0.24 & 0.000 & -56.6 & -0.08 & 0.17 & 0.638 & 26.00 \\
  GHA & -0.51 & 0.32 & 0.109 &   9.8 & -1.50 & 0.22 & 0.000 & 27.00 \\
  GRC & -0.68 & 0.25 & 0.007 &  13.1 &  0.75 & 0.18 & 0.000 & 28.00 \\
  GTM & -2.28 & 0.29 & 0.000 &  51.2 & -0.03 & 0.20 & 0.881 & 29.00 \\
  HND & -2.96 & 0.32 & 0.000 &  71.3 & -0.46 & 0.20 & 0.021 & 30.00 \\
  IND &  1.86 & 0.25 & 0.000 & -28.6 &  1.24 & 0.18 & 0.000 & 31.00 \\
  IRL &  2.54 & 0.24 & 0.000 & -37.0 & -0.33 & 0.18 & 0.067 & 32.00 \\
  IRN & -2.35 & 0.31 & 0.000 &  53.4 &  1.20 & 0.23 & 0.000 & 33.00 \\
  ISR &  1.78 & 0.27 & 0.000 & -27.7 & -0.01 & 0.20 & 0.960 & 34.00 \\
  ITA &  3.48 & 0.24 & 0.000 & -46.9 &  0.85 & 0.17 & 0.000 & 35.00 \\
  JAM & -2.04 & 0.30 & 0.000 &  44.9 & -0.50 & 0.19 & 0.009 & 36.00 \\ 
  \bottomrule                                     
\end{longtabu}%}
%\end{spacing}
\end{document}

答案3

您可能不想使用环境,而是longtabu希望使用环境longtable。我还建议您使用包S提供的列类型,siunitx将第 2 列至第 9 列中的所有数字按十进制对齐,并为-表中的负数获取数学模式(减号)符号,而不是破折号。

在此处输入图片描述

在此处输入图片描述

\documentclass[12pt, a4paper]{article}

%some important packages
\usepackage[T1]{fontenc}             %set font encoding
\usepackage[utf8]{inputenc}          %set input encoding
\usepackage[english,ngerman]{babel}  %language options
\usepackage{booktabs}                %nice rules in tables

\usepackage[charter]{mathdesign}

% sets paragraph without indent but small space between paragraphs
\setlength{\parindent}{0pt} 
\setlength\parskip{1ex} 

\usepackage{array,longtable,siunitx}
\usepackage[skip=1ex]{caption}

%adjustment of page parameters
\usepackage{setspace}
\setstretch{1.3}    %set line spacing to 1.3

% page and text block parameters
\setlength{\textheight}{22.86cm}
\setlength{\textwidth}{14cm}   
\setlength{\oddsidemargin}{1cm}    
\setlength{\evensidemargin}{1cm} 
\setlength{\topmargin}{-0.76cm}   

%space between footnote and text
\setlength\footnotesep{10pt}     

\begin{document}
\begin{longtable}{@{} l
                      S[table-format= 1.2]
                      S[table-format= 1.2]
                      S[table-format= 1.3]
                      S[table-format=-2.2]
                      S[table-format=-1.2]
                      S[table-format= 1.2]
                      S[table-format= 1.3]
                      S[table-format= 2.0,
                        round-mode=places,
                        round-precision=0]
                  @{}}
\caption{Country-Specific Characteristics} \label{table:essexx} \\ 
\toprule
Country & {$\widehat{\textit{ex}}_j$} & {SEs} & {p-Val} & {\%-Effect} & {$\hat{S}_i$} & {SEs} & {p-Val} & {$\lambda_i$} \\
  & & & & & & & & {(USA$\equiv$1)} \\
\midrule
\endfirsthead

\multicolumn{9}{@{}l}{(Table \ref{table:essexx}, continued)}\\ 
\addlinespace
\toprule
Country & {$\widehat{\textit{ex}}_j$} & {SEs} & {p-Val} & {\%-Effect} & {$\hat{S}_i$} & {SEs} & {p-Val} & {$\lambda_i$} \\
  & & & & & & & & {(USA$\equiv$1)} \\
\midrule
\endhead


\bottomrule
\addlinespace
\multicolumn{9}{r@{}}{(continued on following page)}\\
\endfoot
\bottomrule
\endlastfoot

  USA &  5.40 & 0.24 & 0.000 & -62.5 &  0.54 & 0.17 & 0.002 &  1.00 \\
  ARG &  1.62 & 0.26 & 0.000 & -25.6 &  0.69 & 0.19 & 0.000 &  2.00 \\
  AUS &  2.50 & 0.25 & 0.000 & -36.5 &  0.11 & 0.18 & 0.541 &  3.00 \\
  AUT &  1.35 & 0.24 & 0.000 & -21.8 &  0.77 & 0.17 & 0.000 &  4.00 \\
  BEL &  5.14 & 0.24 & 0.000 & -60.7 & -1.55 & 0.17 & 0.000 &  5.00 \\
  BEN & -3.71 & 0.41 & 0.000 &  96.3 & -0.25 & 0.23 & 0.277 &  6.00 \\
  BGD & -0.42 & 0.27 & 0.116 &   8.0 &  0.54 & 0.21 & 0.010 &  7.00 \\                                             
  BOL & -2.61 & 0.31 & 0.000 &  60.7 & -0.09 & 0.21 & 0.668 &  8.00 \\                                           
  BRA &  2.21 & 0.25 & 0.000 & -33.1 &  1.27 & 0.18 & 0.000 &  9.00 \\                                            
  CAF & -4.04 & 0.52 & 0.000 & 108.6 &  0.33 & 0.24 & 0.169 & 10.00 \\                                          
  CAN &  3.32 & 0.24 & 0.000 & -45.3 &  0.11 & 0.17 & 0.518 & 11.00 \\                                           
  CHE &  2.19 & 0.24 & 0.000 & -32.8 &  0.75 & 0.17 & 0.000 & 12.00 \\                                           
  CHL &  2.39 & 0.26 & 0.000 & -35.3 & -0.39 & 0.18 & 0.030 & 13.00 \\                                          
  CHN &  4.40 & 0.24 & 0.000 & -55.1 &  0.76 & 0.17 & 0.000 & 14.00 \\                                           
  CMR & -1.50 & 0.30 & 0.000 &  31.5 & -0.43 & 0.20 & 0.032 & 15.00 \\                                          
  COL & -0.45 & 0.26 & 0.084 &   8.5 &  0.63 & 0.19 & 0.001 & 16.00 \\                                            
  CRI & -0.96 & 0.28 & 0.001 &  19.1 &  0.01 & 0.20 & 0.960 & 17.00 \\                                           
  DNK &  1.67 & 0.24 & 0.000 & -26.2 &  0.81 & 0.17 & 0.000 & 18.00 \\                                           
  DOM & -1.45 & 0.29 & 0.000 &  30.1 & -0.49 & 0.21 & 0.020 & 19.00 \\                                          
  ECU & -1.09 & 0.29 & 0.000 &  21.9 &  0.06 & 0.20 & 0.764 & 20.00 \\                                           
  EGY & -2.66 & 0.27 & 0.000 &  62.1 &  1.17 & 0.19 & 0.000 & 21.00 \\                                           
  ESP &  2.82 & 0.24 & 0.000 & -40.1 &  0.53 & 0.17 & 0.002 & 22.00 \\                                           
  ETH & -2.44 & 0.33 & 0.000 &  56.0 & -1.15 & 0.23 & 0.000 & 23.00 \\                                          
  FIN &  0.82 & 0.25 & 0.001 & -13.8 &  1.39 & 0.18 & 0.000 & 24.00 \\                                           
  FRA &  3.69 & 0.24 & 0.000 & -48.8 &  0.68 & 0.17 & 0.000 & 25.00 \\                                           
  GBR &  4.60 & 0.24 & 0.000 & -56.6 & -0.08 & 0.17 & 0.638 & 26.00 \\
  GHA & -0.51 & 0.32 & 0.109 &   9.8 & -1.50 & 0.22 & 0.000 & 27.00 \\
  GRC & -0.68 & 0.25 & 0.007 &  13.1 &  0.75 & 0.18 & 0.000 & 28.00 \\
  GTM & -2.28 & 0.29 & 0.000 &  51.2 & -0.03 & 0.20 & 0.881 & 29.00 \\
  HND & -2.96 & 0.32 & 0.000 &  71.3 & -0.46 & 0.20 & 0.021 & 30.00 \\
  IND &  1.86 & 0.25 & 0.000 & -28.6 &  1.24 & 0.18 & 0.000 & 31.00 \\
  IRL &  2.54 & 0.24 & 0.000 & -37.0 & -0.33 & 0.18 & 0.067 & 32.00 \\
  IRN & -2.35 & 0.31 & 0.000 &  53.4 &  1.20 & 0.23 & 0.000 & 33.00 \\
  ISR &  1.78 & 0.27 & 0.000 & -27.7 & -0.01 & 0.20 & 0.960 & 34.00 \\
  ITA &  3.48 & 0.24 & 0.000 & -46.9 &  0.85 & 0.17 & 0.000 & 35.00 \\
  JAM & -2.04 & 0.30 & 0.000 &  44.9 & -0.50 & 0.19 & 0.009 & 36.00 \\                                  
\end{longtable}
\end{document}

相关内容