1

I am trying to build a long three part table. The working codes are give below. Please let me know what is going wrong here.

    \begin{longtable}{
            l
                        >{\raggedright\arraybackslash}p{7cm}
                    >{\raggedright\arraybackslash}p{8cm}} 
\begin{threeparttable}
            \caption{Weighted Least Square Estimations – Outcome: $\Delta R_{(t+1)}$}
            \label{tab:wls1}\\
                \toprule
            \textbf{} &\textbf{(1)} & \textbf{(2)} & \textbf{(3)} & \textbf{(4)}
            \endfirsthead
            \caption{-- continued from previous page}\\
                \toprule
            \textbf{} &\textbf{(1)} & \textbf{(2)} & \textbf{(3)} & \textbf{(4)}
            \endhead
                \bottomrule
            \multicolumn{5}{r}{{Continued on next page}} \\
            \endfoot
                \bottomrule
            \endlastfoot    \midrule
                \multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{-0.0005} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.001} \\
        \multicolumn{1}{l}{b} & \multicolumn{1}{r}{-0.001} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.005} \\
        \multicolumn{1}{l}{c} & \multicolumn{1}{r}{-0.063***} & \multicolumn{1}{r}{-0.081***} & \multicolumn{1}{r}{-0.079***} & \multicolumn{1}{r}{-0.080***} \\
        \multicolumn{1}{l}{d} & \multicolumn{1}{r}{-0.082} & \multicolumn{1}{r}{-0.132**} & \multicolumn{1}{r}{-0.171***} & \multicolumn{1}{r}{-0.184***} \\
        \multicolumn{1}{l}{f} & \multicolumn{1}{r}{-0.255**} & \multicolumn{1}{r}{-0.253**} & \multicolumn{1}{r}{-0.307***} & \multicolumn{1}{r}{-0.278**} \\
        \multicolumn{1}{l}{g} & \multicolumn{1}{r}{0.022} & \multicolumn{1}{r}{0.015} & \multicolumn{1}{r}{0.004} & \multicolumn{1}{r}{-0.003} \\
        \multicolumn{1}{l}{a } & \multicolumn{1}{r}{-0.002***} & \multicolumn{1}{r}{-0.003***} & \multicolumn{1}{r}{-0.003***} & \multicolumn{1}{r}{-0.004***} \\
        \multicolumn{1}{l}{b} & \multicolumn{1}{r}{0.012} & \multicolumn{1}{r}{0.016} & \multicolumn{1}{r}{0.014} & \multicolumn{1}{r}{0.013} \\
        \multicolumn{1}{l}{c} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.004*} \\
        \multicolumn{1}{l}{d} & \multicolumn{1}{r}{-0.412***} & \multicolumn{1}{r}{-0.333***} & \multicolumn{1}{r}{-0.413***} & \multicolumn{1}{r}{-0.367***} \\
        \multicolumn{1}{l}{f} & \multicolumn{1}{r}{0.006*} &                  \multicolumn{1}{r}{0.006} & \multicolumn{1}{r}{0.004} & \multicolumn{1}{r}{0.003} \\
        \multicolumn{1}{l}{g} & \multicolumn{1}{r}{-0.012} & \multicolumn{1}{r}{-0.021*} & \multicolumn{1}{r}{-0.021*} & \multicolumn{1}{r}{-0.018} \\
        \multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.008**} & \multicolumn{1}{r}{0.011***} & \multicolumn{1}{r}{0.011***} & \multicolumn{1}{r}{0.012***} \\
        \multicolumn{1}{l}{b} & \multicolumn{1}{r}{-0.049***} & \multicolumn{1}{r}{-0.045***} & \multicolumn{1}{r}{-0.046***} & \multicolumn{1}{r}{-0.046***} \\
        \multicolumn{1}{l}{c} & \multicolumn{1}{r}{0.024**} & \multicolumn{1}{r}{0.021*} & \multicolumn{1}{r}{0.024*} & \multicolumn{1}{r}{0.027**} \\
        \multicolumn{1}{l}{d} & \multicolumn{1}{r}{-0.001} & \multicolumn{1}{r}{-0.036} & \multicolumn{1}{r}{-0.043} & \multicolumn{1}{r}{-0.027} \\
        \multicolumn{1}{l}{f} & \multicolumn{1}{r}{-0.011*} & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{0.0001} & \multicolumn{1}{r}{0.004} \\
        \multicolumn{1}{l}{g} & \multicolumn{1}{r}{-0.016} & \multicolumn{1}{r}{-0.016} & \multicolumn{1}{r}{-0.017} & \multicolumn{1}{r}{-0.018*} \\
        \multicolumn{1}{l}{a } & \multicolumn{1}{r}{-0.013**} & \multicolumn{1}{r}{-0.0002} & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{-0.004} \\
        \multicolumn{1}{l}{b} & \multicolumn{1}{r}{0.009} & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.006} & \multicolumn{1}{r}{0.012} \\
        \multicolumn{1}{l}{c} & \multicolumn{1}{r}{-0.268***} & \multicolumn{1}{r}{-0.229***} & \multicolumn{1}{r}{-0.249***} & \multicolumn{1}{r}{-0.226***} \\
        \multicolumn{1}{l}{d} & \multicolumn{1}{r}{0.011} & \multicolumn{1}{r}{0.008} & \multicolumn{1}{r}{0.009} & \multicolumn{1}{r}{0.011} \\
        \multicolumn{1}{l}{f} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.006} & \multicolumn{1}{r}{-0.007} \\
        \multicolumn{1}{l}{g} & \multicolumn{1}{r}{0.005} & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.005} & \multicolumn{1}{r}{0.003} \\
        \multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.0004} &         \multicolumn{1}{r}{0.002} & \multicolumn{1}{r}{0.002*} & \multicolumn{1}{r}{0.002} \\
        \multicolumn{1}{l}{b} & \multicolumn{1}{r}{0.053**} & \multicolumn{1}{r}{0.067**} & \multicolumn{1}{r}{0.064**} & \multicolumn{1}{r}{0.060**} \\
        \multicolumn{1}{l}{c} & \multicolumn{1}{r}{1.289} & \multicolumn{1}{r}{0.912} & \multicolumn{1}{r}{1.006} & \multicolumn{1}{r}{0.97} \\
        \multicolumn{1}{l}{d} &       & \multicolumn{1}{r}{-0.016**} & \multicolumn{1}{r}{-0.015*} & \multicolumn{1}{r}{-0.007} \\
        \multicolumn{1}{l}{f} &       & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.011} \\
        \multicolumn{1}{l}{g} &       & \multicolumn{1}{r}{-0.029***} & \multicolumn{1}{r}{-0.030***} & \multicolumn{1}{r}{-0.028***} \\
        \multicolumn{1}{l}{a } &       & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{0.002} \\
        \multicolumn{1}{l}{b} &       & \multicolumn{1}{r}{-0.005} & \multicolumn{1}{r}{-0.004} & \multicolumn{1}{r}{-0.007} \\
        \multicolumn{1}{l}{c} &       & \multicolumn{1}{r}{-0.016*} & \multicolumn{1}{r}{-0.014} & \multicolumn{1}{r}{-0.014} \\
        \multicolumn{1}{l}{d} &       &       & \multicolumn{1}{r}{-0.001} & \multicolumn{1}{r}{-0.001} \\
        \multicolumn{1}{l}{f} &       &       & \multicolumn{1}{r}{-0.006} & \multicolumn{1}{r}{-0.005} \\
        \multicolumn{1}{l}{g} &       &       & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.006} \\
        \multicolumn{1}{l}{a } &       &       & \multicolumn{1}{r}{0.008} & \multicolumn{1}{r}{0.011} \\
        \multicolumn{1}{l}{b} &       &       & \multicolumn{1}{r}{-0.018**} & \multicolumn{1}{r}{-0.018**} \\
        \multicolumn{1}{l}{c} &       &       & \multicolumn{1}{r}{0.002} & \multicolumn{1}{r}{-0.015} \\
        \multicolumn{1}{l}{d} &       &       & \multicolumn{1}{r}{0.0002} & \multicolumn{1}{r}{-0.019*} \\
        \multicolumn{1}{l}{f} &       &       & \multicolumn{1}{r}{0.002} & \multicolumn{1}{r}{-0.011} \\
        \multicolumn{1}{l}{g} &       &       & \multicolumn{1}{r}{-0.007} & \multicolumn{1}{r}{-0.016} \\
        \multicolumn{1}{l}{a } &       &       & \multicolumn{1}{r}{-0.015*} & \multicolumn{1}{r}{-0.030***} \\
        \multicolumn{1}{l}{b} &       &       &       & \multicolumn{1}{r}{0.004*} \\
        \multicolumn{1}{l}{c} &       &       &       & \multicolumn{1}{r}{0.009*} \\
        \multicolumn{1}{l}{d} &       &       &       & \multicolumn{1}{r}{-0.013} \\
        \multicolumn{1}{l}{f} &       &       &       & \multicolumn{1}{r}{0.0003} \\
        \multicolumn{1}{l}{g} &       &       &       & \multicolumn{1}{r}{0.042**} \\
        \multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.302***} &         \multicolumn{1}{r}{0.264***} & \multicolumn{1}{r}{0.288***} &         \multicolumn{1}{r}{0.270***} \\
        \midrule
        \multicolumn{1}{l}{Observations} & \multicolumn{1}{r}{1,210} &         \multicolumn{1}{r}{1,210} & \multicolumn{1}{r}{1,210} & \multicolumn{1}{r}{1,210} \\
        \multicolumn{1}{l}{R2} & \multicolumn{1}{r}{0.17} & \multicolumn{1}{r}{0.185} & \multicolumn{1}{r}{0.197} & \multicolumn{1}{r}{0.208} \\
        \multicolumn{1}{l}{Adjusted R2} & \multicolumn{1}{r}{0.151} & \multicolumn{1}{r}{0.162} & \multicolumn{1}{r}{0.168} & \multicolumn{1}{r}{0.176} \\
        \multicolumn{1}{l}{Residual Std. Error} & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.003} \\
        \multicolumn{1}{l}{F Statistic} & \multicolumn{1}{r}{8.989*** } &         \multicolumn{1}{r}{8.079***} & \multicolumn{1}{r}{6.662***} &         \multicolumn{1}{r}{6.367***} \\
        \midrule
        \multicolumn{5}{c}{*p<0.1; **p<0.05; ***p<0.01} \\
        \being{tablenotes}
