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:
- ModernTex: when a build fails, the Build button shows the error count and the last good PDF stays on screen. The Build Results panel lists each error, warning and note in plain language, Compile › Next Issue steps through them, and Raw Log shows the full LaTeX log. When the document needs a package your distribution does not have, the error carries an Install button with the package name under Install fix. ModernTex installs the package and builds again. See ModernTex.
- Overleaf: the logs panel, opened with the button next to Recompile, lists each error and warning with its file and line, and the editor marks the line in the gutter. The unprocessed log is at the bottom of that panel.
- TeXShop: the console window shows the log as it is written and stops at the error. Goto Error moves the source window to the line. TeXShop's default pdfLaTeX command includes
--file-line-error, but this message keeps its!form, and the file and line appear on the stop that follows:./main.tex:3: Emergency stop.
Related errors
- Undefined control sequence: what you get after removing a
\usepackageline whose commands are still in use. - LaTeX Error: Environment x undefined: when the package loads but the environment name is wrong.
- Missing \begin{document}: when a downloaded
.styfile turns out to be a web page.