# [R] ctable error with Hmisc and Sweave (on a Mac)

Marc Schwartz marc_schwartz at me.com
Tue Mar 23 03:24:29 CET 2010

On Mar 22, 2010, at 8:31 PM, Rolf Turner wrote:

>
> On 23/03/2010, at 12:35 PM, Clay Heaton wrote:
>
>> Hi, pretty new with R and LaTeX here...
>>
>> I'm trying to use the latex() function from the Hmisc table with Sweave. When I try:
>>
>> pdflatex myfile.tex
>>
>> I get an error that reads:
>>
>> ! Undefined control sequence.
>> l.22 \ctable
>>
>>
>> It seems like this is an optional package for Tex that I haven't installed? My googling skills have neglected to locate instructions for how to install ctable on a Mac, though I've locate the ctable package. I reinstalled MacTex-2009 in hopes of solving the problem, but so far it hasn't helped.
>>
>> Can anybody shed light on this error and how I might fix it?
>
>
> What does
>
> 	locate ctable
>
> (typed in a terminal window) give you?  I get (a whole load of stuff) and
>      .
>      .
>      .
> /usr/local/texlive/2008/texmf-dist/doc/latex/easy/doc.dvi/doctable.dvi
> /usr/local/texlive/2008/texmf-dist/source/latex/ctable
> /usr/local/texlive/2008/texmf-dist/source/latex/ctable/ctable.dtx
> /usr/local/texlive/2008/texmf-dist/source/latex/ctable/ctable.ins
>      .
>      .
>      .
>
> Also does
>
> 	texdoc ctable
>
> give any results?
>
> If either of these commands gives a result, then you *have* ctable.  The reason
> that pdflatex isn't finding it may relate to your tex search path (controlled by
> the environment variable TEXINPUTS) --- but normally you should not need to set this.

Another basic thing to check on is to be sure that you have:

\usepackage{ctable}

in the .Rnw file preamble (before the \begin{document} directive).

If you have installed the full MacTeX package, you should have the Tex Live Utility, which is used to update/install/manage TeX packages. This can be found in Applications/TeX. Run that and you can check to see whether ctable is installed or not. If not, you can add it there. Some more information is here: