페이지 나누기 시 tcblisting 문제

페이지 나누기 시 tcblisting 문제

나는 내 목록을 표시하기 위해 tcolorbox를 사용하는데 실제로는 꽤 잘 작동합니다. 그러나 내 목록에서 페이지 나누기가 발생하면 미리 정의된 "기본 스타일" 속성이 제거됩니다. 그리고 나는 왜 그런지 전혀 모릅니다. 누군가 아이디어가 있을까요?

이것은 내 코드입니다.

\begin{tcblisting}{
skin=enhanced,
colback=CSbackground,
boxrule=0pt,
arc=0pt,
outer arc=0pt,
top=-14.8pt,
bottom=-14.8pt,
colframe=red,
listing only,
left=-2.5pt,
right=-8pt,
overlay={\fill[CSnumberbg] ([xshift=-10pt]frame.south west) rectangle ([xshift=0pt]frame.north west);
                \fill[CSnumberline] ([xshift=-10pt]frame.south west) rectangle ([xshift=-9pt]frame.north west);},
listing style=CSharp,
breakable,
bottomsep at break=14.8pt,
topsep at break=14.8pt
}
string s = "this is a string"
%many repetitions
string s = "this is a string"
\end{tcblisting}

결과는 여기에 이미지 설명을 입력하세요 다음과 같습니다. Pagebreak가 발생했습니다. 여기에 이미지 설명을 입력하세요

업데이트:

토마스의 대답이 해결책이었습니다. 감사합니다. 그럼에도 불구하고 Thomas가 수정한 더 완전한 예가 있습니다. 누군가 관심이 있다면.

\usepackage{listings}
\usepackage[most]{tcolorbox}

\definecolor{CSbackground}{RGB}{30, 30, 30}
\definecolor{CSkeywords}{RGB}{86, 156, 214}
\definecolor{CSstrings}{RGB}{214, 157, 133}
\definecolor{CScomments}{RGB}{96, 139, 78}
\definecolor{CSemph}{RGB}{78, 201, 176}
\definecolor{CSnumberbg}{RGB}{241, 241, 241}
\definecolor{CSnumberline}{RGB}{38, 169, 202}

\lstdefinestyle{CSharp}{
    backgroundcolor=\color{CSbackground},
    language=[Sharp]C,
    frame=l,
    framesep=5pt,
    basicstyle=\footnotesize\ttfamily\color{White},
    showstringspaces=false,
    keywordstyle=\color{CSkeywords}\bfseries,
    identifierstyle=\ttfamily,
    stringstyle=\color{CSstrings},
    commentstyle=\color{CScomments},
    rulecolor=\color{CSbackground},
    emph={GZipStream,StreamWriter,WebClient,additionalClasses},
    emphstyle=\ttfamily\color{CSemph},
    xleftmargin=5pt,
    xrightmargin=5pt,
    aboveskip=\bigskipamount,
    belowskip=\bigskipamount,
    showspaces=false,
    showtabs=false,
    breaklines=true,
    breakatwhitespace=false,
    escapeinside={(*@}{@*)},
    numbers=left,
    numbersep=1.1em,
    stepnumber=1,
    numberstyle=\tiny\color{Gray}
}


\begin{tcblisting}{
    skin=enhanced,
    colback=CSbackground,
    boxrule=0pt,
    arc=0pt,
    outer arc=0pt,
    top=-14.8pt,
    bottom=-14.8pt,
    colframe=red,
    listing only,
    left=-2.5pt,
    right=-8pt,
    overlay={\fill[CSnumberbg] ([xshift=-10pt]frame.south west) rectangle ([xshift=0pt]frame.north west);
                    \fill[CSnumberline] ([xshift=-10pt]frame.south west) rectangle ([xshift=-9pt]frame.north west);},
    listing style=CSharp,
    breakable,
    bottomsep at break=14.8pt,
    topsep at break=14.8pt,
    colupper=white
    }
    string s = "this is a string"
    %many repetitions
    string s = "this is a string"
\end{tcblisting}

답변1

주어진 코드는 컴파일이 불가능하고 특히 사용된 스타일에 대한 정보가 CSharp누락되어 문제를 테스트할 수 없습니다. 하지만 문제의 원인을 추측하고 있으므로 이에 대한 답변을 제공하려고 합니다.최선의 추측답변.

페이지 나누기가 발생 하면 tcolorbox다음 상자 부분의 색상이 설정 값으로 복원됩니다. 이 동작의 이유는 (La)TeX가 \vsplit내부적으로 작동하는 동안 색상 정보를 추적할 수 없기 때문입니다 .

기본 텍스트 색상은 검은색입니다. 귀하의 CSharp스타일은 현재 텍스트 색상을 흰색으로 설정하고 중단 후 기본 검정색으로 대체되는 것 같습니다 . 이에 대한 해결책은 tcolorbox. 옵션 목록에 다음을 추가해 보세요.

%...
colupper=white,
%...

나의추측하다이것이 트릭을 수행한다는 것입니다.

관련 정보