라텍스의 인라인 파이썬 코드

라텍스의 인라인 파이썬 코드

다음과 같은 상자에 색상이 포함된 일부 인라인 Python 코드를 보고서에 추가하려고 합니다.

여기에 이미지 설명을 입력하세요

"행렬 텍스트가 상자에 빨간색으로 포함되어 있습니다."를 볼 수 있듯이 다음 방법을 사용하여 인라인 색상 코드를 추가할 수 있습니다.

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

다음과 같은 출력이 생성됩니다. 여기에 이미지 설명을 입력하세요

코드 주변의 상자를 제외하면 거의 완벽합니다. 코드 주위에 상자를 어떻게 만들 수 있나요?

답변1

간단히 다음 안에 넣을 수 있습니다 \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}

출력, 정사각형 모서리

\ovalbox{...}또는 둥근 모서리 를 원할 경우fancybox패키지:

\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}

출력, 둥근 모서리

관련 정보