# Square brackets in listings caption

How to add square brackets as a caption in a listing? I tried putting caption inside of "{}", but then the output is quiet weird.

\documentclass{article}

\usepackage{listings}

\begin{document}
\begin{lstlisting}[caption={Algorithm [1] - example}]
example
\end{lstlisting}
\end{document}


\begin{lstlisting}[caption={Algorithm \unexpanded{[1]} - example}]

\begin{lstlisting}[caption={Algorithm {[1]} - example}]

• Just {[1]} is enough. – Manuel May 29 '16 at 10:45
• @Ivan You might have seen, that Latex used the [1] somehow. To prevent Latex from using stuff \noexpand or \unexpanded can help. If you have no output, it is one expansion to less or at the wrong point. But this happens only in rare cases. Apparently, in this case { } is enough. – MaestroGlanz May 29 '16 at 11:24