> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/latex-cuo-wu/09-file-xxx-not-found-on-input-line-xxx.md).

# 在输入行 XXX 找不到文件 XXX

此错误与 LaTeX 无法找到的文件有关。此错误通常在以下情况之一时出现：

* 文件路径包含禁用字符
* 你忘记上传该文件
* 文件路径拼写错误。

有关如何在项目中正确插入图片的全部信息，请参阅我们的 [教程](/latex/zh-cn/geng-duo-zhu-ti/27-inserting-images.md)。另请注意，每当你插入图片时，都必须包含 **`graphicx`** 宏包，在导言区写入 **`\usepackage{graphicx}`**。如果你犯了上述任何一种错误，就会得到如下所示的错误：

main.tex，第 5 行

LaTeX 错误：未找到文件 \`image3'。

请参阅 LaTeX 手册或 LaTeX Companion 以获取说明。键入 H 可立即获得帮助。... l.8 \includegraphics{image3} 我无法使用以下任何扩展名找到该文件：.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2,.eps。尝试键入继续。如果那不行，键入 X 退出。

## 错误的常见原因

**文件路径中的禁用字符**

LaTeX 对文件路径中的某些字符有问题，应尽量避免。在某些情况下，使用这些字符会导致“找不到文件”的错误。应避免的字符包括：

* 空格 ( )
* 百分号 (`%`)
* 反斜杠 (`\`)
* 被设为活动的字符，默认情况下只有波浪号，它会展开为一个不可断行空格 (`~`)

**忘记上传文件：**

当你想在项目中插入一个文件时，必须先将其上传到项目中，这样 LaTeX 才能找到它。方法是点击下方所示的“上传”按钮

![Uploadimage.PNG](/files/0394ecbc74cdc0f511dd431c77f4fb810d854047)

之后，该文件应出现在左侧菜单中。

**文件路径不正确：**

插入文件时，你必须始终写出文件路径 *从根目录开始*。即使你正在编译的主文档存放在根目录下的某个文件夹中，而不是根目录本身，这一点也同样适用。下面是一个示例

![Imagefolder.PNG](/files/12739a4a10cf21e16f8b95d181cd84d4b2b72091)

这里，你想使用的图片， **`image.PNG`** 存储在 **`folder2`**，而它本身又存储在 **`文件夹`**。 **`folder/folder2/image`**。如下所示

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}

\begin{figure}
    \centering
    \includegraphics{ {folder/folder2/image} }
    \caption{这是你的图片}
    \label{fig:my_label}
\end{figure}
\end{document}
```

![Imageexample.PNG](/files/1d84373ae63ff4516cf15fe429fa22b5083dbb9a)

**使用 `\graphicspath{...}` 错误地：**

如果你决定在导言区告诉 LaTeX 图片的存放位置，这样就不必反复写出文件路径，那么务必要记得在文件路径末尾加上正斜杠，并将整个文件路径写在一对花括号中，如下所示

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\graphicspath{ {folder/folder2/} } %图片就保存在这里

\begin{document}

\begin{figure}
    \centering
    \includegraphics{image}
    \caption{这是你的图片}
    \label{fig:my_label}
\end{figure}
\end{document}
```

![Imageexample.PNG](/files/1d84373ae63ff4516cf15fe429fa22b5083dbb9a)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/latex-cuo-wu/09-file-xxx-not-found-on-input-line-xxx.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
