I'm including a fair amount of inline C++ code in a beamer presentation I'm making, and I want to be able to use the short syntax for \lstinline. My code displays fine if I use, for example, the ! character as my delimiter, like
\lstMakeShortInline!
!cout << "This C++ displays fine";!
But when I try to use the @ character as my delimiter, because it will hardly ever appear in C++ code, the line is displayed unformatted, with literal @s surrounding it. As far as I know, @ is not a special character in LaTeX, so why is this happening?
Edit: I did not test the example I gave, and on further inspection, the only character that I can get to work as a delimiter is ~, as demonstrated with this example:
\documentclass{beamer}
\usepackage{listings}
\lstMakeShortInline[language=C++,basicstyle=\ttfamily]~
\begin{document}
\begin{frame}
~cout << "This C++ displays fine";~
\end{frame}
\end{document}
However, other delimiters (such as |) seem to work in the article documentclass, is this an issue with beamer?
\documentclass
to\end{document}
?@
creates a name clash with the existing internal macro\lstMakeShortInline@
and I'm not sure whether it is worth of hacking it such that it works. (defined inlistings.sty
line 1932article
. It seemsbeamer
is doing some catcode stuff. If you make@
active (\catcode`\@=\active
) before\lstMakeShortInline
and between\begin{document}
and\begin{frame}
things work as the should