3

I have the problem that my caption is very far away from my table and I can't find a reason and solution for that. Can anyone help me to solve it? I already tried

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

but that did not work :(

     \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}

Glad for any help, GZ

2
  • 2
    you have two blank lines after the caption. what is the intention of three consecutive \\ with no text? \\ \label{table:essexx} \\ \\ Sep 22, 2015 at 15:39
  • I would never use tabularx/tabu X columns with numeric data, far better to set them natural width aligned using dcolumn or siunitx Sep 22, 2015 at 15:41

3 Answers 3

6
            \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) 

puts two blank lines between the caption the hline then another blank line before "Cntry", You want

          \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) 

Never use a \\ after \hline.

1
  • I'm deeply sorry for my useless editing, it seems I should go to bed right now...
    – user2574
    Sep 22, 2015 at 20:51
3

You had a lot of mistakes in your given code. I corrected them (including that one pointed out by @DavidCarlisle). I did a prettyprint for your table. In this way it is easier to see where numbers or & are missing or more than needed ... You have booktabs in your preamble but you did not use it, why?

The last big errors I commented out (see the leading %) in the following corrected code:

\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}
2

Instead of using a longtabu environment, you may want to use a longtable environment. I would also suggest you use the S column type, provided by the siunitx package, to decimal-align all numbers in columns 2 through 9 and to get math-mode - (minus) symbols instead of dashes for the negative numbers in the table.

enter image description here

enter image description here

\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}
2
  • I really thank you for that help, the table looks very nice now. What I forgot is that I want to have smaller spacing in the table, thats why I put the longtabu in a \begin{spacing}{0.8} environment, that does not work with your code anymore. Since I have 77 observations my table would cover 4 pages without smaller spacing. Do you have an idea how to shrink it?
    – xm0riTzx
    Sep 23, 2015 at 9:20
  • @MoritzHemmerlein - You're welcome. :-) On the spacing issue: You could issue the instruction \begin{singlespacing} before \begin{longtable}...} and issue the instruction \end{singlespacing} after \end{longtable}. I wouldn't make it more cramped than single-spacing, as the readability will suffer greatly if you issued a command such as \setstretch{0.8}.
    – Mico
    Sep 23, 2015 at 9:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .