1

Here is a working example illustrating my problem:

\documentclass[12pt]{article}
\usepackage{booktabs, ltablex, siunitx, threeparttablex}
\usepackage[labelsep=endash, skip=5pt]{caption}
\newcommand{\rowgroup}[1]{\hspace{-2em}#1}  % for indentation tables
\sisetup{
    group-separator={,},
    group-four-digits=true,
    table-space-text-pre    = (,
    table-space-text-post   = ),
    table-space-text-post= \textsuperscript{*},
    retain-explicit-plus,
    input-open-uncertainty  = ,
    input-close-uncertainty = ,
    table-align-text-pre    = false,
    table-align-text-post   = false,
    round-mode=places,
    round-precision = 2,
    tight-spacing = true 
}
\keepXColumns
\usepackage{setspace}


 \begin{document}

\setstretch{0.85}


First table is Table \ref{tab:t1}:

\begin{ThreePartTable}
\small

\begin{TableNotes}[flushleft]\footnotesize
    \item \textit{Notes:} Bla ...
\end{TableNotes}

\begin{tabularx}{0.9\textwidth}{ @{\hspace*{\leftmargin}}
    l  S[table-format=+1.2]  S[table-format=-1.2]  }

\caption {Alternative explanations; estimates for firm size regressions}\label{tab:t1} \\ \toprule

& {Low unemployment} & {High unemployment} \\
& {(1)} & {(2)} \\ \cmidrule(r){2-3}
\endfirsthead

\multicolumn{3}{c}%
    {\vspace{5pt}{\tablename\ \thetable{} -- continued from previous page}} \\ \midrule
& {Low unemployment} & {High unemployment} \\
& {(1)} & {(2)} \\ \cmidrule(r){2-3}
\endhead

\multicolumn{3}{c}%
    {\textit{Continue to next page}} \\ \midrule
\endfoot

\endlastfoot

\addlinespace
\rowgroup{\textit{Panel A: Buniness cycle conditions}}
    & {\phantom{Low unemployment}} & {\phantom{High unemployment}} \\ \addlinespace

{Year 1}
& {...} & {...}\\
& ({...}) & ({...}) \\ 
{Year 2}
& {...} & {...} \\
& ({...}) & ({...}) \\ 
{Year 3}
& {...} & {...} \\
& ({...}) & ({...}) \\ \midrule

\end{tabularx}
\vspace{-20pt}  

\begin{tabularx}{0.9\textwidth}{ @{\hspace*{\leftmargin}}
    l  S[table-format=-1.2]  S[table-format=-1.2]  }

& {Low unemployment} & {High unemployment} \\
& {(1)} & {(2)} \\ \cmidrule(r){2-3}

\addlinespace
\rowgroup{\textit{Panel B: ...\phantom{iness cycle conditions}}}
& {\phantom{Low unemployment}} & {\phantom{High unemployment}} \\ \addlinespace

{Year 1}
& {...} & {...}\\
& ({...}) & ({...}) \\ 
{Year 2}
& {...} & {...} \\
& ({...}) & ({...}) \\ 
{Year 3}
& {...} & {...} \\
& ({...}) & ({...}) \\ 

\bottomrule
\insertTableNotes
\endlastfoot

\end{tabularx}

\end{ThreePartTable}

Second table is Table \ref{tab:t2}:

\begin{table}[h!]
    \caption{\label{tab:t2} The second table}
    \centering
    \begin{tabular}{ccc}
        \toprule
        column 1 & column 2 & column 3 \\ \midrule
        ... & ... & ... \\
        ... & ... & ... \\ \bottomrule
    \end{tabular}
\end{table}


\end{document}

The issue is that the labels numbering is inflated by one when compiling first table, so that the second table appears to be Table 3, and not Table 2. Thanks for any suggestions.

EDIT:

For those interested in why I actually need two tabularx nested inside the ThreePartTable environment, see this question. In short, I use one tabularx for each panel of the table in order to be able to flexibly set the siunitx columns in each panel.

3
  • As a workaround, you always can add at the very beginning of the second table \addtocounter{table}{-1}. But have you any reason to use two tabularx environment for the first table?
    – Bernard
    Commented Apr 2, 2017 at 14:08
  • Hi, yes I need it (see the Edit). I need to have different siunitx settings for each panel of the table. It is not obvious from this example, but it is from the one at the link I posted. Commented Apr 2, 2017 at 14:11
  • I see. I tested various possibilities, and the only thing that worked was the manual workaround I mention in my previous comment.
    – Bernard
    Commented Apr 2, 2017 at 15:27

2 Answers 2

1

A workaround consists in adding, just after \begin{table}[h!] for the next table:

\addtocounter{table}{-1}

enter image description here

1

Sorry, don't have the right to add a comment yet, so have to post this as an answer. The problem is that you are using 2 x tabularx (so basically 2 tables) to generate the first table. There is not need for this. Make the first table so that you generate a single table with 3 columns and 5 rows. You can use http://www.tablesgenerator.com/ initially to set up your table and then change it accordingly if you want to use tabularx instead of tabular.

4
  • Hi, I have to disagree. In my real-world project I actually need to use multiple tabularx since each of them has different suinitx settings (in terms of decimals after the comma and other details). Commented Apr 2, 2017 at 13:00
  • Okay, I didn't realise this. However, could you not set those per column, by adding it to the column format definition, e.g. S[table-format=+1.2, round-precision = 2 ...]?
    – Tina
    Commented Apr 2, 2017 at 15:10
  • @Stina Definitely, but you set up this setting for all tables in the document. If you need different decimal positions in each panel (e.g. because you have one panel with measures in Th. Dollars and another with differently measured variables) you need some kind of workaround. One is to have two separate tabularx, each with different table-formats. See the details in the link for more info. Commented Apr 2, 2017 at 15:48
  • Or alternatively you can see the problem in case you want to add a panel with "number of observations" (thousands or hundreds of thousads) under a variable that is a share, measured between 0 and 1. You can still get the alignment but it looks awful... so you basically need for the same column different aligment settings. Commented Apr 2, 2017 at 15:54

You must log in to answer this question.

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