5

I want to write something like

In order to avoid a RuntimeException

where RuntimeException appears with a code font.

I've tried something like

\begin{lstlisting} In order to avoid a RuntimeException \end{lstlisting}

but it was of no avail. Any suggestions? If it isn't possible, could anyone point out what's the font being used by default by listings?

Thorsten
  • 12,872
user12079
  • 263

1 Answers1

11

Use \lstinline for inline listings:

enter image description here

The \begin{lstlisting}...\end{lstlisting} is for displayed listings.

References:

Code:

\documentclass{article}
\usepackage{listings}
\lstset{basicstyle=\ttfamily\small}
\begin{document}
    To avoid a  \lstinline´RuntimeException´ you need to...
\end{document}
Peter Grill
  • 223,288