1

I'm trying to get an inline code format just like this this. This answer works but it's not near the format I'm looking for, and this answer gets a bit closer but it seems a too complex solution. A specific example of how I'm going to use it would be:

We can make this random variable $X\sim N(\mu,\sigma^{2})$ with this function my_normal_function(arg1, arg2, arg3) given that..

Any suggestions?

Chris
  • 291

1 Answers1

2

How about using tcolorbox? It provides support for \lstinline. Refer to the documentation for more details.

\documentclass{article}

\usepackage[listings]{tcolorbox}

\lstdefinestyle{inlinepy}{% language=python, basicstyle=\ttfamily, commentstyle=\color{green!60!black}, keywordstyle=\color{blue}\bfseries, stringstyle=\color{red}, keepspaces=true, }

\DeclareTotalTCBox{\inlinepy}{sv}{verbatim}{\lstinline[style=inlinepy]|#2|}

\begin{document} \begin{itemize} \item Python strings: \inlinepy{name = "First name" + "Last name"} \item Comments: \inlinepy{theta_rad = theta_deg*3.14/180 # angle conversion to radians} \item Import packages: \inlinepy{import numpy as np} \end{itemize} \end{document}

enter image description here

Zxcvasdf
  • 1,735