\footnotesize
        This table provides the results of OLS. 
\end{tablenotes}
        \end{threeparttable}
        \end{longtable}%

The actual table should look like this. OLS

  • 1
    Since threeparttable makes a box, you'll ruin longtable. I've made an extension, threeparttablex, that can be used with longtable, see its manual for details (the interface is different) – daleif Nov 4 '16 at 16:38
  • Your comment in tablenotes can be set in a \multicolumn, so you doesn't need threepartable. – Zarko Nov 4 '16 at 18:02
  • as stated on your earlier questions you should post complete documents that reproduce the problem (the test document can be much smaller as it only needs two or three rows). Apart from the clearly spurious threeparttable environment (no environment woudl work in that position!) you have a table defined with three columns, then each row of the table has 4 & so a 5-column table. – David Carlisle Nov 4 '16 at 18:14
1

As I said in comment, for comment on the end of table you don't need threepartavble, it can be put in multicolumn environment, for example in

\multicolumn{5}{l}{\footnotesize
                   This table provides the results of OLS.
                    }

If you persist to use threepartable, than consider daleif comment.

Off-topic: Your table is unnecessary complicated (as the one in your previous question for which I already rewrote its code): all multicolumn{1}... are surplus, better result you obtain if for column type would use S column type from siunitx package. And not at the end, neaxt time please consider David Carlisle comment. If you like that we help you, please help us in this effort.

