LaTeX Table to Standalone

formattinglatex-to-wordpdfstandalonetables

I have a relatively complicated table with a lot of manual adjustments to the column widths and spacing that I am trying to convert to a standalone pdf (for the purpose of ultimately inserting it into a Word Doc). The original table text is below:

\begin{table}[h!]
\begin{center}
\begin{tabularx}{0.7\textwidth}{>{\raggedright\arraybackslash}X  >{\raggedleft\arraybackslash}X }
\hline
\hline
\vspace{1mm}
 & Initiate conflict \\
\Xhline{2\arrayrulewidth}
First = female                      & $-0.08$      \\
                                            & $(0.05)$     \\
Second = prefer not to say         & $-0.21$      \\
                                            & $(0.18)$     \\
Third = non-binary/non-conforming  & $-0.18$      \\
                                            & $(0.12)$     \\
(Intercept)                                 & $0.35^{***}$ \\
                                            & $(0.03)$     \\
\hline
R$^2$                                       & $0.01$       \\
Adj. R$^2$                                  & $0.01$       \\
Num. obs.                                   & $404$        \\
\hline
\hline
\multicolumn{2}{l}{\scriptsize{$^{***}p<0.001$; $^{**}p<0.01$; $^{*}p<0.05$}}
\end{tabularx} \\
\parbox{11cm}{\caption{Random caption inserted as a placeholder for what I am actually going to say, which will be a sentence or two long in the end I think.}}
\label{table:coefficients}
\end{center}
\end{table}

Any guidance on how to successfully make this work in a document type standalone would be greatly appreciated. Alternatively, if there is an easier way to put such a table into a Word Doc, I am open to suggestions.

Best Answer

I don't think that using a tabularx environment with two equally wide columns and some ensuing line-breaks in the first column generates a good layout. I'd go with a basic tabular environment, use l for the first column, and align the numbers in the second column. To force the width of the legend to be the same as the tabular material above it, I suggest you employ a threeparttable wrapper.

enter image description here

\documentclass[border=2pt]{standalone}
\usepackage{booktabs,threeparttable,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c@{}}{#1}} % handy shortcut macro

\begin{document}

\begin{threeparttable}
\begin{tabular}{@{} l d{2.3} @{}}
\toprule
 & \mc{Initiate conflict} \\
\midrule
First = female                     & -0.08      \\
                                   & (0.05)     \\
Second = prefer not to say         & -0.21      \\
                                   & (0.18)     \\
Third = non-binary/non-conforming  & -0.18      \\
                                   & (0.12)     \\
(Intercept)                        & 0.35^{***} \\
                                   & (0.03)     \\
\addlinespace
R$^2$                              & 0.01       \\
Adj.\ R$^2$                        & 0.01       \\
Num.\ obs.                         & \mc{404}   \\
\midrule[\heavyrulewidth]
\multicolumn{2}{@{}l}{\scriptsize $^{***}\ p<0.001$; $^{**}\ p<0.01$; $^{*}\ p<0.05$} 
\end{tabular}

Random caption inserted as a placeholder for what I am actually going to say, which will be a sentence or two long in the end I think.
\end{threeparttable}

\end{document}
Related Question