[Tex/LaTex] How to add a little code block instream with text

code

I would like to add a little code block in line with paragraph text. For example:

In order to do this just run the [code block] command in your terminal.

Can anybody help?

Best Answer

The listings package provides a command for inline code snippets:

\documentclass{article}
\usepackage{listings}
\lstset{language = C++}
\begin{document}
In order to do this just run the
\lstinline!#include <iostream>! command
command in your terminal.
\end{document}

Output with Code snippet

Instead of the exclamation mark you could use any character as delimiter, as long as it does not appear in the code snippet.

Related Question