Completely revised your MWE is:

\documentclass[12pt, a4paper, twoside]{article}
\usepackage{array,booktabs,longtable,tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}% <-- added
\usepackage{caption}% <-- added

\usepackage{ltablex}% <-- added
\usepackage{siunitx}% <-- added
\usepackage[margin=30mm]{geometry}% <-- added

\usepackage{showframe}% don't use in real document
\renewcommand*\ShowFrameColor{\color{red}}% don't use in real document

\begin{document}
\begin{tabularx}{\textwidth}{X*{4}{S[table-format=-2.4,
                                     table-space-text-post=***]}
                            }
\caption{Weighted Least Square Estimations – Outcome: $\Delta R_{(t+1)}$}
\label{tab:wls1}\\
    \toprule
\textbf{} & {\textbf{(1)}} & {\textbf{(2)}} & {\textbf{(3)}} & {\textbf{(4)}}\\
\endfirsthead
\caption{-- continued from previous page}\\
    \toprule
\textbf{} & {\textbf{(1)}} & {\textbf{(2)}} & {\textbf{(3)}} & {\textbf{(4)}}\\
\endhead
    \bottomrule
\multicolumn{5}{r}{{Continued on next page}} \\
\endfoot
    \bottomrule
\endlastfoot    
    \midrule
