Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: sjlog with variable names containing underscores


From   Venable <[email protected]>
To   [email protected]
Subject   st: sjlog with variable names containing underscores
Date   Sun, 14 Nov 2010 10:35:13 -0500

Hi all,

I really like the sjlog command for creating latex-compatible log files.

However, I am having a small problem:

I frequently use underscore characters in variable names, and LaTeX
interprets underscore as "start doing math and begin a subscript."
This causes problems when compiling the pdf.

As a minimal working example, I make a small modification to the very
nice example on the UCLA Stata website:
http://www.ats.ucla.edu/stat/stata/latex/verbatim.htm


The only modification is to create a duplicate of the race variable
called race_clone.

[begin example]

.use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear
(highschool and beyond (200 cases))

. clonevar race_clone = race

. sjlog using desc_hsb2

. describe

Contains data from http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta
  obs:           200                          highschool and beyond (200 cases)
 vars:            12                          17 Jun 2002 08:48
 size:        10,400 (99.9% of memory free)
--------------------------------------------------------------------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
--------------------------------------------------------------------------------------------------------------------------------------------
id              float  %9.0g
female          float  %9.0g       fl
race            float  %12.0g      rl
ses             float  %9.0g       sl
schtyp          float  %9.0g       scl        type of school
prog            float  %9.0g       sel        type of program
read            float  %9.0g                  reading score
write           float  %9.0g                  writing score
math            float  %9.0g                  math score
science         float  %9.0g                  science score
socst           float  %9.0g                  social studies score
race_clone  float  %9.0g
--------------------------------------------------------------------------------------------------------------------------------------------
Sorted by:
     Note:  dataset has changed since last saved

. sjlog close
(note: file c:\desc_hsb2.smcl.bak not found)

. sjlog type desc_hsb2.log.tex
{\smallskip}
. describe
{\smallskip}
Contains data from http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta
  obs:           200                          highschool and beyond (200 cases)
 vars:            12                          17 Jun 2002 08:48
 size:        10,400 (99.9\% of memory free)
\HLI{79}
              storage  display     value
variable name   type   format      label      variable label
\HLI{79}
id              float  \%9.0g
female          float  \%9.0g       fl
race            float  \%12.0g      rl
ses             float  \%9.0g       sl
schtyp          float  \%9.0g       scl        type of school
prog            float  \%9.0g       sel        type of program
read            float  \%9.0g                  reading score
write           float  \%9.0g                  writing score
math            float  \%9.0g                  math score
science         float  \%9.0g                  science score
socst           float  \%9.0g                  social studies score
race_duplicate  float  \%9.0g
\HLI{79}
Sorted by:
     Note:  dataset has changed since last saved

.
[end example]


Note that the variable name race_duplicate is going to cause the
problem mentioned above.

Is there some sort of workaround for this? I notice that the %
character, which is the LaTeX comment command, is accomodated by using
\%, which latex interprets as "this really is a percent symbol, not a
comment command." Is is possible to do the same for underscores?

Many thanks in advance.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index