如何将 tikzpicture 添加到 tcblisting 标题?

如何将 tikzpicture 添加到 tcblisting 标题?

我想添加这个带有三个彩色圆圈的 tikzture

\definecolor{Button1}{RGB}{254,94,86}
\definecolor{Button2}{RGB}{254,188,45}
\definecolor{Button3}{RGB}{38,202,59}

\begin{tikzpicture}
    \node[circle,fill=Button1] (c) at (0,0){};
    \node[circle,fill=Button2] (c) at (0.5,0){};
    \node[circle,fill=Button3] (c) at (1,0){};
\end{tikzpicture}

至 的标题tcblisting来自tcolorbox

\begin{tcblisting}{listing engine=minted,minted style=native,
    minted language=python,
    colback=terminalColor,colframe=terminalColor,listing only, title=Terminal}
    >>> a = [1, 2, 3]
    >>> b = a
    >>> b.append(4)
    >>> b
        [1, 2, 3, 4]
\end{tcblisting}

它应该像“OOO终端”。

答案1

\documentclass{article}
\usepackage[most, minted]{tcolorbox}

\definecolor{Button1}{RGB}{254,94,86}
\definecolor{Button2}{RGB}{254,188,45}
\definecolor{Button3}{RGB}{38,202,59}


\begin{document}
\begin{tcblisting}{listing engine=minted,minted style=native,
    minted language=python,
    colback=white,colframe=black,listing only, title= 
\tikz {
    \node[circle,fill=Button1] (c) at (0,0){};
    \node[circle,fill=Button2] (c) at (0.5,0){};
    \node[circle,fill=Button3] (c) at (1,0){};
} Terminal}
    >>> a = [1, 2, 3]
    >>> b = a
    >>> b.append(4)
    >>> b
        [1, 2, 3, 4]
\end{tcblisting}

\end{document}

在此处输入图片描述

相关内容