a               & 0.001     & -0.0005   & -0.002    & -0.001    \\
b               & -0.001    & -0.003    & -0.003    & -0.005    \\
c               & -0.063*** & -0.081*** & -0.079*** & -0.080*** \\
d               & -0.082    & -0.132**  & -0.171*** & -0.184*** \\
f               & -0.255**  & -0.253**  & -0.307*** & -0.278**  \\
g               & 0.022     & 0.015     & 0.004     & -0.003    \\
    \addlinespace
a               & -0.002*** & -0.003*** & -0.003*** & -0.004*** \\
b               & 0.012     & 0.016     & 0.014     & 0.013     \\
c               & -0.002    & -0.002    & -0.003    & -0.004*   \\
d               & -0.412*** & -0.333*** & -0.413*** & -0.367*** \\
f               & 0.006*    & 0.006     & 0.004     & 0.003     \\
g               & -0.012    & -0.021*   & -0.021*   & -0.018    \\
    \addlinespace
a               & 0.008**   & 0.011***  & 0.011***  & 0.012***  \\
b               & -0.049*** & -0.045*** & -0.046*** & -0.046*** \\
c               & 0.024**   & 0.021*    & 0.024*    & 0.027**   \\
d               & -0.001    & -0.036    & -0.043    & -0.027    \\
f               & -0.011*   & 0.001     & 0.0001    & 0.004     \\
g               & -0.016    & -0.016    & -0.017    & -0.018*   \\
    \addlinespace
a               & -0.013**  & -0.0002   & 0.001     & -0.004    \\
b               & 0.009     & 0.007     & 0.006     & 0.012     \\
c               & -0.268*** & -0.229*** & -0.249*** & -0.226*** \\
d               & 0.011     & 0.008     & 0.009     & 0.011     \\
f               & -0.003    & -0.002    & -0.006    & -0.007    \\
g               & 0.005     & 0.007     & 0.005     & 0.003     \\
    \addlinespace
a               & 0.0004    & 0.002     & 0.002*    & 0.002     \\
b               & 0.053**   & 0.067**   & 0.064**   & 0.060**   \\
c               & 1.289     & 0.912     & 1.006     & 0.97      \\
d               &           & -0.016**  & -0.015*   & -0.007    \\
f               &           & 0.007     & 0.007     & 0.011     \\
g               &           & -0.029*** & -0.030*** & -0.028*** \\
    \addlinespace
