我正在尝试使用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
项目。