Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Here is a table using ltablex package. Can someone tell me how I can include caption and use threeparttable with this one. Fyi, when I used:

\begin{table} 
begin{tabularx} 
...
\end{tabularx} 
\end{table}` 

the page did not break for me. Suggestions would be extremely helpful. I want to include caption and footnotes as given in this example Table formatting.

\documentclass{article}
\usepackage{ltablex}
\usepackage{threeparttable}
\usepackage{booktabs}

\title{Document}
\begin{document}
\maketitle

\begin{tabularx}{\textwidth}{Xc}
\toprule\toprule
Some random text & 1,75,650\\\midrule
\multicolumn{2}{l}{\textbf{Panel A1: AAA}} \\\midrule
Number of observations ... & 1,75,650\\
Delete: ... & (78,420)\\
Delete: ... & (7,104)\\
Final sample & 90,126\\
Delete: & (2,143)\\
Delete: & (8,345)\\
Final sample & 79,638\\\midrule
\multicolumn{2}{l}{\textbf{Panel A2: AAA}} \\\midrule
Number of observations & 79,638\\
Delete: & (39,540)\\
Delete: & (7,979) \\
Final sample & 32,119 \\\midrule
\multicolumn{2}{l}{\textbf{Panel B1: BBB }} \\\midrule
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\\midrule
\multicolumn{2}{l}{\textbf{Panel B2: BBB}} \\\midrule
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\\midrule\bottomrule
\end{tabularx}

\end{document}
share|improve this question
    
what do you mean by "break" (line breaking or page breaking)? tabularx doesnt break over a page. In any case please always provide a complete document showing al packages used, not a fragment that can't be processed on its own. –  David Carlisle Mar 23 at 12:28
    
Done editing. The following code in the presence of ltablex package does break over pages. –  Sumit Mar 23 at 12:45
    
Did you try the threeparttablex package? It allows using threeparttable in long tables. –  Bernard Mar 23 at 13:16
    
@Bernard I did try that, but it seems that it doesn't work with ltablex package, which I require to get tabularx features in long table. Any other solutions? –  Sumit Mar 23 at 13:22
    
@Sumit: look at my answer: it does seem OK. Or did I miss something? –  Bernard Mar 23 at 13:56

3 Answers 3

up vote 2 down vote accepted

The threeparttablex seems to work for me: in the following, I inserted the table notes inside the long table, and also at the end. No problem for the caption either. You have to write the table notes just after \begin{ThreePartTable} and to compile twice.

        \documentclass{article}
        \usepackage{ltablex}
        \usepackage{threeparttablex}
        \usepackage{booktabs}
        \usepackage[bf,tablename=TABLE,labelsep=newline,aboveskip=0pt]{caption}

        \title{Document}
        \begin{document}
        \maketitle
        \begin{ThreePartTable}
        \begin{TableNotes}
        \item[a] \label{tn:a}1st lovely note.
        \item[b] \label{tn:b}2nd lovely note.
        \end{TableNotes}
        \begin{tabularx}{\textwidth}{Xc}
        \caption{A Fine Caption}\\
        \toprule\toprule
        Some random text & 1,75,650\\\midrule
        \multicolumn{2}{l}{\textbf{Panel A1: AAA}} \\\midrule
        Number of observations ...\tnote{tn:a} & 1,75,650\\
        Delete: ... & (78,420)\\
        Delete: ... & (7,104)\\
        Final sample & 90,126\\
        Delete: & (2,143)\\
        Delete: & (8,345)\\
        Final sample\tnote{tn:b} & 79,638\\\midrule
        \multicolumn{2}{l}{\textbf{Panel A2: AAA}} \\\midrule
        Number of observations & 79,638\\
        Delete: & (39,540)\\
        Delete: & (7,979) \\
        Final sample & 32,119 \\\midrule
        \insertTableNotes\\[12pt]\midrule
        \multicolumn{2}{l}{\textbf{Panel B1: BBB }} \\\midrule
        Number of observations  & 1,75,650\\
        Delete: & (78,420)\\
        Delete: & (47,136)\\
        Delete: & (7,178)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Final sample & 42,884\\\midrule
        \multicolumn{2}{l}{\textbf{Panel B2: BBB}} \\\midrule
        Number of observations  & 1,75,650\\
        Delete: & (78,420)\\
        Delete: & (47,136)\\
        Delete: & (7,178)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Number of observations  & 1,75,650\\
        Delete: & (78,420)\\
        Delete: & (47,136)\\
        Delete: & (7,178)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Delete: & (32)\\
        Final sample & 42,884\\\midrule\bottomrule
        \insertTableNotes
        \end{tabularx}
        \end{ThreePartTable}

        \end{document} 

enter image description here

share|improve this answer
    
Thanks for the information. I was using \begin{threeparttable}, but it seems that for threeparttablex, the correct env. is in capital letter. Very cool. Thanks. –  Sumit Mar 23 at 13:59

Try this:

\documentclass{article}
\usepackage{ltablex}
\usepackage{threeparttablex}
\usepackage{booktabs}
\usepackage{caption}
\title{Document}
\begin{document}
\maketitle
\captionof{table}{TITLE}
\begin{ThreePartTable}
\begin{tabularx}{\textwidth}{Xc}
\toprule\toprule
Some random text\tnote{a} & 1,75,650\\\midrule
\multicolumn{2}{l}{\textbf{Panel A1: AAA}} \\\midrule
Number of observations ... & 1,75,650\\
Delete: ... & (78,420)\\
Delete: ... & (7,104)\\
Final sample & 90,126\\
Delete: & (2,143)\\
Delete: & (8,345)\\
Final sample & 79,638\\\midrule
\multicolumn{2}{l}{\textbf{Panel A2: AAA}} \\\midrule
Number of observations & 79,638\\
Delete: & (39,540)\\
Delete: & (7,979) \\
Final sample & 32,119 \\\midrule
\multicolumn{2}{l}{\textbf{Panel B1: BBB }} \\\midrule
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\\midrule
\multicolumn{2}{l}{\textbf{Panel B2: BBB}} \\\midrule
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\\midrule\bottomrule
\end{tabularx}
\begin{tablenotes}
\item[a]  TEXT-TEXT   
\end{tablenotes}
\end{ThreePartTable}
\end{document}

Try this with longtabu environment:

\documentclass[a4,12pt]{article}
\usepackage{caption}
\usepackage{longtable}   
\usepackage{tabu}
\usepackage{threeparttablex} 
\title{Document}
\begin{document}
\maketitle
Text-Text
\captionof{table}{TITLE.}
\begin{ThreePartTable}
\begin{longtabu}{cc}
\tabucline[2pt]{-}
Some random text\tnote{a} & 1,75,650\\
\tabucline[1pt]{-}
\multicolumn{2}{l}{\textbf{Panel A1: AAA}} \\
\tabucline[1pt]{-}
Number of observations ... & 1,75,650\\
Delete: ... & (78,420)\\
Delete: ... & (7,104)\\
Final sample & 90,126\\
Delete: & (2,143)\\
Delete: & (8,345)\\
Final sample & 79,638\\
%\tabucline[1pt]{-}
\multicolumn{2}{l}{\textbf{Panel A2: AAA}} \\
\tabucline[1pt]{-}
Number of observations & 79,638\\
Delete: & (39,540)\\
Delete: & (7,979) \\
Final sample & 32,119 \\
\tabucline[1pt]{-}
\multicolumn{2}{l}{\textbf{Panel B1: BBB }} \\
\tabucline[1pt]{-}
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\
\tabucline[1pt]{-}
\multicolumn{2}{l}{\textbf{Panel B2: BBB}} \\
\tabucline[1pt]{-}
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\
\tabucline[2pt]{-}
\end{longtabu}
\begin{tablenotes}
\item[a]  TEXT-TEXT   
\end{tablenotes}
\end{ThreePartTable}
\end{document}
share|improve this answer

An alternative is to use resizebox from graphicx package so that the table can be kept in one piece without break. Also there is no need to use threepart table, since there's no problem adding the content at the bottom of the tabular, as long as \multicolumn is the first element in a cell -- quote from Werner fellow user.

enter image description here

Code

\documentclass{article}
%\usepackage[margin=1cm]{geometry}
\usepackage{ltablex,graphicx}
%\usepackage{threeparttable}
\usepackage{booktabs}

\title{Document}
\begin{document}
\author{A. Author}
\maketitle

\begin{table}[htbp]
\resizebox{0.75\textwidth}{!}{
\begin{minipage}{\textwidth}
\caption{The caption goes here}
\begin{tabularx}{\textwidth}{Xc}
\toprule\toprule
Some random text & 1,75,650\\\midrule
\multicolumn{2}{l}{\textbf{Panel A1: AAA}} \\\midrule
Number of observations ... & 1,75,650\\
Delete: ... & (78,420)\\
Delete: ... & (7,104)\\
Final sample & 90,126\\
Delete: & (2,143)\\
Delete: & (8,345)\\
Final sample & 79,638\\\midrule
\multicolumn{2}{l}{\textbf{Panel A2: AAA}} \\\midrule
Number of observations & 79,638\\
Delete: & (39,540)\\
Delete: & (7,979) \\
Final sample & 32,119 \\\midrule
\multicolumn{2}{l}{\textbf{Panel B1: BBB }} \\\midrule
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\\midrule
\multicolumn{2}{l}{\textbf{Panel B2: BBB}} \\\midrule
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Number of observations  & 1,75,650\\
Delete: & (78,420)\\
Delete: & (47,136)\\
Delete: & (7,178)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Delete: & (32)\\
Final sample & 42,884\\
\midrule\bottomrule
\multicolumn{1}{l}{\rule{0pt}{1.2\normalbaselineskip}
 \textsuperscript{***} comment 1,     \textsuperscript{**} comment 2,     \textsuperscript{*} comment 3}
\end{tabularx}
\end{minipage}
}
\end{table}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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