a               &           & 0.001     & 0.001     & 0.002     \\
b               &           & -0.005    & -0.004    & -0.007    \\
c               &           & -0.016*   & -0.014    & -0.014    \\
d               &           &           & -0.001    & -0.001    \\
f               &           &           & -0.006    & -0.005    \\
g               &           &           & 0.003     & 0.006     \\
    \addlinespace
a               &           &           & 0.008     & 0.011     \\
b               &           &           & -0.018**  & -0.018**  \\
c               &           &           & 0.002     & -0.015    \\
d               &           &           & 0.0002    & -0.019*   \\
f               &           &           & 0.002     & -0.011    \\
g               &           &           & -0.007    & -0.016    \\
    \addlinespace
a               &           &           & -0.015*   & -0.030*** \\
b               &           &           &           & 0.004*    \\
c               &           &           &           & 0.009*    \\
d               &           &           &           & -0.013    \\
f               &           &           &           & 0.0003    \\
g               &           &           &           & 0.042**   \\
    \addlinespace
a               & 0.302***  & 0.264***  & 0.288***  & 0.270***  \\
    \midrule
Observations    & 1,210     & 1,210     & 1,210     & 1,210     \\
R2              & 0.17      & 0.185     & 0.197     & 0.208     \\
Adjusted R2     & 0.151     & 0.162     & 0.168     & 0.176     \\
Residual Std. Error & 0.003 & 0.003     & 0.003     & 0.003     \\
F Statistic     & 8.989***  & 8.079***  & 6.662***  & 6.367***  \\
\midrule
\multicolumn{5}{c}{*p<0.1; **p<0.05; ***p<0.01}                 \\
\multicolumn{5}{l}{\footnotesize
                   This table provides the results of OLS.
                    }
\end{tabularx}
\end{document}

enter image description here

  • Sorry for not providing the full document details. I will make sure that next time I provide all the necessary information. I am really grateful to you for your help. – Ahmed Arif Nov 6 '16 at 1:19
  • if you truthful grateful for my help, than you can express this with voting my answer :-). – Zarko Nov 6 '16 at 1:46
1

You don't need any of these \multicolumns. On the other hand, threeparttable doesn't work with longtable; you have to use threeparttablex, which has a slighlty different syntax, as commented by @daleif: the table notes must be declared at the beginnind, and inserted at the place you want with \insertTableNotes. I suggest using the S column type from  siunitx to have an alignment of the numbers in each column. As there seems to be groups of data (a,b,c,d,e,f,g,a,b,c,…), I separated them with \addlinespace. Also; I added some padding under the captions. Last, I think hard-coding upper case for tablename might also make it uppercase in cross references, so I preferred to define an uppercase label foramt:

