11

I am trying to use the \input command to insert a table produced by STATA (statistics software). The problem is that I am unable to adjust the size of the table, I have tried \resizebox and other options with various errors. My code looks like this:

\documentclass[12pt, a4paper, abstracton, norsk]{scrartcl}          

\usepackage[onehalfspacing]{setspace}               
\usepackage[T1]{fontenc}                            
\usepackage[utf8, latin1]{inputenc}                 
\usepackage{graphicx}


\begin{document}


\clearpage
\begin{singlespace}

\begin{table}

\input{table}

\end{table}


\end{singlespace}

\end{document}

the table.tex file looks something like this:

\begin{center}
\begin{tabular}{lcc} \hline
 & (1) & (2) \\
 & ACA & ACA \\
 & str\_all & str\_all \\
VARIABLES & Baseline FE & full controls \\ \hline
\vspace{4pt} & \begin{footnotesize}\end{footnotesize} & \begin{footnotesize}\end{footnotesize} \\
str\_all\_1982 & 0.0159 & 0.0234 \\
\vspace{4pt} & \begin{footnotesize}(0.0131)\end{footnotesize} & \begin{footnotesize}(0.0143)\end{footnotesize} \\
Share age>60 &  & -0.303 \\
\vspace{4pt} & \begin{footnotesize}\end{footnotesize} & \begin{footnotesize}(0.371)\end{footnotesize} \\
Constant & 0.876*** & 0.910*** \\
 & \begin{footnotesize}(0.00104)\end{footnotesize} & \begin{footnotesize}(0.0938)\end{footnotesize} \\
\vspace{4pt} & \begin{footnotesize}\end{footnotesize} & \begin{footnotesize}\end{footnotesize} \\
Observations & 118,319 & 117,831 \\
$R^2$ & 0.016 & 0.025 \\
Cohortdummies & yes & yes \\
Kommunedummies & yes & yes \\
clustering & kommune & kommune \\
Fylkesdummies & no & no \\
vgo fixed & no & no \\
komm time trend & no & no \\
fylke time trend & no & no \\
 Kommuner & 235 & 235 \\ \hline
\multicolumn{3}{c}{\begin{footnotesize} Robust standard errors in parentheses\end{footnotesize}} \\
\multicolumn{3}{c}{\begin{footnotesize} *** p$<$0.01, ** p$<$0.05, * p$<$0.1\end{footnotesize}} \\
\end{tabular}
\end{center}
7

The problem is environment center that does not work inside \resizebox. Also it is not the best choice for centering in environment table, because environment center adds vertical space. The example locally disables environment center in the table and uses \centering instead. \resizebox is now working like expected:

\documentclass[12pt, a4paper]{scrartcl}

\usepackage{graphicx}

\begin{document}

\begin{table}
\let\center\empty
\let\endcenter\relax
\centering
\resizebox{.5\width}{!}{\input{table}}
\end{table}

\end{document}

Result

Additional remark:

  • Only the latest option in \usepackage[utf8,latin1]{inputenc} is used, thus specifying several options does not make too much sense. If you are unsure about the encoding, take a look at package selinput.

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.