File XXX not found on input line XXX
This error is related to a file which cannot be found by LaTeX. This error usually appears when either
- The file path contains forbidden characters
- You have forgotten to upload the file
- The file path is spelled incorrectly.
For all information on how to correctly include images in your project, see our tutorial. Also note that whenever you are including images, you must include the graphicx
package in your preamble by writing \usepackage{graphicx}
. If you make any of the mistakes outlined above, you will get an error which looks like
main.tex, line 5
See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.8 \includegraphics{image3} I could not locate the file with any of these extensions: .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2,.eps Try typing <return> to proceed. If that doesn't work, type X <return> to quit.
Common Causes of Error
Forbidden characters in the file path
LaTeX has issues with certain characters in file paths, which you should avoid. In some cases the usage of such characters results in a file not found error. Characters you should avoid include:
- space (
- percent symbol (
%
) - backslash (
\
) - characters which are made active, by default this is only the tilde, which expands to an unbreakable space (
~
)
Forgetting to upload file:
When you want to include a file in your project, you must upload it to the project so that LaTeX is able to find it. This is done by clicking the 'upload' button as shown below
After this, the file should appear in the left hand menu.
File path incorrect:
When including a file, you must always write the file path from the root directory. This is true even if the main document which you are compiling is stored in a folder in the root directory instead of the root directory itself. An example of this is shown below
Here, the image you want to use, image.PNG
is stored inside folder2
, which itself is stored inside folder
. Therefore, to tell LaTeX where to find the image, you should write the path as folder/folder2/image
. This is shown below
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics{ {folder/folder2/image} }
\caption{This is your image}
\label{fig:my_label}
\end{figure}
\end{document}
Using \graphicspath{...}
incorrectly:
If you decide to tell LaTeX where your images are stored in the preamble so that you don't have to keep writing out the file path, then you must remember to include a forward slash at the end of the file path, and to write the entire file path inside a set of braces, as shown below
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {folder/folder2/} } %This is where you have saved the images
\begin{document}
\begin{figure}
\centering
\includegraphics{image}
\caption{This is your image}
\label{fig:my_label}
\end{figure}
\end{document}
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class