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

Sharpie chuck at sharpsteen.net
Tue Mar 23 03:31:44 CET 2010

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?
> Thanks,
> Clay

The "undefined control sequence" error from LaTeX usually means you haven't
loaded a latex package that provides a given command or environment.  Just
as you have to load a package in R using library() or require() before you
can use functions from that package, you have to specify in your LaTeX
document that you are going to use a given package before you can use
commands for that package.  This is indicated by adding:


Somewhere before the \begin{document} statement in your Sweave/LaTeX file. 
If you don't have the package installed, you will get an error message that
looks like:

  ! LaTeX Error: File `packageName.sty' not found.

You can check to see if a given LaTeX package is installed on your system
using the kpesewhich command that works similarly to the Unix/Linux command

  kpsewhich packageName.sty

If kpsewhich doesn't return a path to a .sty file, then the package you
attempted to find is not installed on your LaTeX search path.  Since you are
using MacTex 2009 which is based on TeXlive 2009, you can use the TeXlive
package manager to install missing packages from the command line:

  tlmgr install packageName

Since you are using a Mac, there is a GUI option to perform all this
searching and installing without having to use the command line (although it
is always a good idea to know how to do something from the command line).
Simply download Tex Live Utility from the following website:


It provides a nice GUI from which you can install and update TeX based
packages and utilities.

Hope this helps!


Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
View this message in context: http://n4.nabble.com/ctable-error-with-Hmisc-and-Sweave-on-a-Mac-tp1678494p1678588.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list