2

I would like to use an overlay but only at the start of a tcolorbox when there is a break. This does not work as it is shown in the picture. Is there a way to fix that ?

Note: the use of overlay first doesn't solve the problem because the logo is only printed once for the very first tcolorbox broken.

enter image description here

\documentclass[12pt]{article}

\usepackage[skins,many,minted,breakable]{tcolorbox}
\usepackage{fontawesome5}
\usemintedstyle{bw}
\renewcommand{\ttdefault}{pcr}

% Source: https://tex.stackexchange.com/a/124688/6880
\newcommand{\mynewminted}[3]{%
  \newminted[#1]{#2}{#3}%
  \tcbset{myminted/#1/.style={minted language=#2,minted options={#3}}}}

\mynewminted{for-coding-python}{python}{tabsize=4,fontsize=\footnotesize}

\newtcblisting[
    auto counter,
    number within=section,
    list inside=mypyg
]{coding-python}[1]{%
    listing only,
    title= #1,
    list entry={\protect\numberline{\thetcbcounter}#1},
    enhanced,
    coltitle     = black,
    colbacktitle = black!10!white,
    colback      = white,
    toptitle     = 1.5mm,
    bottomtitle  = 1.5mm,
    center title,
    breakable,
%   drop fuzzy shadow,
    myminted/for-coding-python,
    overlay first= {%
        \begin{tcbcliptitle}
            \node[
                anchor     = north west,
                inner ysep = 1.75mm,
                inner xsep = 2mm
            ] at (frame.north west){\Large\faPython};
        \end{tcbcliptitle}
    }
}

\begin{document}

\begin{coding-python}{TTT}
if i == 0:
    print("OK")

elif:
    print("KO")
\end{coding-python}

\null\vspace{12.5cm}

\begin{coding-python}{TTT}
if i == 0:
    print("OK")

elif:
    print("KO")
\end{coding-python}

\end{document}
3
  • Does using tcbcliptitle instead of tcbclipframe solve the issue?
    – user194703
    Commented Oct 4, 2019 at 19:19
  • Unfortunately this does not solve the problem.
    – projetmbc
    Commented Oct 4, 2019 at 19:21
  • 1
    @Schrödinger'scat I have added a complete functional solution.
    – projetmbc
    Commented Oct 4, 2019 at 21:27

1 Answer 1

3

Here is a way to solve the problem. This needs to use overlay unbroken app and overlay first app of the hooks machinery.

\documentclass[12pt]{article}

\usepackage[skins,many,minted,breakable,hooks]{tcolorbox}
\usepackage{fontawesome5}
\usemintedstyle{bw}
\renewcommand{\ttdefault}{pcr}

% Source: https://tex.stackexchange.com/a/124688/6880
\newcommand{\mynewminted}[3]{%
  \newminted[#1]{#2}{#3}%
  \tcbset{myminted/#1/.style={minted language=#2,minted options={#3}}}}

\mynewminted{for-coding-python}{python}{tabsize=4,fontsize=\footnotesize}

\newtcblisting[
    auto counter,
    number within=section,
    list inside=mypyg
]{coding-python}[1]{%
    listing only,
    title        = #1,
    list entry   ={\protect\numberline{\thetcbcounter}#1},
    enhanced,
    coltitle     = black,
    colbacktitle = black!10!white,
    colback      = white,
    toptitle     = 1.5mm,
    bottomtitle  = 1.5mm,
    center title,
    breakable,
%   drop fuzzy shadow,
    myminted/for-coding-python,
    overlay unbroken app = {%
        \begin{tcbcliptitle}
            \node[
                anchor     = north west,
                inner ysep = 1.75mm,
                inner xsep = 2mm
            ] at (frame.north west){\Large\faPython};
        \end{tcbcliptitle}
    },
    overlay first app = {%
        \begin{tcbcliptitle}
            \node[
                anchor     = north west,
                inner ysep = 1.75mm,
                inner xsep = 2mm
            ] at (frame.north west){\Large\faPython};
        \end{tcbcliptitle}
    },
}

\begin{document}

\begin{coding-python}{TTT}
if i == 0:
    print("OK")

elif:
    print("KO")
\end{coding-python}

\begin{coding-python}{TTT}
if i == 0:
    print("OK")

elif:
    print("KO")
\end{coding-python}

\null\vspace{8.5cm}

\begin{coding-python}{TTT}
if i == 0:
    print("OK")

elif:
    print("KO")
\end{coding-python}

\null\vspace{14cm}

\begin{coding-python}{TTT}
if i == 0:
    print("OK")

elif:
    print("KO")
\end{coding-python}

\end{document}

This gives the following expected output.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .