6

A solution that keeps the style of the boxed title after a break in a tcolorbox can be found at Tcolorbox: same boxed title style after break? The solution works well for frames made of a continuous line. Is there a way to make it work for dashed frames ?

\documentclass{article}
\usepackage{lipsum}%
\usepackage[all]{tcolorbox}%

\begin{document}

% Example taken from Thomas F. Sturm Manual for version 3.93 p. 346
% Problem: After a break, The style of the boxed title is lost

\begin{tcolorbox}[enhanced,breakable,colframe=green!50!white,
colbacktitle=green!15!white,
coltitle=green!50!black,
borderline={0.5mm}{0mm}{green!15!white},
borderline={0.5mm}{0mm}{green!50!white,dashed},
attach boxed title to top center={yshift=-2mm},
boxed title style={boxrule=0.4pt},
title=Boxed title]
A dashed frame: example taken from Thomas F. Sturm Manual for version 3.93 p. 346
\end{tcolorbox}

% 
% Christian Hupfer found a solution that keeps the style of the boxed title after a break in a tcolorbox.
% https://tex.stackexchange.com/questions/315091/tcolorbox-same-boxed-title-style-after-break
% The solution works well for frames made of a continuous line.
% Is there a way to make it work for dashed frames ?

\tcbset{boxtitlestuff/.style={boxrule=0.4pt,colback=black!2!white,coltitle=black,fonttitle={\bfseries},size=normal
%borderline={0.5mm}{0mm}{green!15!white},
%borderline={0.5mm}{0mm}{green!50!white,dashed}
},
        brokentitle/.style={geometry nodes=true,skin=freelancemiddle,
          extras middle and last={overlay={\node[above,inner sep=-4pt] (A) at (interior.north) {\tcbox[boxtitlestuff]{continued boxed title}};}
          }
        }
      }

