# LaTeX finds .cls file but not .sty file in ~/texmf directory

I'm writing a paper that depends on a file elsarticle.cls and also a file clrscode3e.sty (they're for two different things - not related). I have placed both files in my ~/texmf directory. When I remove anything in my .tex file dependent on clrscode3e.sty and compile with LaTeX, everything is fine and from the output formatting i can see that elsarticle.cls has clearly been recognised. When I add something which depends on clrscode3e.sty, I get "File clrscode3e.sty not found". To verify that I hadn't mistyped anything, I tried moving clrscode3e.sty into the same directory as the .tex file being compiled and everything worked fine. Why would LaTeX recognise a .cls file in my ~/texmf directory but not a .sty file?

-
Put it in ~/texmf/tex/latex/SOMENAME and run texhash. See tex.stackexchange.com/questions/2063/… and other previous related questions. –  Leo Liu Feb 11 '11 at 8:15
Could it be the case that the cls is already installed in your distribution and it is read from the main tex-tree rather than you local one? –  Martin H Feb 11 '11 at 8:36
@Martin H: AFAIK the user directory should come first, but this is of course a matter of configuration. –  Martin Scharrer Feb 11 '11 at 9:39
@Martin Scharrer: True, but maybe not in if the cls is not in the correct folder within the local tree. That is what I implied –  Martin H Feb 11 '11 at 12:26
@Martin Scharrer: What Martin H. means is that the local cls and sty are both in a wrong folder which is not searched, and that a second version of the cls exists in a correct location. –  Ulrike Fischer Feb 11 '11 at 14:32

The most likely answer here is that neither file is being loaded from ~/texmf, but that the .cls file is also installed correctly in the main TeX tree. The way to work this out is to look at the .log file which TeX produces. Each file loaded will include the location it was loaded from, so a quick search for the relevant files should reveal where they are loaded from.
In general, TeX will find any .cls or .sty file inside ~/texmf/tex/latex, although you may need to run texhash before this happens. (Recent versions of TeX Live do not require you to run texhash on your local tree, whereas older ones do.)