Announcement

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

  • Adding new LaTeX packages to texsave

    I am using Julian Reif's -texsave- to create some tables, but I would like to use other packages that alter the look of the table that are not supported. Currently, I am using the line editor ex to insert the usepackage on line 6 of the tex file after it is created:

    Code:
    #delimit;
    sysuse auto, clear;
    keep in 1/10;
    
    texsave price mpg using "results.tex"
    , title("Some Cars Data")
    headlines("\captionsetup[table]{labelformat=empty}") 
    headerlines("\pagenumbering{gobble}")
    varlabels landscape replace;
    
    /* insert usepackge on line 6 */
    !ex -sc '6i|\usepackage{caption}' -cx results.tex;
    
    !/Library/TeX/texbin/pdflatex results.tex;
    !open results.pdf;
    Is there a more elegant way of doing this that I am missing?

  • #2
    The only thing I could think of would be to modify the source code itself. When I’ve had to generate a bunch of LaTeX output in the past I’ve typically created an ado file that writes the LaTeX source and uses macro evaluation to provide values in the appropriate locations.

    Comment


    • #3
      I usually just wrap texsave into a texdoc document (both external programs installed via -findit-) so that I can load the latex packages of interest. Here's a MWE (that works on my machine with MacOSX, TexShop, Stata 15.1 MP with my 'pdflatex' installation paths specified). HTH


      Code:
       sysuse auto, clear
       
        
      
      
      
       **default example from texdoc:
       cap texdoc close
       texdoc init myexample.tex, replace force // (forced b/c run within this do file)
      
          
          texdoc write    \documentclass{article}
          
          **insert lots of packages:
           texdoc write      \usepackage{graphicx, caption, hyperref,stata,lscape,tabularx,booktabs}
      
           texdoc write   \begin{document}
      
           texdoc write   \section{Exercise 1}
           texdoc write   Open the 1978 Automobile Data and summarize the variables.
      
           
      
              texdoc stlog
              sysuse auto, clear
              summarize
              texdoc stlog close
      
      
      **texsave frag:
      preserve
      keep in 1/10
         texsave price mpg using "results.tex" ///
        , title("Some Cars Data") frag ///
      headlines("\captionsetup[table]{labelformat=empty}")  ///
      headerlines("\pagenumbering{gobble}") ///
      varlabels landscape replace 
      restore 
      
          texdoc write \input{results.tex}
          
      
      
         
      
           texdoc write   \section{Exercise 2}
           texdoc write   Run a regression of price on milage and weight.
      
           
      
              texdoc stlog
              regress price mpg weight
              texdoc stlog close
      
             
      
          texdoc write    \end{document}
         
      
              
          cap  texdoc close 
          **compile/open (if everything is installed in paths below)    
          loc md `"`c(pwd)'"'
              if "`c(os)'" == "Windows"  shell pdflatex "`md'myexample.tex"
              if "`c(os)'" == "MacOSX"  shell /Library/TeX/texbin/pdflatex --shell-escape  "`md'/myexample.tex"
      
                  di as smcl `"CLICK TO OPEN: {browse `"myexample.pdf"' }"'
      Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

      Comment


      • #4
        That said, I've contemplated editing the ado for - texsave - (as Billy Buchanan suggests) because this challenge comes up in my workflow often. Wrapping it in a standalone -texsave- doc is a lot of extra work, and I keep hoping Julian Reif will update -texsave- with options for [, packages(list)] so that I dont have to mess with the core code.
        Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

        Comment


        • #5
          I was afraid that this was the solution. Thanks you both for good suggestions!

          Comment


          • #6
            This thread was recently brought to my attention. I have added a -preamble()- option to -texsave- that adds the feature requested by Dimitriy. You can download the updated version from Github.
            Code:
            net install texsave, from("https://raw.githubusercontent.com/reifjulian/texsave/master") replace
            Associate Professor of Finance and Economics
            University of Illinois
            www.julianreif.com

            Comment

            Working...
            X