> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-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 才能找到它。通过点击如下所示的“upload”按钮即可完成此操作

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

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

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

在包含文件时，你必须始终写出文件路径 *从根目录开始*。即使你要编译的主文档存放在根目录中的某个文件夹里，而不是根目录本身，也仍然如此。下面示出了一个示例

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

这里，你想使用的图片， **`image.PNG`** 存放在 **`folder2`**，它本身存放在 **`文件夹`**。因此，要告诉 LaTeX 在哪里找到这张图片，你应该将路径写为 **`folder/folder2/image`**。这在下面显示

```latex
\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}
```

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

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

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

```latex
\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}
```

![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://ayakaleaf-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.
