2

I have managed to make statweave produce pdf, though not much what I want. How can I format the output of statweave to give what I want, for example:

  1. Remove the source code
  2. format tables
  3. output selected column from stata tables.
  4. is the formating of the statweave depend on the Latex? (e.g. tables)
  5. Is there special edit in saving the swv file extensions
2
  • 1
    As stated this question will be very hard to answer. Can you post a minimal example of what you are doing, and what you want to change? Also, this looks like many questions in one, which is also not the best way to ask questions here. It's ok to ask multiple questions, but you need to make them a bit more explicit so that people can help you better.
    – Alan Munn
    Sep 24 '11 at 18:00
  • @huu: Your session expired and this created a second unregistered, but identical looking account for you. New users can only comment on post their wrote or the answers to them. I merged both accounts together and converted you answer post to a comment. Please consider registering your account to avoid this in the future. Thanks!
    – Martin Scharrer
    Sep 25 '11 at 8:18
1

I'll attempt to answer your questions, but since I use R and not Stata, I will not be able to answer them in full, although the general ideas will be the same.

  1. First, you can remove the source code in a StatWeave document by adding echo=false to the options passed to the code chunk. This is described in section 5.3 of the StatWeave manual. e.g.:

    \begin{Statacode}{echo=false} % plus any other options you need
    ...
    \end{Statcode}
    
  2. Any formatting of tables via LaTeX must be done using tools within Stata. It's possible to do minor formatting of the output passed to StatWeave, but if you want nicely formatted tables (using, e.g. booktabs or similar LaTeX packages, you will need to have Stata produce the relevant LaTeX which will then be passed back to StatWeave. You need to add the output option results=tex to tell StatWeave to treat the output as LaTeX rather than verbatim text.) I have no direct experience with such tools in Stata, but here is a link that might help: Stata Tools for LaTeX.

  3. This is addressed by (2) above.

  4. This is addressed by (2) above.

  5. I'm not sure what you mean by this question. If you mean is there a special editor for creating StatWeave files, I think the answer is no, you should be able to use any text editor. I use a Mac, and can edit such files from within TeXShop. Most TeX-aware editors allow you to add new tools to compile files, so you should be able to tell your editor to run both StatWeave on your .swv file and pdflatex on the generated .tex file.

1
  • Alan Munn, Thanks for your response.will work on it and come back to you. cheers
    – huu
    Sep 24 '11 at 23:25
0

I'm giving StatWeave a try and Alan Munn's answer has been helpful to me. However, I came across another tex-related problem when using StatWeave and maybe the simple solution I found is useful for future reference:

Once you manage to create a .tex-file from your initial .swv-file using StatWeave, you come to the point where you need to compile the .tex-file in a program such as TeXnicCenter to obtain a proper .pdf-file. The problem I encountered was that this .pdf-file looked horrible (the fonts were blurred, etc.) compared to the usual .pdf-files I manage to compile.

By trial-and-error I found out the following: StatWeave adds a line to your .tex-file, namely \usepackage{Statweave} (just before your usual \begin{document} command). This package is the problem - without further inquiring into it, I suspect that it tells TeXnicCenter to use bitmap (i.e., Type 3) fonts instead of scalable Type 1 or TrueType fonts (even if you usually use scalable Type 1 or TrueType fonts).

Here is a simple work-around to obtain nice looking .pdf-files (well, it is simple if you used Sweave before, if not you have to install it first): simply replace in the .tex-file created by StatWeave the line \usepackage{Statweave} by \usepackage{Sweave}. TeXnicCenter should be able to compile the file without yielding error messages (NB: I also tried to simply delete the line \usepackage{Statweave} but then I got an error message from biblatex).

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.