> 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/latex-errors/12-latex-error-verb-ended-by-end-of-line.md).

# LaTeX Error: \verb ended by end of line

This error appears when you have used a **`verbatim`** command incorrectly. If you do this, you will generate the error below:

main.tex, line 5

LaTeX Error: \verb ended by end of line.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.7 \unbrace{\verb+\error+} Try typing to proceed. If that doesn't work, type X to quit.

To resolve this error, it is best to use the **`verbatim`** environment instead as shown below:

```latex
\begin{verbatim}
You should include your verbatim text in here.
\end{verbatim}
```

## Common Causes

**Including a line-break inside a \verb command:**

One common cause for this error to occur is if you have used a **`\verb`** command, but you have included a line-break, as shown below:

```latex
We can write different typefaces in \LaTeX as
\verb{
\textbf{Bold}
\textit{italics}
\textsf{sans serif}
}
```

This will generate an error, as line-breaks are not allowed inside the **`\verb`** command. The correct way to write this is to use the **`verbatim`** environment as shown below:

```latex
% In your preamble

\usepackage{verbatim}

% In the main body of your document

We can write different typefaces in \LaTeX as
\begin{verbatim}
\textbf{Bold}
\textit{italics}
\textsf{sans serif}
\end{verbatim}
```

![Verbatim.PNG](/files/wQyox2GUIjHquNpU4yDi)

**Omitting an end character in a \verb command:**

The verb command should be used as shown below:

```latex
\verb!\frac{1}{2}!
```

Note that delimiters here are not unique, and any character will do. The reason that we have used **`!`** as our delimiter here is that there are no **`!`** written in **`\frac{1}{2}`**. If we had chosen to write **`\verb{\frac{1}{2}}`**, we would generate the output below, which is not correct.

```latex
\verb{\frac{1}{2}}
```

![Delimiters.PNG](/files/L62UwxC0z2MVuHRuCMtJ)

This can lead to problems, as an error will be generated if the start and end of the **`\verb`** are not the same character. Because of this, all of the below commands will generate an error:

```latex
\verb \frac{1}{2}
```

```latex
{\verb \frac{1}{2}}
```

```latex
\verb!\frac{1}{2}
```

Once again, it is recommended to simply use the **`verbatim`** environment to write this as shown below

```latex
\begin{verbatim}
\frac{1}{2}
\end{verbatim}
```

**Using a \verb command inside another command:**

Another way in which this error can appear is if a **`\verb`** command is used inside another command as shown below

```latex
\section{\verb!\frac{1}{2}!}
```

This is not allowed in LaTeX, and is one of the few cases when the **`verbatim`** environment won't help. To resolve this error, you should load the **`cprotect`** package as shown below:

```latex
% In your preamble

\usepackage{cprotect}

% In the main body of your document

\cprotect\section{This is a section heading with a verbatim \verb!\frac{1}{2}!}
This is some text
```

![Cprotect.PNG](/files/QuyoXGktHOzBnRvzTLSZ)


---

# 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/latex-errors/12-latex-error-verb-ended-by-end-of-line.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.
