The answers of Using \lstinline inside a \item work rather nicely with the beamer class.
But, as pointed out by the following MCEs when \beamerdefaultoverlayspecification{<+->} is uncommented, they don't work if incremental overlay specifications are used: the item labels are not printed.
Is there a way to use \lstinline inside a \item in beamer class in case of incremental overlay specifications?
-
\documentclass{beamer} \usepackage{listings} \makeatletter \let\orig@item\item \def\item{% \@ifnextchar{[}% {\lstinline@item}% {\orig@item}% } \begingroup \catcode`\]=\active \gdef\lstinline@item[{% \setbox0\hbox\bgroup \catcode`\]=\active \let]\lstinline@item@end } \endgroup \def\lstinline@item@end{% \egroup \orig@item[\usebox0]% } \makeatother \begin{document} \begin{frame}[fragile] \frametitle{Foo} The arguments of the function are: % \beamerdefaultoverlayspecification{<+->} \begin{description} \item[\lstinline!foo!] Name of the file \\[1cm] % other [ ] still work as normal! something \item[\lstinline!bar!] Permissions \item[\lstinline!%^$]_!] verbatim \end{description} \end{frame} \end{document} -
\documentclass{beamer} \usepackage{listings} \newcommand*{\lstitem}[1]{ \setbox0\hbox{\lstinline{#1}} \item[\usebox0] } \begin{document} \begin{frame}[fragile] \frametitle{Foo} The arguments of the function are: % \beamerdefaultoverlayspecification{<+->} \begin{description} \lstitem{foo} Name of the file \\[1cm] % other [ ] still work as normal! something \lstitem{bar} Permissions \end{description} \end{frame} \end{document}
fragiledoes in Beamer's manual. I think that's where the impossibility of this lies. – cfr Dec 19 '17 at 00:16