
Ich versuche, meinem Bericht Inline-Python-Code mit Farbe in einem Feld wie dem folgenden hinzuzufügen:
Wie Sie sehen, ist der Matrixtext rot gefärbt und in ein Kästchen eingebettet. Ich kann mit der folgenden Methode einen Inline-Farbcode hinzufügen:
CVXOPT extends the built-in Python objects with two matrix objects: a {\color{red}\texttt{matrix}} object for dense
Es ist fast perfekt, abgesehen von einem Kästchen um den Code. Wie kann ich ein Kästchen um den Code haben?
Antwort1
Sie können es einfach in ein : einfügen \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}
Oder, wenn Sie abgerundete Ecken wünschen, verwenden Sie \ovalbox{...}
aus demfancybox
Paket:
\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}