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.
<to be read again>
\kern
l.3 This
is a long line. This is a long line. This is a long line. This is a...
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
Any ideas on why does the textcolor
makes things crash ?
%