![如何在 tcbinputlisting 环境中转移代码](https://linux22.com/image/432969/%E5%A6%82%E4%BD%95%E5%9C%A8%20tcbinputlisting%20%E7%8E%AF%E5%A2%83%E4%B8%AD%E8%BD%AC%E7%A7%BB%E4%BB%A3%E7%A0%81.png)
我正在尝试使用minted
a 内部的代码突出显示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
项目。