\begin{tcolorbox}[skin=enhanced jigsaw,brokentitle,
breakable,colframe=green!50!white,
colbacktitle=green!15!white,
coltitle=green!50!black,
borderline={0.5mm}{0mm}{green!15!white},
borderline={0.5mm}{0mm}{green!50!white,dashed},
attach boxed title to top center={yshift=-2mm},
boxed title style={boxrule=0.4pt},title=Boxed title
]
A dashed frame with "broken" boxed title according to solution 1:
{\footnotesize https://tex.stackexchange.com/questions/315091/tcolorbox-same-boxed-title-style-after-break}\\
The top and bottom dashed lines are lost.\\
Is there a way to have boxed titles that do not loose their style after a break in a  tcolorbox with a dashed frame ?

\end{tcolorbox}



\begin{tcolorbox}[skin=enhanced jigsaw,brokentitle,
breakable,colframe=green!50!white,
colbacktitle=green!15!white,
coltitle=green!50!black,
borderline={0.5mm}{0mm}{green!15!white},
borderline={0.5mm}{0mm}{green!50!white,dashed},
attach boxed title to top center={yshift=-2mm},
boxed title style={boxrule=0.4pt},title=Boxed title
]
\tiny
\lipsum
\lipsum
\end{tcolorbox}


\end{document}

enter image description hereenter image description here

ADDENDUM

@cfr found a solution that works ...only if the tcolorbox breaks. If the tcolorbox does not break, it has neither a boxed title nor a dashed frame. Is there a way to extend the solution to unbroken tcolorboxes ?

\documentclass{article}
\usepackage{lipsum}
\usepackage[skins,breakable]{tcolorbox}
\begin{document}

\tcbset{%
  boxtitlestuff/.style={%
    frame empty,
    colback=\Color!2!white,
  },
  brokentitle/.style={%
    geometry nodes=true,
    skin=freelance,
    extras first={%
      overlay={%
        \draw [preaction={draw=\Color!15!white, line width=1pt, rounded corners}, rounded corners, \Color!50!white, line width=1pt, dashed] ([yshift=1pt, xshift=-1pt]interior.north west) rectangle ([yshift=-1pt, xshift=1pt]interior.south east);
        \node[above, rounded corners, draw, \Color!50!white, line width=1pt, fill=\Color!15!white, text=\Color!50!black, font=\bfseries\normalsize] (A) at ([yshift=-.25\baselineskip]interior.north) {#1};
      }
    },
    extras middle and last={%
      overlay={%
        \draw [preaction={draw=\Color!15!white, line width=1pt, rounded corners}, rounded corners,\Color!50!white, line width=1pt, dashed] ([yshift=1pt, xshift=-1pt]interior.north west) rectangle ([yshift=-1pt, xshift=1pt]interior.south east);
        \node[above, rounded corners, draw=\Color, line width=.8pt, fill=\Color!2!white, text=black, font=\bfseries\normalsize] (A) at ([yshift=-.25\baselineskip]interior.north) {continued #1 };
      }
    }
  }
}


\newcommand{\BreakableDashedFrameBoxedTitleTcolorbox}[2]{
\def\Color{#2}
\begin{tcolorbox}[%
  brokentitle=Boxed title #1 (dashed frame),
  breakable,
  frame empty,
  colframe=\Color,
  colback=\Color!20!white
  ]
  \tiny
  \lipsum
\end{tcolorbox}
}


\BreakableDashedFrameBoxedTitleTcolorbox{1}{green}
\BreakableDashedFrameBoxedTitleTcolorbox{2}{red}
\BreakableDashedFrameBoxedTitleTcolorbox{3}{blue}
\BreakableDashedFrameBoxedTitleTcolorbox{4}{pink}
\BreakableDashedFrameBoxedTitleTcolorbox{5}{orange}
\BreakableDashedFrameBoxedTitleTcolorbox{6}{yellow}

\end{document}

enter image description here

1 Answer 1

5

Probably there's a much more elegant tcolorbox solution, but you could always 'freelance' the frame as well:

freelance frame

\documentclass{article}
\usepackage{lipsum}
\usepackage[skins,breakable]{tcolorbox}
\begin{document}
% Example taken from Thomas F. Sturm Manual for version 3.93 p. 346
% Problem: After a break, The style of the boxed title is lost
% Christian Hupfer found a solution that keeps the style of the boxed title after a break in a tcolorbox.
% http://tex.stackexchange.com/questions/315091/tcolorbox-same-boxed-title-style-after-break
% The solution works well for frames made of a continuous line.
% Is there a way to make it work for dashed frames ?
\tcbset{%
  boxtitlestuff/.style={%
    frame empty,
    colback=black!2!white,
  },
  brokentitle/.style={%
    geometry nodes=true,
    skin=freelance,
    extras first={%
      overlay={%
        \draw [preaction={draw=green!15!white, line width=1pt, rounded corners}, rounded corners, green!50!white, line width=1pt, dashed] ([yshift=1pt, xshift=-1pt]interior.north west) rectangle ([yshift=-1pt, xshift=1pt]interior.south east);
        \node[above, rounded corners, draw, green!50!white, line width=1pt, fill=green!15!white, text=green!50!black, font=\bfseries\normalsize] (A) at ([yshift=-.25\baselineskip]interior.north) {#1};
      }
    },
    extras middle and last={%
      overlay={%
        \draw [preaction={draw=green!15!white, line width=1pt, rounded corners}, rounded corners,green!50!white, line width=1pt, dashed] ([yshift=1pt, xshift=-1pt]interior.north west) rectangle ([yshift=-1pt, xshift=1pt]interior.south east);
        \node[above, rounded corners, draw=black, line width=.8pt, fill=black!2!white, text=black, font=\bfseries\normalsize] (A) at ([yshift=-.25\baselineskip]interior.north) {continued boxed title};
      }
    }
  }
}

\begin{tcolorbox}[%
  brokentitle=Boxed title,
  breakable,
  frame empty,
  colframe=green!15!white,
  ]
  \tiny
  \lipsum
  \lipsum
\end{tcolorbox}
\end{document}
2
  • Unfortunately, your solution works only for tcolorbox that break. If a tcolorbox does not break, it has neither a title nor a frame...
    – SDrolet
    Jun 25, 2016 at 14:50
  • The "addendum" (see above) provides a MWE regarding that specific issue for unbroken tcolorboxes.
    – SDrolet
    Jun 25, 2016 at 15:38

You must log in to answer this question.

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