[Tex/LaTex] Latex cannot find `.sty` files

installingmactexpackagestexlive

I am on a mac and I believe I am using MacTeX. I am getting errors of the sort:

File `fullpage.sty' not found.

When I run locate fullpage.sty I get

/usr/local/texlive/2013/texmf-dist/tex/latex/preprint/fullpage.sty

But when I run kpsewhich fullpage.sty I get nothing. I have already tried sudo texhash and sudo mktexlsr to no avail. I think the problem may be that I have two conflicting TeX Live versions installed—I recently installed QuTIP and I think during the process a basic version was installed via macports—but of this I am not certain. I have no idea how to proceed.

I have two questions: How can I get LaTeX to find fullpage.sty? And, if someone can see the real cause of the above error or knows how to find it, how can I remedy the situation?

Best Answer

Old question, but this is a common problem. If you installed via MacTeX, TeX Live will end up in /usr/local/texlive, but I believe MacPorts installs under /opt by default (it did last time I checked, but it's been a few years). Hence, you do indeed have two conflicting TeX distributions, and you're running kpsewhich from the MacPorts install. If you enter which kpsewhich in Terminal, it probably points to /opt/local/bin/kpsewhich or something similar.

The easiest way to fix this is to edit your PATH environment variable so that /usr/texbin comes first. If you're using bash, your ~/.bash_profile, you would have something like

PATH=/usr/texbin:/opt/local/bin:/usr/bin:…:/foo/bar/bin

Alternately, if macports sets your PATH by sourcing a script in ~/.bash_profile, as Fink does (or did), you can add a final line to your profile of

PATH=/usr/texbin:$PATH

A couple of notes:

  • this will not affect PATH settings for any GUI applications, only programs launched from a shell
  • for a TeX Live not installed via MacTeX, you'd use the appropriate full path, e.g., /usr/local/texlive/2013/bin/x86_64-darwin instead of /usr/texbin
Related Question