\documentclass[a4paper]{article}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%
\usepackage{caption}
\DeclareCaptionLabelFormat{uppercase}{\MakeUppercase{#1}~#2}
\captionsetup{labelsep=newline, aboveskip=1ex, labelfont={bf}, labelformat = uppercase}
\usepackage{booktabs, siunitx}
\usepackage[svgnames]{xcolor}
\usepackage{longtable}
\usepackage[flushleft]{threeparttablex}

\begin{document}

\begin{ThreePartTable}
\sisetup{table-format=-1.3, table-number-alignment=center, table-space-text-post=***}
\begin{TableNotes}%
\footnotesize
\item[] * p < 0.1; ** p < 0.05; *** p < 0.01\medskip
\item[] This table provides the results of OLS.
\end{TableNotes}
\begin{longtable}{l*{4}{S}} \caption{Weighted Least Square Estimations – Outcome: $\Delta R_{(t+1)}$}
\label{tab:wls1}\\
    \toprule
&{\bfseries(1)} & {\bfseries(2)} &{\bfseries(3)} & {\bfseries(4)} \\%
\endfirsthead
\caption{-- continued from previous page}\\
\toprule
& {\bfseries(1)} & {\bfseries(2)} &{\bfseries(3)} & {\bfseries(4)}\\
\endhead
\bottomrule
\addlinespace
\multicolumn{5}{r}{\footnotesize Continued on next page} \\
\endfoot
\bottomrule
\addlinespace
\insertTableNotes\\
\endlastfoot %
\midrule
a & 0.001 & -0.0005 & -0.002 & -0.001 \\
b & -0.001 & -0.003 & -0.003 & -0.005 \\
c & -0.063*** & -0.081*** & -0.079*** & -0.080*** \\
d & -0.082 & -0.132** & -0.171*** & -0.184*** \\
f & -0.255** & -0.253** & -0.307*** & -0.278** \\
g & 0.022 & 0.015 & 0.004 & -0.003 \\
\addlinespace
a & -0.002*** & -0.003*** & -0.003*** & -0.004*** \\
b & 0.012 & 0.016 & 0.014 & 0.013 \\
c & -0.002 & -0.002 & -0.003 & -0.004* \\
d & -0.412*** & -0.333*** & -0.413*** & -0.367*** \\
f & 0.006* & 0.006 & 0.004 & 0.003 \\
g & -0.012 & -0.021* & -0.021* & -0.018 \\
\addlinespace
a & 0.008** & 0.011*** & 0.011*** & 0.012*** \\
b & -0.049*** & -0.045*** & -0.046*** & -0.046*** \\
c & 0.024** & 0.021* & 0.024* & 0.027** \\
d & -0.001 & -0.036 & -0.043 & -0.027 \\
f & -0.011* & 0.001 & 0.0001 & 0.004 \\
g & -0.016 & -0.016 & -0.017 & -0.018* \\
\addlinespace
a & -0.013** & -0.0002 & 0.001 & -0.004 \\
b & 0.009 & 0.007 & 0.006 & 0.012 \\
c & -0.268*** & -0.229*** & -0.249*** & -0.226*** \\
d & 0.011 & 0.008 & 0.009 & 0.011 \\
f & -0.003 & -0.002 & -0.006 & -0.007 \\
g & 0.005 & 0.007 & 0.005 & 0.003 \\
\addlinespace
a & 0.0004 & 0.002 & 0.002* & 0.002 \\
b & 0.053** & 0.067** & 0.064** & 0.060** \\
c & 1.289 & 0.912 & 1.006 & 0.97 \\
d & & -0.016** & -0.015* & -0.007 \\
f & & 0.007 & 0.007 & 0.011 \\
g & & -0.029*** & -0.030*** & -0.028*** \\
\addlinespace
a & & 0.001 & 0.001 & 0.002 \\
b & & -0.005 & -0.004 & -0.007 \\
c & & -0.016* & -0.014 & -0.014 \\
d & & & -0.001 & -0.001 \\
f & & & -0.006 & -0.005 \\
g & & & 0.003 & 0.006 \\
\addlinespace
a & & & 0.008 & 0.011 \\
b & & & -0.018** & -0.018** \\
c & & & 0.002 & -0.015 \\
d & & & 0.0002 & -0.019* \\
f & & & 0.002 & -0.011 \\
g & & & -0.007 & -0.016 \\
\addlinespace
a & & & -0.015* & -0.030*** \\
b & & & & 0.004* \\
c & & & & 0.009* \\
d & & & & -0.013 \\
f & & & & 0.0003 \\
g & & & & 0.042** \\
\addlinespace
a & 0.302*** & 0.264*** & 0.288*** & 0.270*** \\
\midrule
Observations & 1,210 & 1,210 & 1,210 & 1,210 \\
R2 & 0.17 & 0.185 & 0.197 & 0.208 \\
Adjusted R2 & 0.151 & 0.162 & 0.168 & 0.176 \\
Residual Std. Error & 0.003 & 0.003 & 0.003 & 0.003 \\
F Statistic & 8.989*** & 8.079*** & 6.662*** & 6.367*** \end{longtable}%
\end{ThreePartTable}

\end{document} 

enter image description here enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.