1

I have two tex files that I want to combine in order to make one table. In the first.tex, the data is like this:

var 1 & num & num & num & num \\
      & num & num & num & num \\

I have a second.tex that has the same structure as before, even the same variable name:

var 1 & num & num & num & num \\
      & num & num & num & num \\

Both tex files are exported from STATA without columns names or notes. My desired output would be something like this:

var 1 & num & num & num & num & num & num  \\
      & num & num & num & num & num & num  \\

Therefore, I am hiding column 4 in both tex files, and column 1 of the second tex file. My issue is on how I include both tex file and have a fixed table header.

Within the document tex file, I have created a table using threeparttable

\begin{table}[H]
\centering
\caption{Balance: \label{tab:summary_rct1}}
\begin{threeparttable}
\centering
%\begin{tabular}{l*{1}{ccHcHccHc}}
\toprule
& (1) & (2) &  & (3) &  & (4) & (5) &  & (6) \\
& T   &  C  &  &  D  &  &  T  &  C  &  &  D  \\
\midrule
\addlinespace
\input{tables/first.tex}%
\input{tables/second.tex}%
\end{tabular}
\begin{tablenotes}
\footnotesize
\item Some footnotes
\end{tablenotes}
\end{threeparttable}
\end{table}

As you notice, given that the header is fixed, I have to hide column 4, column 6 and column 9. If I do the above code, the second.tex file will be positioned below first.tex but I wanted to be next to it.

Is there a clean way to do this? I have tried what it is expressed in this post, only using the first.tex and second.tex without including the table header like this:

\begin{tabular}{lccHc}
\input{first}%
\end{tabular}%
\begin{tabular}{HccHc}
\input{second}%
\end{tabular}

Nonetheless, when I include the table header and use threeparttable, I don't get my desired output.

0

Well, it was quite easier than I expected. You can have two different input files and combine them as follows:

Imagine you have two files: file1 and file2, and you need to be side by side but the table headers should be included plus some table notes. Therefore, using threeparttable package:

\begin{table}[H]
\centering
\begin{threeparttable}
\caption{A caption here \label{label}}
\begin{tabular}[t]{@{}l@{}l}
\toprule
\begin{tabular}[t]{@{}lHcHc}
&   & \multicolumn{3}{c}{Year 1}                    \\ 
\cmidrule(lr){2-5}
&   & \multirow{2}{*}{Control}  &   &   Treatment   \\  
&   &                           &   &   Effect      \\
&   &   (1)                     &   &    (2)        \\  
\midrule 
\addlinespace
\input{file1}
\end{tabular}
&
\begin{tabular}[t]{HHcHc}
&   & \multicolumn{3}{c}{Year 3}                    \\ 
\cmidrule(l){2-5}
&   & \multirow{2}{*}{Control}  &   &   Treatment   \\  
&   &                           &   &   Effect      \\
&   &   (3)                     &   &    (4)        \\  
\midrule 
\addlinespace   
\input{file2}
\end{tabular}
\tabularnewline \bottomrule
\end{tabular}
\begin{tablenotes}
\footnotesize
\item Some table notes here
\end{tablenotes}
\end{threeparttable}
\end{table}

There are 3 tabulars: one that connects the other two tabulars. And within the first tabular we specify the top rule and the bottom rule (in this case, wee need \tabularnewline to properly set the bottom rule. Also, both tabular should have the same structure, if they do not have it, the table would be badly allocated. This is how I solved my question. I am not sure weather this is most effective way to do it but it does the work.

|improve this answer|||||

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.