> 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-tw/latex-cuo-wu/09-file-xxx-not-found-on-input-line-xxx.md).

# 在輸入第 XXX 行找不到檔案 XXX

這個錯誤與 LaTeX 無法找到的檔案有關。這個錯誤通常會在以下任一情況下出現：

* 檔案路徑包含禁止使用的字元
* 你忘了上傳該檔案
* 檔案路徑拼寫錯誤。

如需了解在專案中正確插入圖片的所有資訊，請參閱我們的 [教學](/latex/zh-tw/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/d66d694b6f07711d9837a64110c24ea5e29c78bb)

接著，該檔案應該會出現在左側選單中。

**檔案路徑不正確：**

在加入檔案時，你必須一律寫出檔案路徑 *從根目錄開始*。即使你正在編譯的主文件是儲存在根目錄中的某個資料夾內，而不是根目錄本身，這一點也同樣適用。以下是範例

![Imagefolder.PNG](/files/56cca10843370dc18c6043acdeaecf1d7cd077b0)

在這裡，你要使用的圖片， **`image.PNG`** 儲存在 **`folder2`**，而它本身又儲存在 **`folder`**。因此，要告訴 LaTeX 到哪裡尋找圖片，你應將路徑寫成 **`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/dbf8ce1f065dd728db5337c12e2e5cb88cf02442)

**使用 `\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/dbf8ce1f065dd728db5337c12e2e5cb88cf02442)


---

# 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-tw/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.
