如何在 tcbinputlisting 环境中转移代码

如何在 tcbinputlisting 环境中转移代码

我正在尝试使用minteda 内部的代码突出显示newtcbinputlisting,效果非常好。感谢 TeXExchange 和许多以前的答案!但是,我无法在环境中移动代码tcolorbox。我太接近了!我不确定我错过了什么。

\newtcbinputlisting[use counter=filePrg, number format=\arabic]{\codeFromFile}[4]{%
    listing engine=minted,
    minted language=#1,
    listing file={#2},
    minted options={
        fontsize=\footnotesize,
        linenos,
        numbersep=1mm,
        breaklines=true,
        },% <-- put other minted options inside the brackets
    overlay={%
        \begin{tcbclipinterior}
            \fill[gray!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
        \end{tcbclipinterior}
    },
    colback=pythoncodebg, 
    colframe=black!70, 
    coltitle=White, 
    coltext=Black, 
    before skip= \UofUDoubleSpace, 
    after skip= \UofUDoubleSpace, 
    code={\singlespacing}, 
    breakable, % Allows for code to continue on multiple pages
    listing only, 
    arc=1.5mm, % Curvature of line corner
    enhanced, % jigsaw,
    boxrule=0.5mm, % Border width
    size=title,
    title=\TwoSymbolsAndText{\faCode}{%
    \textbf{File program \thetcbcounter}\ifthenelse{\equal{#3}{}}{}{\textbf{:} \textit{#3}}%
    }{\faCode},
    label=filePrg:#4
}

在此处输入图片描述

答案1

在进一步了解了这一点之后,我尝试使用,framesep但这是错误的方法。相反,我需要插入来xleftmargin指定偏移量。

\newtcbinputlisting[use counter=filePrg, number format=\arabic]{\codeFromFileFNS}[4]{%
    listing engine=minted, 
    minted language=#1, 
    listing file={#2}, 
    %left=5mm, 
    minted options={
        fontsize=\footnotesize, 
        linenos, 
        xleftmargin=3.25mm, 
        numbersep=2mm, 
        breaklines=true, 
        },% <-- put other minted options inside the brackets
    overlay={%
        \begin{tcbclipinterior}
            \fill[gray!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
        \end{tcbclipinterior}
        },
    colback=pythoncodebg, 
    colframe=black!70, 
    coltitle=White, 
    coltext=Black, 
    before skip= \UofUDoubleSpace, 
    after skip= \UofUDoubleSpace, 
    code={\singlespacing}, 
    breakable, % Allows for code to continue on multiple pages
    listing only, 
    arc=1.5mm, % Curvature of line corner
    enhanced jigsaw, % ,
    boxrule=0.5mm, % Border width
    size=title,
    title=\TwoSymbolsAndText{\faCode}{%
    \textbf{File program \thetcbcounter}\ifthenelse{\equal{#3}{}}{}{\textbf{:} \textit{#3}}%
    }{\faCode},
    label=filePrg:#4
}

很抱歉我没有,mwe因为这是一个庞大的subfiles项目。

在此处输入图片描述

相关内容