tcblisting box w/ minted 显示不正确的列表

tcblisting box w/ minted 显示不正确的列表

当使用 minted 的其中一个 tcblisting 框来显示代码和注释时,我经常无法显示代码片段。以前,我使用 listings 并且没有遇到任何问题,但是当我为了获得更好的功能而转到 minted 时,这个错误开始出现 - listing 代码框会显示最后一个 minted 框,而不是正确的代码片段。

在此处输入图片描述

代码:

\begin{minted}{python}
def function(n):
    print(n)
\end{minted}

\begin{tcbdefinition}[name = Test, minted language = python]{
This is a function that takes in argument \mintinline{text}{n}, prints it, and returns it. \mintinline{text}{test}
}
def function(n):
    print(n)
    return n
\end{tcbdefinition}

供参考的tcblisting框代码:

    % code def
    \newtcblisting[auto counter, number within=section, list inside=definitionlist]{tcbdefinition}[2][]{%
        colback=red!5, colbacktitle=red!20, coltitle=black,
        frame hidden, arc=2pt, titlerule=0pt, toptitle=2pt, bottomtitle=2pt,
        fonttitle=\bfseries, breakable, enhanced, parbox=false,
        segmentation style={solid, draw=red!20, line width=1pt},
        comment and listing,
        title=Definition~\thetcbcounter,
        comment={#2},#1
    }
    % code example
    \newtcblisting[auto counter, number within=section, list inside=examplelist]{tcbexample}[2][]{%
    colback=gray!5, colbacktitle=gray!40, coltitle=black,
    frame hidden, arc=2pt, titlerule=0pt, toptitle=2pt, bottomtitle=2pt,
    fonttitle=\bfseries, breakable, enhanced, parbox=false,
    segmentation style={solid, draw=gray!20, line width=1pt},
    comment and listing,
    title=Example~\thetcbcounter,
    comment={#2},#1
    }

% generate Name
    \pgfkeysifdefined{/tcb/name}{\fail}{
    \tcbset{
    name/.style={after title={: #1}}}
    }

如果有人也见过类似的错误,或者知道该如何修复/报告此问题以便修复,那就太好了。谢谢!

相关内容