Skip to content
Get started

Fix "LaTeX Error: File not found"

This error means LaTeX could not find a file your document asks for: a package, a document class, an image or a file you \input. You will learn how to tell which kind it is and how to fix each one.

For a package or class, the full log shows:

! LaTeX Error: File `amsmaths.sty' not found.
...
./main.tex:3: Emergency stop.

For an image:

./main.tex:4: Package pdftex.def Error: File `figures/plot.png' not found: using draft setting.

The name in quotes is the file LaTeX looked for. Its extension tells you what kind of file it is.

  • .sty or .cls: the package or class name is misspelled, or it is not part of TeX Live (for example a university or journal class).
  • An image or .tex file: the file is not in the project, the folder or file name is different, or the upper and lower case does not match.
  • A file that was renamed, moved or deleted. Luzbase warns you before you do this to a file that \input or \includegraphics uses, but it does not change the references for you.
main.tex (broken)
\documentclass{article}
\usepackage{amsmaths}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=0.5\linewidth]{figures/plot.png}
\end{document}

Correct the package name, and make sure the image path matches a file in the project:

main.tex (fixed)
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
% figures/plot.png must exist in the project
\includegraphics[width=0.5\linewidth]{figures/plot.png}
\end{document}
  • Write paths from the top level of the project, where your main file normally sits. figures/plot.png means the plot.png file inside the figures folder.
  • A package or class that is not in TeX Live cannot be installed during a compile, because compiles have no internet access. Upload its .sty or .cls file to the project instead. Luzbase finds .sty, .cls, .bst and .bib files in any folder of the project, so you do not need to change a search path.
  • Images must be PNG, JPG, GIF, WebP, PDF or EPS. SVG cannot be uploaded: convert it to PDF or PNG first.

The error summary in the Output panel explains which case you hit, for example “The package “amsmaths” is not installed. Check the name in \usepackage{amsmaths}.” or ““figures/plot.png” is not in the project. Check the file name and folder; paths are relative to the main file.” The hint assumes your main file is at the top level. If it is in a folder, paths are still read from the top level of the project.

While you type, the editor autocompletes file names in \input, \include and \includegraphics, which avoids typos.

Not on Luzbase yet? It compiles LaTeX in your browser and links each error to its line, often with the fix. Start writing free.