FormaTeX
FatalCommands & Packages

\verb or \verbatim Inside Command Argument

! Argument of \XXX has an extra }.

What this error means

\verb and verbatim environments are 'fragile' — they cannot be used inside arguments to other commands. Using \verb inside \section{}, \caption{}, footnotes, or similar commands causes a cryptic brace mismatch error.

Common causes

  • \verb|...| used inside \section{} or \caption{}
  • \verb used inside \footnote{} or \marginpar{}
  • Verbatim environment used inside a box or table cell

How to fix it

Replace \verb with \texttt{} for monospace text inside command arguments. If you need true verbatim in a caption, use the caption package with the \protect\verb workaround, or use \lstinline from the listings package.

Code examples

Causes the error
\documentclass{article}
\begin{document}

\section{Using \verb|\textbf{}| in LaTeX}  % Error!

\end{document}
Fixed
\documentclass{article}
\begin{document}

\section{Using \texttt{\textbackslash textbf\{\}} in LaTeX}

\end{document}

Related errors

Test the fix live

Paste your LaTeX into the playground and compile instantly.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy