# listing pre- and postbeak gives error in beamer slide

Following this answer, I've tried to embed a listing with long lines into a beamer frame.

I'd like to have a nice red arrow at the line break (as show here).

The parameters prebreak and postbreak give an error while compiling it. As a matter of fact, it's the \textcolor that gives the error.

Here is the adapted MWE :

\documentclass[xcolor={svgnames,usenames,dvipsnames,table}]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{listings}

\lstset{%
xleftmargin=3.4pt,
xrightmargin=3.4pt,
%keepspaces=true,
columns=fullflexible,   % Rasterize the columns
frame=single,
basicstyle=\ttfamily\small,
inputencoding=utf8,
extendedchars=\true,
backgroundcolor=\color{black!10},
breaklines=true,
% This works
postbreak=\mbox{$\hookrightarrow$\space},
% This does not work
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
}

\begin{document}

\begin{frame}[fragile]{Test}
\begin{lstlisting}
This is a long line. This is a long line. This is a long line. This is a long line. This is a long line.
This is another long line. This is another long line. This is another long line. This is another long line.
\end{lstlisting}
\end{frame}
\end{document}


Here is the output of the code, without the \textcolor obviously.

If I uncomment the postbreak line, I get this error :

! Missing number, treated as zero.
A number should have been here; I inserted 0'.

Any ideas on why does the textcolor makes things crash ?
• It is probably a good idea to leave that postbreak line uncommented in the MWE. Then it would fail without the user having to do anything. Here we have to read the MWE to know that it only fails if you remove a % – daleif Oct 27 at 8:39