> 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/029-code-check.md).

# 程式碼檢查

Overleaf 編輯器包含一個語法檢查器（稱為「Code Check」），會在你輸入時醒目標示常見錯誤。

Code Check 可以找出的錯誤有：

* 不匹配的 `\begin` 和 `\end` 命令
* 不匹配的 LaTeX 群組分隔符號 `{ }`
* 不匹配的 `\left` 和 `\right` 分隔符號
* 不匹配的數學模式分隔符號 `$..$` 和 `$$..$$`
* 在數學模式外使用的數學命令
* 在數學模式中使用的文字命令

Code Check 使用啟發式方法，並假設文件是典型的 LaTeX，且只使用標準命令，例如每個 `\begin{}` 都有對應的 `\end{}`.

## Code Check 限制

如果你的專案使用自訂的 LaTeX 或 TeX 巨集，或是會改變標準 LaTeX 行為的套件，你可能會發現需要關閉 Code Check——你可以針對全域、單一檔案，或檔案的一部分來關閉它。

特別是，如果你使用巨集作為標準 LaTeX 環境的快捷方式（例如 `\newcommand{\beq}{\begin{equation}}`），這些內容不會被展開，你應該停用 Code Check。

## 全域停用 Code Check

如果你根本不想使用 Code Check，可以在左側選單中將其關閉：點擊檔案清單面板上方的 Overleaf 選單圖示，然後尋找「Settings - Code Check」。

## 為單一檔案停用 Code Check

要為單一檔案關閉 Code Check，請在檔案頂端加入註解 `%%novalidate` 。（注意：為避免衝突，我們使用雙重註解字元）。

```latex
%%novalidate

% 複雜的巨集定義或 Tikz 圖形
% ...
```

## 為檔案部分區段停用 Code Check

你也可以為檔案的一部分關閉 Code Check

```latex
檔案的這一部分會由 Code Check 檢查

%%begin novalidate
這一部分不會被檢查
%%end novalidate

這一部分也會由 Code Check 檢查
```

## 已知問題

* Url、verbatim 以及其他其中 `%` 是字面字元的命令，在命令所在行後面還有 LaTeX 程式碼時，可能會產生誤報。解決方法是在任何 `\url{}` 或其他包含字面 `%` 字元的命令之後另起新行。
* 使用帶有底線的巨集名稱且採用 LaTeX3 語法的命令。
* 將 `\begin{...}` 來自 `\end{...}` 語句分開的自訂命令定義


---

# 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/029-code-check.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.
