Announcement

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

  • esttab exporting an extra "\" to .tex

    Hello!
    When assigning coefficient labels on esttab, I'm writing the following:

    (...)
    Code:
     coeflabel(var1 "\(\text{name}_{t - 1}\)")
    (...)

    But the resulting export to .tex is the following:
    Code:
    \(\text{name}\_{t - 1}\)
    So, esttab is adding an extra \ before _{t -1}. If I export to .rtf, it gives me: name_t - 1, so the \ isn't added.
    Not sure if it matters, but this happens when exporting results from a logit model. The variable is continuous. The reason that I want the_{t -1}, is that it automatically becomes a subscript in latex code, indicating that the variable is lagged.
    Does anyone know how to avoid the \ getting added?

    Thanks in advance for your time!
    Hélder Costa
    Last edited by Helder Costa; 16 Nov 2021, 08:41.

  • #2
    estout is from the Stata Journal/ SSC, as you are asked to explain (FAQ Advice #12). Probably the opposite problem is more pervasive, i.e., intending to have an underscore and ending up with a subscript. I would not advocate changing the default. Also note that the underscore indicates a subscript in math mode, so you should probably surround the whole thing with dollar signs.

    Code:
    sysuse auto, clear
    regress mpg weight disp, nocons
    esttab, varlab(weight "weight\$_{78}\$") substitute("\_" "_") tex
    Res.:

    Code:
    . esttab, varlab(weight "weight\$_{78}\$") substitute("\_" "_") tex
    
    {
    \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
    \begin{tabular}{l*{1}{c}}
    \hline\hline
                &\multicolumn{1}{c}{(1)}\\
                &\multicolumn{1}{c}{mpg}\\
    \hline
    weight$_{78}$&      0.0138\sym{***}\\
                &      (9.83)         \\
    displacement&      -0.111\sym{***}\\
                &     (-5.54)         \\
    \hline
    \(N\)       &          74         \\
    \hline\hline
    \multicolumn{2}{l}{\footnotesize \textit{t} statistics in parentheses}\\
    \multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
    \end{tabular}
    }
    Last edited by Andrew Musau; 16 Nov 2021, 09:16.

    Comment


    • #3
      Thank you very much Andrew Musau!

      Comment

      Working...
      X