2

I am trying to add some inline python code into my report with color in an box like following:

enter image description here

As you can see "matrix text is red coloured embedded in a box" I can add inline colour code using the following method:

CVXOPT extends the built-in Python objects with two matrix objects: a {\color{red}\texttt{matrix}} object for dense

Which produces the following output: enter image description here

It is almost perfect except a box around the code. How I can have a box around the code?

1
  • Hi, ya it is close to my requirement. Thank you. Feb 7, 2016 at 17:17

1 Answer 1

3

You can simply put it inside an \fbox{...}:

\documentclass[border=5pt]{standalone}
\usepackage{xcolor}

\newcommand{\pyobject}[1]{\fbox{\color{red}{\texttt{#1}}}}

\begin{document}

CVXOPT extends the built-in Python objects with two matrix objects: a \pyobject{matrix} object for dense

\end{document}

Output, square corners

Or, if you want rounded corners, use \ovalbox{...} from the fancybox package:

\documentclass[border=5pt]{standalone}
\usepackage{xcolor,fancybox}

\newcommand{\pyobject}[1]{\ovalbox{\color{red}{\texttt{#1}}}}

\begin{document}

CVXOPT extends the built-in Python objects with two matrix objects: a \pyobject{matrix} object for dense

\end{document}

Output, rounded corners

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .