2

I'm using threeparttablex and tabularx packages.

I have 2 problems:

  1. caption only enumerates right if put before \begin{tabularx};
  2. notes are not center aligned with the table;

enter image description here

My code is the following:

\documentclass{article}

\usepackage{booktabs,ltablex,threeparttablex}

\def\tabularxcolumn#1{m{#1}}
\newcolumntype{L}{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}X}


\begin{document}

\begin{table}[ht]
  \begin{ThreePartTable}
    \begin{tabularx}{\textwidth}{LL}
    \toprule
    ex1 & ex2\\
    ex3 & ex4\\
    \bottomrule
    \end{tabularx}%
    \begin{tablenotes}\footnotesize
            \item[a] note1.
            \item[b] note2.
    \end{tablenotes}
    \caption{Example.}\label{tab:dummy}%
    \end{ThreePartTable}
\end{table}

\end{document} 

I've tried many approaches: using tabularx with threeparttable instead, with captionof{table}{caption} and the problem is the same: if I put it before tabularx env. it works, else the caption number increments by two (so I have Table 2.2, 2.4, 2.6 and so on... ); if I use tabular instead, it works fine both ways. I don't get it....

What am I doing wrong? I really have to use tabularx though...

7
  • What is the Lspecifier?
    – Bernard
    Jan 21, 2015 at 19:23
  • 1
    I've added some code from your previous question to show the problem. Hope you don't mind. Jan 21, 2015 at 20:16
  • To center the notes, simply add \centering inside tablenotes. Why do you need tabularx? Jan 21, 2015 at 20:19
  • 1
    @karlkoeller: Actually, ltablex loads tabularx(and perhaps patches it, didn't check).)
    – Bernard
    Jan 21, 2015 at 20:41
  • You can clearly see that ltablex makes the tabularx environment do wrong.
    – egreg
    Jan 21, 2015 at 20:55

1 Answer 1

1

An unorthodox solution: put the caption inside the tabularx environment (as would be done for longtable). Some comments about your code: with threeparttablex, the tablenotes is replaced with TableNotes is declared at the very beginning, and is inserted later wheare you please with the \insertTableNotes commands. Also, if you really want to have a table with true X columns, you have to use the \keepXColumns command; else the calculated X width is only the maximum width of columns.

\documentclass{article}

\usepackage{array, ltablex}%
\usepackage{caption}
\usepackage{threeparttablex}
\setTableNoteFont{\footnotesize}

\usepackage{booktabs}
\keepXColumns

\begin{document}

\section{A First Section}
\begin{table}[ht]
\begin{ThreePartTable}
\begin{TableNotes}
\item[a] note1.
\item[b] note2.
\end{TableNotes}

\begin{tabularx}{\textwidth}{*{2}{X}}%
\toprule
\endhead
\bottomrule
\endfoot
ex1 & ex2\\
ex3 & ex4\\
\bottomrule
\insertTableNotes\\
\caption{Example1.}\label{tab:dummy}
\end{tabularx}%%
\end{ThreePartTable}
\end{table}

\begin{table}[ht]
\begin{ThreePartTable}
\begin{TableNotes}\footnotesize
\item[a] note1.
\item[b] note2.
\end{TableNotes}

\begin{tabularx}{\textwidth}{*{2}{X}}%
\caption{Example 2.}\label{tab:dummy}\\
\toprule
\endhead
\bottomrule
\endfoot
ex1 & ex2\\
ex3 & ex4\\
\bottomrule
\insertTableNotes\\
\end{tabularx}%%
\end{ThreePartTable}
\end{table}

\end{document} 

enter image description here

12
  • As mentioned in My comment above, ThreePartTable and TableNotes are intended with longtable. Does not make much sense with other constructions
    – daleif
    Jan 21, 2015 at 21:58
  • I've used ThreePartTable with tabularx via ltablex, because most of the times I have really big tables that cross pages, which is not this case in particular. I will try your suggestions. Thanks
    – neverMind
    Jan 21, 2015 at 23:01
  • @Bernard your example 1 works just fine for me. I always use tabularx. I just loaded the ltablex (which requires tabularx,right?) because of the long tables I've added before (with 1endhead, \endfoot an so...).
    – neverMind
    Jan 21, 2015 at 23:11
  • @neverMind: I didn't test an example of a tabularx environment that breaks across pages, so I'm not sure it works in such a case.
    – Bernard
    Jan 21, 2015 at 23:31
  • 1
    Yes, but if threeparttablex doesn't work with tabularx that break across pages? That's what I meant.
    – Bernard
    Jan 22, 2015 at 0:48

You must log in to answer this question.

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