TransWikia.com

How can I shift the code inside a tcbinputlisting environment

TeX - LaTeX Asked on May 25, 2021

I am trying to highlight code using minted inside of a newtcbinputlisting and it is working beautifully. Thanks to TeXExchange and many previous answers! However, I am unable to shift the code inside the tcolorbox environment. I’m so close! I’m not sure what I am missing.

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
}

enter image description here

One Answer

After reading more into this, I was trying to use framesep and that was the incorrect approach. Instead, I needed to insert the xleftmargin to specify the offset.

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
}

I apologize I don't have a mwe as this is a massive subfiles project.

enter image description here

Answered by Christopher Creveling on May 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP