Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tabout error: 'Misplaced alignment tab character &'

    I'm trying to export tables to LaTeX, using tabout.
    Code:
    sysuse auto
    tabout foreign using test.tex, c(freq cell cum) f(0c,1) style(tex) replace
    This is the output:
    Code:
    Car type&No.&\%&\% \\
    \hline
    Domestic&52&70&70 \\
    Foreign&22&30&100 \\
    Total&74&100& \\
    However, when I compile my .tex document, I get the error "Misplaced alignment tab character &" for every '&' in test.tex.
    Code:
    \documentclass{article}
    \begin{document}
    \begin{table}
      \input{test.tex}
    \end{table}
    \end{document}
    I'm using tabout version 2.0.7, and I get the same behavior on Stata 12 and Stata 14.
    Last edited by Michael Wiebe; 27 Nov 2017, 00:44.

  • #2
    Read the help file on Latex file contents, page 33: http://www.ianwatson.com.au/stata/tabout_tutorial.pdf

    Otherwise, use esttab, which I think has simpler syntax. Example:
    Code:
    sysuse auto
    eststo: quietly regress price weight mpg
    eststo: quietly regress price weight mpg foreign
    esttab using example.tex, label nostar title(Regression table\label{tab1})

    Comment


    • #3
      Okay, the solution is to create `top.tex` and `bot.tex` files, as defined on p.33 of the tutorial. Then the code is:
      Code:
      tabout foreign using test.tex, c(freq cell cum) f(0c,1) clab(Freq % Cum_%) style(tex) topf(top.tex) botf(bot.tex) replace
      However, this still produces an ugly table. Instead I used `esttab`:
      Code:
      estpost tab for
      esttab . using test.tex, replace cell((b(fmt(0)) pct(fmt(2)) cumpct(fmt(2))))

      Comment

      Working...
      X