# Code Check

The Overleaf editor includes a syntax-checker known as Code Check which highlights common errors as you type.

The errors Code Check can find are:

* Mismatched `\begin` and `\end` commands
* Mismatched LaTeX group delimiters `{ }`
* Mismatched `\left` and `\right` delimiters
* Mismatched math mode delimiters `$..$` and `$$..$$`
* Math commands used outside math mode
* Text commands used inside math mode

Code Check uses heuristics and assumes that the document is typical LaTeX, using only standard commands, e.g., every `\begin{}` has a corresponding `\end{}.`

### Code Check limitations

If your project uses your own LaTeX or TeX macros, or packages which change standard LaTeX behavior, you may find that Code Check needs to be turned off—you can do this globally, for a single file, or for part of a file.

In particular, if you use macros as shortcuts for standard LaTeX environments (e.g., `\newcommand{\beq}{\begin{equation}}`), these will not be expanded and you should disable Code Check.

### Disabling Code Check globally

If you don't want to use Code Check at all you can turn it off in the left menu: Click on the Overleaf menu icon above the file list panel, and then look for **Settings** > **Code Check**.

### Disabling Code Check for a single file

To turn off Code Check for a single file, put the comment `%%novalidate` at the top of the file (N.B. to avoid conflicts we use a double comment character).

```latex
%%novalidate

% complex macro definitions or Tikz figures
% ...
```

### Disabling Code Check for part of a file

You can also turn off Code Check for part of a file.

```latex
This part of the file is checked with Code Check

%%begin novalidate
This part is not checked
%%end novalidate

This part will also be checked with Code Check
```

### Known issues

* URL, verbatim and other commands where `%` is a literal character can give false errors when there is subsequent LaTeX code on the same line as the command. A workaround is to start a new line after any `\url{}` or other commands containing literal `%` characters.
* Commands that use LaTeX3 syntax with underscores in macro names.
* Custom command definitions that separate `\begin{...}` from `\end{...}` statements.


---

# Agent Instructions: 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:

```
GET https://docs.overleaf.com/troubleshooting-and-support/code-check.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
