Announcement

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

  • Escaping % in esttab with latex (without breaking graphs)

    I am generating a number of graphs and latex files, where I want to use the variable label as the label in the table (and graphs). But the labels will frequently have a % sign in them. To illustrate:
    Code:
    sysuse auto
    label variable price "% price" 
    twoway (scatter price mpg)
    eststo: quietly regress price weight mpg
    esttab using example.tex, replace label
    Note that the label "% price" works fine in the twoway graph, but in the "example.tex" file, the % turns into a latex comment as it is not properly escaped.

    Is there any way around this or estout features I am missing?

    I realize I can use:
    Code:
    label variable price "\% price"
    which fixes the latex issue, but it breaks the graphs. It would be a pain to constantly switch back and forh.

  • #2
    Did you try adding the option "substitute(% \%)"? It's an option of -estout- (which is the low-level command -esttab- uses), and all options of -estout- can also be used with -esttab-. The following works for me:
    Code:
    sysuse auto
    label variable price "% price"
    twoway (scatter price mpg)
    eststo: quietly regress price weight mpg
    esttab , tex label substitute(% \%)
    Regards
    Bela

    Comment


    • #3
      Perfect, thanks!

      Comment

      Working...
      X