Purplelink
← All LaTeX errors

File `x.sty' not found

LaTeX asked for a package, class or input file and could not find it in the project folder or in the TeX distribution.

What it means

LaTeX looked for a file named in \usepackage, \documentclass, \input or \include and did not find it, either next to your document or in the TeX distribution. For a .sty file this means the package is not installed, its name is misspelled, or it is a file that should sit beside your .tex file and does not. The build stops here, because nothing after that line can work without the file.

The log line

This small file triggers the error:

\documentclass{article}
\usepackage{graphicsx}
\begin{document}
A figure goes here.
\end{document}

Compiled with pdfLaTeX (TeX Live 2026), it writes this to the .log file:

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

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.3 \begin
          {document}^^M
*** (cannot \read from terminal in nonstop modes)

The first line names the file LaTeX wanted: graphicsx.sty, a typo for graphicx.sty. In an interactive run LaTeX would now wait for you to type another file name. In non-stop mode it cannot ask, so the next thing in the log is ! Emergency stop. and the build ends. The l.3 line shows how far TeX had read, which is one line past the \usepackage on line 2, because LaTeX reads ahead before it loads a package.

To try a fix without touching your project, save the example as a .tex file and compile it online with the LaTeX to PDF tool.

Why it happens

The causes below are in order of likelihood. Each has a before and an after you can compare with your own source.

1. The package is not installed

Small distributions such as TinyTeX and BasicTeX ship a subset of packages. Install the missing one with tlmgr. If the package name differs from the file name, tlmgr search --global --file cleveref.sty tells you which package contains the file. MiKTeX offers to install a missing package the first time a document asks for it.

Before

\usepackage{cleveref}
% ! LaTeX Error: File `cleveref.sty' not found.

After (in a terminal)

tlmgr install cleveref
pdflatex main.tex

2. The package name is misspelled

The name in \usepackage must match the file name exactly, without the .sty extension.

Before

\usepackage{graphicsx}

After

\usepackage{graphicx}

3. A style file from a template is not in the project folder

Conference and journal style files are not part of any TeX distribution. They have to sit in the same folder as the main .tex file. If you copied only the .tex file out of a template, copy the .sty, .cls and .bst files as well.

Before

% neurips_2026.sty is not in the folder
\usepackage{neurips_2026}

After

% neurips_2026.sty copied next to main.tex
\usepackage{neurips_2026}

4. The class name is wrong

The same message with a .cls extension means the name in \documentclass is misspelled or the class is not installed.

Before

\documentclass{artcle}
% ! LaTeX Error: File `artcle.cls' not found.

After

\documentclass{article}

5. An \input path does not match the file on disk

With a .tex extension in the message, the path in \input or \include is wrong. Paths are relative to the main file, not to the file that contains the \input.

Before

\input{sections/introduction}
% the file on disk is sections/intro.tex

After

\input{sections/intro}

How to find the line

For this error the file name in the message matters more than the line number. The l. line is usually one line past the \usepackage or \documentclass that asked for the file. Search your preamble for the file name without its extension.

When you run pdflatex in a terminal without -interaction=nonstopmode, TeX stops at the error and prints a ? prompt. Press Return to carry on past the error, type x to quit, or type h for TeX's own help text, which is the paragraph you see after the l. line in the log. Editors run TeX in non-stop mode, so you get the log and never see the prompt.

What each editor shows:

Related errors

Frequently asked questions

How do I install a missing LaTeX package?
With TeX Live, TinyTeX or BasicTeX, run tlmgr install followed by the package name. MiKTeX offers to install a missing package the first time a document asks for it. A full MacTeX or TeX Live installation already includes nearly every package on CTAN.
The package is installed. Why is the .sty file still not found?
Check the spelling and capitalization in \usepackage, since file names are case-sensitive on Linux. If you copied the file into the distribution's local texmf tree by hand, run mktexlsr so that TeX's file database includes it. If your editor uses a different TeX distribution from your terminal, the package may be installed in the other one.
Where do I put a .sty or .cls file from a journal template?
In the same folder as the main .tex file. LaTeX looks in the folder of the document before it searches the distribution. Keeping the file in the project also means co-authors and the journal build with the same version.