ページ区切りでの tcblisting の問題

ページ区切りでの tcblisting の問題

私はリストを表示するために tcolorbox を使用していますが、これは実際にはかなりうまく機能しています。しかし、リスト内でページ区切りが発生すると、定義済みの「basicstyle」プロパティが削除されます。その理由はわかりません。誰かアイデアをお持ちでしょうか?

これが私のコードです:

\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}

そして結果: ここに画像の説明を入力してください これがページ区切りです。 ここに画像の説明を入力してください

アップデート:

Thomas からの返信が解決策でした。ありがとうございます。ただし、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,
%...

私の推測これはうまくいくということです。

関連情報