Package alltt defines an environemnt alltt that uses a list environment internally. Therefore it cannot be used the same way as \verb or \texttt.
The main point of package alltt is the unchanged use of \, { and }. The following macro \textalltt sets verbatim catcodes for its argument except for the three characters.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\makeatletter
\newcommand*{\textalltt}{}
\DeclareRobustCommand*{\textalltt}{%
\begingroup
\let\do\@makeother
\dospecials
\catcode`\\=\z@
\catcode`\{=\@ne
\catcode`\}=\tw@
\verbatim@font\@noligs
\@vobeyspaces
\frenchspacing
\@textalltt
}
\newcommand*{\@textalltt}[1]{%
#1%
\endgroup
}
\makeatother
\begin{document}
Verbatim text: \textalltt{Hello \textbf{\textsl{world}}}.
\end{document}

allttshould be used as an environment. You probably want\texttt{a}. – egreg Sep 08 '12 at 07:53\textttmakes odd things to hyphens: https://tex.stackexchange.com/q/9813/81156 – scrutari Jan 22 '20 at 14:28