Announcement

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

  • tabout - latex table label

    Hi,
    I am using tabout by Ian Watson to produce/export crosstabs in latex. I cannot find a way to introduce a label for the table from within the stata code. This means that I have to manually edit the latex table to be able to reference the table from within my latex document. For example, in latabstat, this was possible with the clabel option, or in esttab it can be done via "title( \label{})".
    Is there anything like this for tabout?
    Thanks a lot,
    Eva

  • #2
    Have you looked at

    http://www.ianwatson.com.au/stata/tabout_tutorial.pdf

    There are some LaTex examples

    Ronnie
    010100100110111101101110011011100110100101100101

    Comment


    • #3
      This can be achieved using the top and bot options of tabout. For example, you can define a custom table header top.tex as follows
      Code:
      \begin{table}[htbp]
      \caption{#}
      \label{#}
      \begin{center}
      \footnotesize
      \newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
      \begin{tabularx} {\textwidth} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
      \toprule
      The two # placeholders will be replaced by text in the topstr option of tabout. For the footer of the table, you can define bot.tex as
      Code:
      \bottomrule
      \addlinespace[.75ex]
      \end{tabularx}
      \normalsize
      \end{center}
      \end{table}
      Place top.tex and bot.tex in the folder where your tabout table is going to be. I will draw from one of the examples of Ian Watson's tutorial to create a LaTex document with a crossreference to a table. I am using the user written commands texdoc and maketex.

      Code:
      * Set up table as in tabout example 1
      sysuse cancer, clear
      la 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"
      * Notice the topstr option
      tabout stime died using table1.tex, ///
      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("A caption" | "mylabel")
      
      * Start tex document
      texdoc init example.tex, replace
      tex This is table \ref{mylabel}
      tex \include{table1}
      texdoc close
      
      * Make a ready to compile document out of tex
      maketex using example.tex, packages(tabularx booktabs)
      * Compile and show
      ! texify -p -c -b --run-viewer example.tex
      The key here is to notice that topstr("A caption" | "mylabel") places text in the # placeholders.


      Jorge Eduardo Pérez Pérez
      www.jorgeperezperez.com

      Comment


      • #4
        Thank you very much. This works perfectly!
        Eva

        Comment


        • #5
          This can now be done much more easily with Version 3 of -tabout- which as of this writing must be downloaded and installed manually from the -tabout- website. To include a table label in a tex document the syntax looks like this:

          Code:
          tabout race south using table38.tex, replace ///
          style(tex) font(bold) c(freq row) f(0c 1) ///
          doctype(report) caplab(racebysouth) cappos(below) ///
          title(Example of caption below table) fn(nlsw88.dta)
          where -caplab- is the table label. See page 93 of the Version 3 manual: http://tabout.net.au/downloads/tabout_user_guide.pdf.

          Comment

          Working...
          X