带有虚线框架的 Tcolorbox:中断后是否具有相同的框式标题样式?

带有虚线框架的 Tcolorbox:中断后是否具有相同的框式标题样式?

可以在以下位置找到一种解决方案,可以在 tcolorbox 中断后保持盒装标题的样式:Tcolorbox:中断后是否仍使用相同的盒装标题样式?该解决方案对于由连续线组成的框架非常有效。有没有办法让它适用于虚线框架?

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

在此处输入图片描述在此处输入图片描述

附录

@cfr 找到了一种解决方案,只有当 tcolorbox 损坏时才有效。如果 tcolorbox 没有损坏,它既没有方框标题也没有虚线框架。有没有办法将解决方案扩展到未损坏的 tcolorbox?

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

在此处输入图片描述

答案1

可能有一个更优雅的tcolorbox解决方案,但你也可以随时“自由地”使用框架:

自由职业框架

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

相关内容