This question is very similar to a previous post: Where do I place my own .sty or .cls files, to make them available to all my .tex files?

I am using MiKTeX 2.9 and TeXnicCenter to compose and execute my LaTeX file(s) on Windows 7. I am using a template from Elsevier to submit a journal article, but I am getting the LaTeX Error that File 'numcompress.sty' not found. This file is currently located in the same directory as the other elsarticle files: C:\Program Files (x86)\MikTex 2.9\tex\latex\elsarticle. I have actually followed the directions posted to the above question exactly: https://tex.stackexchange.com/a/20121/ but still have had no change in outcome.

  • 2
    If numcompress.sty is in this directory, and you clicked refresh FNDB, it should works. Did you try to compile your file without TeXnic center?
    – corentin
    Jul 20, 2012 at 20:52
  • Here's a walk through on downloading, compiling and installing your own custom latex packages: inf.ed.ac.uk/systems/tex/new-packages.html Feb 19, 2017 at 1:39

8 Answers 8


Are you using MikTeX as User or as administrator? To be safe change to adminstrator, check wheather your file numcompress.sty is really in the directory C:\Program Files (x86)\MikTex 2.9\tex\latex\elsarticle. Now start MiKTeX 2.9 over Windows start -> all programms. Choose Maintenance (Admin), then Settings (admin) (Admin is important!). Now choose General and click Refresh FNDB. Afterwards you can change to user again and run MiKTeX. Refresh FNDB means refresh your database for the used filenames.


As others answer already said: You should update the FNDB in admin mode if you put files in the main miktex tree. But it is not recommended to use this tree for local additions. Your additions can get lost when miktex updates packages. Use either one of the other trees (UserConfig or CommonConfig) or (better) use a new local tree: Create (e.g.) C:\mylocaltree\tex\latex\elsarticle, copy your file in this folder and then add C:\mylocaltree as a new root in miktex settings.

  • This is the correct answer. The others are advising you to create big headaches for yourself in the future, or anyone else who needs to compile your source. If you add a local file to the distibution tree, it will get lost when you upgrade to a new version, and you will no longer be able to compile any document that uses it.
    – Davislor
    Jun 24, 2020 at 7:32

First, launch the Windows cmd line as administator and search for an .sty file that you know is present and works using the findtexmf utility, e.g.

findtexmf colortbl.sty

Ensure that your .sty file is in a similar location.

Now, update the filename database using the initexmf utility:

initexmf --admin -u
initexmf --admin --dump

The first one refreshes the filename database and the second performs other updates. You may not need both but it won't hurt.


With MikTeX installed you have access to Texworks at the All Programs/MikTeX/ menu. Try loading and compiling from that IDE. If it will not compile from TeXworks then the *.sty has not been properly registered.

If this fails then use My Computer and actually verify that the files are exactly where you think they are. (The Windows defaults for file saving can easily trip you up.)


Absolutely do not add a local file to your MikTeX distribution folder. You will create a big headache when you upgrade, it disappears, and you will no longer be able to compile your document. The journal might not even still have the version you need available for download when you want to recompile it years later.

Ulrike Fischer’s answer is the only one so far that’s correct, but there are several good places to put the file:

  • Add a second root to MikTeX, such as C:\texmflocal\. Put it in an appropriate subdirectory, such as C:\texmflocal\tex\latex\.
  • Create a local texmf root in your user directory and select it with the TEXINPUTS environment variable. This lets you have one that isn’t turned on for everyone all the time.
  • Put the file in your project folder. Then, you can be sure it will be archived along with the source files that need it. It’s a short text file and you have terabytes of disk space.

After you put a new file in a user directory, you must update the file names database under the MikTeX Tasks menu, or run texhash.

  • I have this very problem with a package (I think I have no choice, for this one I must install the .sty separately). I use TeXLive on Linux, when I put the .sty at its place, I must run sudo mktexlsr in order to have it available for compilation. mktexlsr (without sudo) does not show error messages, but just does nothing (it tells each step is skipped do not only read the final Done. message).
    – zezollo
    Nov 6, 2022 at 19:45
  • @zezollo With TeX Live on Linux, you can install to your TEXMFLOCAL directory. Type kpsewhich --var-value=TEXMGLOCAL to find it. You can similarly find TEXMFHOME and install it there only for yourself. Re-run texhash when you’re done.
    – Davislor
    Nov 6, 2022 at 21:59

For Mac OS system:

  1. Open your terminal.

  2. Find an .sty file that you know is present and works, for example bm.sty.

  3. In your terminal put: kpsewhich bm.sty.

    It will show the path, for example: /users/yourname/Library/TinyTex/texmf-dist/tex/latex/tools/bm.sty.

  4. Go to that folder (Command + Shift + G) on your desk. Put the path without tools/bm.sty.

  5. Search and download the package that you don't have, then put it in that folder. Or you have own .sty file, just put it in that folder.

  6. Go to terminal, put: sudo teshash.

  7. The package will work.

  • 1
    Welcome! This is not good advice, I'm afraid. Local and custom files shouldn't be in texmf-dist. You should use, say, TEXMFHOME. On a Mac, this is usually in /Users/<username>/Library/texmf.
    – cfr
    Oct 31, 2019 at 5:02

You can use the vector to add all the packages that you may need and then use the for loop to install all of them from the R terminal.

packs <- c("setspace.sty'", "float.sty'", "amssymb.sty'", "utf8.sty'", "fancyhdr.sty'", "tabularx.sty'", "hyperref.sty'", "etoolbox.sty'", "`lmodern.sty")

for (i in 1:length(packs)) {
tinytex::parse_install(text = paste('! LaTeX Error: File', packs[i],'not found.')) }


I doubt this is what happened to OP, but it happened to me: a missing comma in my usepackage statement meant that instead of searching for both relsize.sty and setspace.sty, LaTeX tried searching for relsizesetspace.sty.

You must log in to answer this question.