2

I want to make an itemized list with verbatim elements which contain underscores (actually \verb just doesn't work) . So far, nothing I have tried worked. Escaping doesn't work, and I have tried examples but that package is broken. How can I achieve what I want ?

\documentclass[aspectratio = 169]{beamer}
\setbeamertemplate{navigation symbols}{}
\usetheme{Boadilla}

\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{graphicx} \usepackage{hyperref}

\begin{document}

\section{Sorting algorithms} \begin{frame}{Sorting algorithms} Three algorithms : \begin {itemize} \item \verb"bubble_sort" \item \verb"strand_sort" \item \verb"pigeonhole_sort" \end{itemize} \end{frame}

\end{document}

ice-wind
  • 121
  • 7
    A frame containing verbatim material must be set with the fragile option (so \begin{frame}[fragile]). Preferable would be to use \item\texttt{bubble\_sort}. – Skillmon May 12 '22 at 12:47
  • @Skillmon Great ! Can you post that as an answer so I can accept it ? It would be nice if other people can find this instead of the other questions I found which give broken answers ! – ice-wind May 12 '22 at 12:50
  • 3
    (1) It is recommended to use \begin{frame}\frametitle{title}, (2) as Skillmon mentions use \begin{frame}[fragile] when using special constructions like \verb etc. Then your example compiles just fine – daleif May 12 '22 at 12:51
  • @Skillmon If not I'll do it but you deserve the reputation not me – ice-wind May 12 '22 at 12:51
  • @Crysambrosia In essence this is a duplicate (I was just too lazy to search). See e.g. here: https://tex.stackexchange.com/questions/197234 and https://tex.stackexchange.com/questions/140719 – Skillmon May 12 '22 at 12:54

0 Answers0