6

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?

ajames
  • 215

2 Answers2

7

The minted package offers you \mintinline; since it uses Pygments, its highlighting quality is superb:

\documentclass{article}
\usepackage{minted}

\begin{document}
You can use \mintinline{python}{def boring(args = None):} and some more text.
\end{document}

enter image description here

Adam Liter
  • 12,567
Gonzalo Medina
  • 505,128
  • Very nice +1, one off-topic nitpick for python: it would be def boring(args=None) according to PEP8. – magu_ Aug 10 '15 at 21:26
6

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.

Stefan Kottwitz
  • 231,401