Announcement

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

  • creating LaTex formatted tables in Mac OS X

    I am seeking to create a table created in Stata, and output to LaTex format.
    Below is my Stata code, and prior to running this I have specified the directory containing the top.tex and bot.tex files.

    HTML Code:
    sysuse cancer, clear
    label var died "Patient died"
    la def ny  0 ”No” 1 ”Yes”, modify
    la val died ny
    recode studytime (min/10 = 1 "10 or less months") ///
                (11/20 = 2 "11 to 20 months") ///
                (21/30 = 3 "21 to 30 months") ///
                (31/max = 4 "31 or more months") ///
                , gen(stime)
    la var stime "To died or exp. end"
    tabout stime died using table1.txt, ///
        cells(freq col cum) format(0 1) clab(No. Col_% Cum_%) ///
        replace ///
        style(tex) bt  cl1(2-10) cl2(2-4 5-7 8-10) font(bold) ///
        topf(top.tex) botf(bot.tex) topstr(14cm) botstr(cancer.dta)
    The Stata viewer produces what looks like a correctly formatted set of LaTex code.
    However, the final command
    HTML Code:
    texify table1.txt
    returns the following error code:
    /bin/bash: pdflatex: command not found

    I would very much appreciate assistance or tips appropriate for someone without any LaTex experience.


  • #2
    I think Roy Wada needs to update texify. I'm not sure if he still updates his programs, though.

    This line…
    Code:
    !pdflatex `temp'
    …needs to be something like this
    Code:
    shell PATH=\$PATH:/usr/local/bin:/Library/TeX/texbin && pdflatex `temp'
    This might not work, but I suggest using the following code in place of the texify command:
    Code:
    shell ///
        PATH=\$PATH:/usr/local/bin:/Library/TeX/texbin /// latexmk and pdflatex live here
        && latexmk -pdf --shell-escape "table1.txt"
    I'm not sure if the directories need to be changed manually, but if we're lucky it's that simple. You could also try the command above in place of the texify command:
    Code:
    shell PATH=\$PATH:/usr/local/bin:/Library/TeX/texbin && pdflatex table1.txt
    Last edited by Nils Enevoldsen; 14 Jun 2016, 10:00.

    Comment


    • #3
      Dear Nils, brilliant! It was in fact that simple, and I'm very appreciative. This command worked perfectly.
      HTML Code:
        shell PATH=\$PATH:/usr/local/bin:/Library/TeX/texbin && pdflatex table1.txt
      I suppose the reason I didn't need to specify the location of my LaTex code file is that Stata still has in working memory the path I specified for creating it.

      Comment


      • #4
        Nils, may I ask in follow-up, what is the cause of the following LaTex error message, which occurred when I tried to reproduce my results:

        This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
        restricted \write18 enabled.
        entering extended mode
        (./table1.txt
        LaTeX2e <2015/01/01>
        Babel <3.9l> and hyphenation patterns for 79 languages loaded.

        ! LaTeX Error: Missing \begin{document}.

        See the LaTeX manual or LaTeX Companion for explanation.
        Type H <return> for immediate help.
        ...

        l.1 \begin{center}

        ?
        ! Emergency stop.
        ...

        l.1 \begin{center}

        ! ==> Fatal error occurred, no output PDF file produced!
        Transcript written on table1.log.


        Comment


        • #5
          I think you are trying to compile (i.e. turn-tex-into-pdf) a single table, instead of a complete LaTeX document with paragraphs of text and multiple tables. The file produced by your code, table1.txt (which I still suggest you should rename to table1.tex), is probably just a table.

          I think you should add the body option to tabout. This option will automatically create a minimal document around the table, such that the LaTeX file consists of a table in an otherwise empty document. Without knowing how you are using this table, this is my best guess as to what you want.

          An alternative way of using tabout is to have another hand-made file that is your LaTeX document, e.g. paper.tex, containing paragraphs of text and so forth, and in that document you "link" to table1. I won't show you that syntax now, because I don't think you're doing that.

          Comment

          Working...
          X