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

# LaTeXエラー: \verbが行末で終了しました

このエラーは、次のものを使用したときに表示されます。 **`verbatim`** コマンドを誤って使用した場合です。これを行うと、以下のエラーが発生します。

main.tex、5行目

LaTeX エラー: \verb は行末で終了しました。

説明については LaTeX マニュアルまたは LaTeX Companion を参照してください。直ちにヘルプを表示するには H と入力してください。... l.7 \unbrace{\verb+\error+} 続行するには入力してみてください。それでも動かない場合は、終了するには X を入力してください。

このエラーを解決するには、代わりに次のものを使用するのが最善です。 **`verbatim`** 以下に示すように、代わりに環境を使用します。

```latex
\begin{verbatim}
ここにそのままのテキストを含めてください。
\end{verbatim}
```

## 一般的な原因

**\verb コマンド内に改行を含める場合:**

このエラーが発生する一般的な原因の1つは、次のものを使用したことです。 **`\verb`** コマンドですが、以下に示すように改行を含めてしまっている場合です。

```latex
LaTeX では、さまざまな書体を次のように記述できます。
\verb{
\textbf{太字}
\textit{イタリック体}
\textsf{サンセリフ}
}
```

これはエラーになります。改行は次の中では許可されていないためです。 **`\verb`** コマンド。これを正しく記述するには、次のものを使用します。 **`verbatim`** 以下に示すように環境を使います。

```latex
% プリアンブル内

\usepackage{verbatim}

% 文書の本文内

LaTeX では、さまざまな書体を次のように記述できます。
\begin{verbatim}
\textbf{太字}
\textit{イタリック体}
\textsf{サンセリフ}
\end{verbatim}
```

![Verbatim.PNG](/files/2fdd440169f9856f2973d62b769281441d9a5d5f)

**\verb コマンドで終端文字を省略する場合:**

\verb コマンドは以下に示すように使用します。

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

ここでの区切り文字は一意ではなく、どの文字でも構いません。ここで次を使用している理由は **`!`** ここでの区切り文字としてこれを使っているのは、 **`!`** と書かれているものが **`\frac{1}{2}`**&#x3068;いうわけではないからです。もし次のように書いていたら **`\verb{\frac{1}{2}}`**、以下の出力が生成されますが、これは正しくありません。

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

![Delimiters.PNG](/files/68dbda87772956b44aad7ff8fc434ecccc1fc639)

これは問題を引き起こす可能性があります。なぜなら、次のものの開始文字と終了文字が **`\verb`** 同じ文字でない場合、エラーが生成されるからです。そのため、以下のコマンドはすべてエラーになります。

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

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

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

繰り返しますが、単に次のものを使用することをお勧めします。 **`verbatim`** 以下に示すようにこれを書きます。

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

**別のコマンド内で \verb コマンドを使用する場合:**

このエラーが表示される別の原因は、次のものを **`\verb`** 別のコマンド内で使用している場合です。以下に示します。

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

これは LaTeX では許可されておらず、次のものでは対処できない数少ないケースの1つです。 **`verbatim`** 環境は役に立ちません。このエラーを解決するには、次のものを読み込む必要があります。 **`cprotect`** 以下に示すパッケージです。

```latex
% プリアンブル内

\usepackage{cprotect}

% 文書の本文内

\cprotect\section{これは、そのままの \verb!\frac{1}{2}! を含む節見出しです}
これは本文です
```

![Cprotect.PNG](/files/575b8827660dfefd8efc2ba44f974d6d7fcd335c)


---

# 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/ja/latexer/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.
