2

This is my MWE:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\tcbuselibrary{skins,hooks}

\newtcolorbox{mybox}[2][]{enhanced,
frame code app={\draw[yellow,line width=1cm] (frame.south west)--(frame.north east);},
interior titled code app={\draw[red,line width=1cm] (frame.north west)--(frame.south east);},
leftrule=3mm,
arc=4mm,
colframe=blue!80!red,colback=white,colbacktitle=blue!5!yellow!50!white,
fonttitle=\bfseries,coltitle=black,
attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},
boxed title style={enhanced,boxrule=.5mm,frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west)-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)-- (frame.south east) -- (frame.south west) -- cycle; },interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west) -- (interior.north west) -- (interior.north east)-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west) -- cycle;}  },
title={#2},#1}


\newtcolorbox{mybox2}[2][]{enhanced,
    frame code app={\draw[yellow,line width=1cm] (frame.south west)--(frame.north east);},
    interior titled code app={\draw[red,line width=1cm] (frame.north west)--(frame.south east);},
    leftrule=3mm,
    arc=4mm,
    colframe=blue!80!red,colback=white,colbacktitle=blue!5!yellow!50!white,
    fonttitle=\bfseries,coltitle=black,
%   attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2}, 
    boxed title style={enhanced,boxrule=.5mm,frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west)-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)-- (frame.south east) -- (frame.south west) -- cycle; },interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west) -- (interior.north west) -- (interior.north east)-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west) -- cycle;}  },
    title={#2},#1}

\begin{document}

\begin{mybox}{Studied systems}
    \lipsum[1]  
\end{mybox}

\lipsum[1]
\begin{mybox2}{Studied systems2}
    \lipsum[1]  
\end{mybox2}

\end{document}

It gives: enter image description here

I want to have red line crossing first tcolorbox as well. I found out that attach boxed title to top center code make an effect that red line disappears.

What it the solution to this problem?

2

The frame code app and interior titled code app are quite low-level options. interior titled code app adds code for drawing the interior of a box with a title. All boxed title versions detach the title from the main box and put it into an own box. This means, that the main box is to be considered as a box without title. Therefore, interior titled code app has no effect, because it is only used for the titled box (in a low-level sense).

One possible solution is to replace interior titled code app by interior code app:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\tcbuselibrary{skins,hooks}

\newtcolorbox{mybox}[2][]{enhanced,
  frame code app={\draw[yellow,line width=1cm] (frame.south west)--(frame.north east);},
  interior code app={\draw[red,line width=1cm] (frame.north west)--(frame.south east);},
  leftrule=3mm,
  arc=4mm,
  colframe=blue!80!red,colback=white,colbacktitle=blue!5!yellow!50!white,
  fonttitle=\bfseries,coltitle=black,
  attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},
  boxed title style={enhanced,boxrule=.5mm,frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west)-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)-- (frame.south east) -- (frame.south west) -- cycle; },interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west) -- (interior.north west) -- (interior.north east)-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west) -- cycle;}  },
  title={#2},#1}

\begin{document}

\begin{mybox}{Studied systems}
    \lipsum[1]
\end{mybox}

\end{document}

This gives:

enter image description here

Alternatively, since the red line crossing is on top of the box, you could use overlay or underlay options which are more high-level and work independent from title settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.