tcolorbox,不显示列表中的符号(使用 minted)

tcolorbox,不显示列表中的符号(使用 minted)

我有以下乳胶代码

\begin{ipythonnb}
\begin{ipyin}
A = np.array([[3, 2, -1], [2, -2, 4], [-1, 0.5, -1]])
b = np.array([1, -2, 0])
np.linalg.solve(A,b)
\end{ipyin}
\begin{ipyout}
array([ 1., -2., -2.])
\end{ipyout}
\begin{ipyin}
Ai = np.linalg.inv(A)
np.dot(Ai, b)
\end{ipyin}
\begin{ipyout}
array([ 1., -2., -2.])
\end{ipyout}
\begin{ipyin}
Ai
\end{ipyin}
\begin{ipyout}

\end{ipyout}
\begin{ipyout2}
array([[  2.22044605e-16,  -5.00000000e-01,  -2.00000000e+00],
       [  6.66666667e-01,   1.33333333e+00,   4.66666667e+00],
       [  3.33333333e-01,   1.16666667e+00,   3.33333333e+00]])
\end{ipyout2}
\end{ipythonnb}

分别声明如下

\newlength{\inwd}
\setlength{\inwd}{1.8cm}

\newcounter{ipythcntr}
\setcounter{ipythcntr}{0}

\DeclareTColorBox{ipythonnb}{}{colback=blue!5!white,colframe=blue!75!black,
breakable,
title=\setcounter{ipythcntr}{0}IPython Session,
title after break=IPython Session (cont.), fonttitle=\bfseries}

\DeclareTCBListing{ipyin}{ o }{
    enlarge left by=\inwd,
    width=\linewidth-\inwd,
    boxrule=0.4pt,
    enhanced,
    listing only,
    top=0pt,
    bottom=0pt,
    left=0pt,
    opacityframe=0,
    opacityback=0,
    overlay={
        \node[
            anchor=north east,
            text width=\inwd,
            font=\ttfamily\color{blue!50!black},
            inner ysep=6pt,
            inner xsep=0pt,
            outer sep=0pt
        ]
        at (frame.north west)
        {\IfValueTF{#1}{\setcounter{ipythcntr}{#1}}{\stepcounter{ipythcntr}}In [\theipythcntr]:};
    }
    listing engine=minted,minted language=python,
    minted options={breaklines}
    }

\DeclareTCBListing{ipyout}{ }{
    enlarge left by=\inwd,
    width=\linewidth-\inwd,
    boxrule=0.4pt,
    enhanced,
    listing only,
    top=0pt,
    bottom=0pt,
    left=0pt,
    opacityframe=0,
    opacityback=0,
    overlay={
        \node[
            anchor=north east,
            text width=\inwd,
            font=\ttfamily\color{red!75!black},
            inner ysep=1pt,
            inner xsep=0pt,
            outer sep=0pt
        ]
        at (frame.north west)
        {Out [\theipythcntr]:};
    }
    }

\DeclareTCBListing{ipyout2}{ }{
    boxrule=0.4pt,
    enhanced,
    listing only,
    top=0pt,
    bottom=0pt,
    left=0pt,
    opacityframe=0,
    opacityback=0,
    }
    }

它生成以下输出: 生成的输出

我不知道减号出了什么问题,我发现了其他一些帖子,一个影响列表,另一个包混淆了符号,另一个帖子中减号是unicode符号,我已使用键盘手动替换所有减号,因此这应该不是问题,而且我没有使用列表包,而是使用minted,因此该解决方案在这里没有用。

我还遇到过其他符号消失的情况,例如尖括号和花括号。

相关内容