> 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/zhi-shi-ku/068-how-to-insert-figures-in-overleaf.md).

# 如何在 Overleaf 中插入圖形

Overleaf 提供 3 種建立 LaTeX 圖形的方法：

1. 使用 [**插入圖形** 按鈕](#using-insert-figure-to-add-a-figure-to-your-project) (![The Insert Figure button on the editor toolbar](/files/806f9266d789b09f529dbbb2345b82abf69a37a5)）將圖形插入到 **視覺編輯器** 或 **程式碼編輯器**.
2. [複製並貼上一個圖片](/latex/zh-tw/zhi-shi-ku/075-how-to-paste-formatted-content-into-overleaf.md#pasting-images-into-your-overleaf-project) 到 **視覺編輯器** 或 **程式碼編輯器**.
3. 使用 **程式碼編輯器** 來撰寫 LaTeX 程式碼，以 [插入圖像並將其置於 figure 環境中](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md).

選項 1 和 2 會自動產生建立圖形所需的 LaTeX 程式碼，但如果你是有信心的 LaTeX 使用者，或許會偏好選項 3，因為它提供最大的彈性。如果你是 LaTeX 新手，那麼選項 1，也就是 **插入圖形** 按鈕（本頁的重點），是很好的起點。

在使用這些圖形建立方法之前，請先確認你的主要 LaTeX 檔案已載入 `graphicx` 套件，方法是在其中的 `\usepackage{graphicx}` 內寫入 [前言區](/latex/zh-tw/latex-ji-chu/01-learn-latex-in-30-minutes.md#the-preamble-of-a-document).

## 使用視覺編輯器與程式碼編輯器

在我們說明如何插入圖形之前，值得注意的是 **視覺編輯器**的圖形預覽功能。

圖形可以插入到 **視覺編輯器** 或 **程式碼編輯器**，但只有 **視覺編輯器** 會提供圖形預覽，以及一個可開啟對話視窗讓你進行修改的按鈕。以下的簡短影片片段示範了 **視覺編輯器**的圖形預覽功能。

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/4ohFnejYVn89OUj2fAbJ6F/18ad3cd10b0b3ceb7955cc651c92eedb/VisualEditorDemo.mp4>" %}

## 使用插入圖形將圖形加入你的專案

請依照以下步驟將圖形插入 Overleaf LaTeX 文件中。

1. 選擇你要使用的編輯器： **視覺編輯器** 或 **程式碼編輯器**.
2. 選取 **插入圖形** 按鈕（![The Insert Figure button on the editor toolbar](/files/806f9266d789b09f529dbbb2345b82abf69a37a5)）以顯示可用於插入圖形的選項清單：

   ![插入圖形的選項清單](/files/93c8cf182f887675b11000edc4601f3913bc6c16)
3. 請使用以下文件連結跳至你感興趣的選項：

* [從電腦上傳](#upload-from-computer)
* [從專案檔案](#from-project-files)
* [從另一個專案（影片示範）](#from-another-project)
* [從 URL（影片示範）](#from-url)

### 從電腦上傳

此選項會使用從你的裝置上傳的圖形檔案來建立圖形。

![上傳檔案時顯示的「從電腦上傳」對話視窗](/files/7a986d5db84a2041b2dca852cdfc58a5d177243d)

要使用此選項：

1. 使用以下其中一種方法上傳圖形：

* 將圖形檔案拖放到對話視窗上（在顯示的區域內）
* 將圖片貼到對話視窗中（在顯示的區域內）
* 手動選取裝置上的檔案

3. 為圖形檔案命名。
4. （選用）選擇一個專案資料夾來儲存檔案。
5. 決定是否使用圖形標題。
6. 決定是否加入標籤（用於 [參照圖形](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md#labels-and-cross-references)).
7. 設定圖片寬度（作為 `\linewidth`).
8. 選擇 **插入圖形** 以上傳圖形，並根據你的選擇自動產生一個 LaTeX `圖形` 環境。

### 從專案檔案

此選項會使用你目前專案中先前上傳的其中一個圖形檔案來建立圖形。

![用於選取專案檔案以建立圖形的「從專案檔案插入」對話視窗](/files/8cd1fd01c58267c0dd66edadbcec7c4cd2ad7507)

要使用此選項：

1. 選擇你專案中的一個圖形。
2. 決定是否使用圖形標題。
3. 決定是否加入標籤（用於 [參照圖形](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md#labels-and-cross-references)).
4. 設定圖片寬度（作為 `\linewidth`).
5. 選擇 **插入圖形** 以自動產生一個 LaTeX `圖形` 環境。

### 從另一個專案

此選項可讓你使用另一個 Overleaf 專案中的圖形檔案來建立圖形。如下面的動畫截圖所示，你先選擇一個專案，然後選取先前 *上傳到* 該專案，或由該專案 *output* （產生）的檔案——例如，由 [外部化 TikZ 圖形](https://learn.overleaf.com/learn/Questions/I_have_a_lot_of_tikz,_matlab2tikz_or_pgfplots_figures,_so_I%27m_getting_a_compilation_timeout._Can_I_externalise_my_figures%3F#How_to_externalize_TikZ_graphics)產生的 PDF 圖形。請參閱章節 [從輸出檔案選取](#select-from-output-files) 以查看如何使用由另一個專案建立的輸出檔案的影片片段。

![一段動畫 GIF，示範如何選擇由另一個專案產生的檔案](/files/b6d89b9a0514e1cc32443a21a6d6bbc54d17ff54)

要使用此選項：

1. 選擇一個包含你想在目前專案中使用之圖形檔案的專案。
2. 選取該專案的其中一個圖形：
   * 一個 **圖片檔案** *上傳到* 該專案，或
   * 一個 [**輸出檔案**](#select-from-output-files) *由* 該專案產生。
3. 為圖形檔案命名。
4. （選用）選擇一個專案資料夾來儲存檔案。
5. 決定是否使用圖形標題。
6. 決定是否加入標籤（用於 [參照圖形](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md#labels-and-cross-references)).
7. 設定圖片寬度（作為 `\linewidth`).
8. 選擇 **插入圖形** 以自動產生一個 LaTeX `圖形` 環境。

#### 從輸出檔案選取

下面的影片片段將帶你了解如何將圖形納入目前專案，利用另一個會建立 [外部化 TikZ 圖形](/latex/zh-tw/wen-yu-da/60-i-have-a-lot-of-tikz-matlab2tikz-or-pgfplots-figures-so-i-m-getting-a-compilation-timeout.-can-i.md#how-to-externalize-tikz-graphics).

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/1hcdCRW7PFioG58vexEMpf/60b86288419fea290ad4b43a633afda3/FigureFromExternalProjectFile.mp4>" %}

### 從 URL

此選項可讓你使用透過 URL 新增（下載）到專案中的圖形來建立圖形。

![一張顯示透過 URL 下載檔案之對話視窗的圖片](/files/ba10697c3a4245166f3252bb17d1bc400b3493fa)

要使用此選項：

1. 貼上一個 [直接下載連結](https://en.wikipedia.org/wiki/Direct_download_link) （URL）到 **圖片 URL** 欄位中。
2. 為圖形檔案命名。
3. （選用）選擇一個專案資料夾來儲存它。
4. 決定是否加入圖形標題。
5. 決定是否加入標籤（用於 [參照圖形](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md#labels-and-cross-references)).
6. 設定圖片寬度（作為 `\linewidth`).
7. 選擇 **插入圖形** 以自動產生一個 LaTeX `圖形` 環境。

以下影片片段示範如何使用一個 [Google Drive 下載 URL](/latex/zh-tw/zhi-shi-ku/051-how-can-i-upload-files-from-google-drive.md)。它也示範如何變更圖形大小並為其加入標題。

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/29hcjGmsEQewhuCVQaWkSr/2cef229050a36a87b86dc0aabdde2858/InsertFigureURL.mp4>" %}


---

# 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/zhi-shi-ku/068-how-to-insert-figures-in-overleaf.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.
