% colorframed.sty    v1.1    2026/11/16
% Copyright (C) 2022, 2026 Jean-François Burnol
% Distributed under the terms of the LPPL 1.3c, see README.md
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{colorframed}
    [2026/11/16 v1.1 fix `framed' breakable boxes colour leaks (JFB)]
% Apart from code comments here, documentation is in colorframed-doc.pdf
\RequirePackage{framed}
\RequirePackage{color}
% The next three do something only in a document with tagging, see the end
% of this file.
\let\colorframed@artifact\@firstofone
\let\colorframed@tagtitle\@firstofone
\let\colorframed@notagpara\relax
% Default colours (repository issue #9).
% framed.sty defines none of the colours which its environments use, and a
% document not defining them got "Undefined color" errors.  Those still
% undefined at \begin{document} now get a definition.  This is delayed to
% \begin{document} because a colour defined here by the color package
% becomes unusable if the xcolor package is loaded later on.  A definition
% by the user, in the preamble (before or after loading colorframed) or in
% the document body, has precedence.
%   shadecolor     for `shaded', `shaded*', `snugshade', `snugshade*'
%   TFFrameColor   for `titled-frame': frame and background of the title
%   TFTitleColor   for `titled-frame': text of the title
% In xcolor notation the first two are lightgray!25 and teal!20.  The third
% is a dark purple; its contrast ratio with TFFrameColor is 8.16.
\AtBeginDocument{%
  \@ifundefined{\string\color@shadecolor}
    {\definecolor{shadecolor}{gray}{.9375}}{}%
  \@ifundefined{\string\color@TFFrameColor}
    {\definecolor{TFFrameColor}{rgb}{.8,.9,.9}}{}%
  \@ifundefined{\string\color@TFTitleColor}
    {\definecolor{TFTitleColor}{rgb}{.5,0,.2}}{}%
}
% Now we must make \MakeFramed/\endMakeFramed colour safe.
\expandafter\def\expandafter\MakeFramed\expandafter#\expandafter1\expandafter
  {\MakeFramed{#1}\color@begingroup}
\expandafter\def\expandafter\endMakeFramed\expandafter
  {\expandafter\color@endgroup\endMakeFramed}
%
% `framed'
\def\FrameCommand{%
    \setlength\fboxrule{\FrameRule}\setlength\fboxsep{\FrameSep}%
    \CustomFBox{}{}\fboxrule\fboxrule\fboxrule\fboxrule % replaces \fbox
}
% The frame colour can be set via modifying this macro.
\def\colorframedbordercolorcommand{\normalcolor}
%
% `shaded', `shaded*', `snugshade', `snugshade*'
% The \colorbox in \FrameCommand is replaced by \colorframedcolorbox
\renewenvironment{shaded}{%
  \def\FrameCommand{\fboxsep=\FrameSep 
                    \colorframedcolorbox{shadecolor}}%<<<< MODIFIED
  \MakeFramed {\FrameRestore}}%
 {\endMakeFramed}
\renewenvironment{shaded*}{%
  \def\FrameCommand{\fboxsep=\FrameSep
                    \colorframedcolorbox{shadecolor}}%<<<< MODIFIED
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}
\renewenvironment{snugshade}{%
  \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
  \colorframedcolorbox{shadecolor}{##1}%<<<< MODIFIED
      \hskip-\fboxsep
      % There is no \@totalrightmargin, so:
      \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
  \MakeFramed {\advance\hsize-\width 
    \@totalleftmargin\z@ \linewidth\hsize
    \@setminipage}%
 }{\par\unskip\@minipagefalse\endMakeFramed}
\renewenvironment{snugshade*}{%
  \def\FrameCommand##1{\hskip\@totalleftmargin 
  \colorframedcolorbox{shadecolor}{##1}%<<<< MODIFIED
      % There is no \@totalrightmargin, so:
      \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
  \MakeFramed {\advance\hsize-\width 
    \@totalleftmargin\z@ \linewidth\hsize
    \advance\labelsep\fboxsep
    \@setminipage}%
 }{\par\unskip\@minipagefalse\endMakeFramed}
% The \colorframedcolorbox was obtained via a process of trimming from some
% far more capable box, hence some possibly strange looking or sub-optimal
% code; but we did not want to keep extra capabilities and have to provide
% interface for that...
\def\colorframedcolorbox#1#2{%
  % #1 is in our usage always "shadecolor"
  % #2 is in our usage always a box or rule
  \leavevmode% this is not needed in our usage
  \hbox{%
    \setbox\@tempboxa\hbox{\kern\fboxsep{#2}\kern\fboxsep}%
    \ht\@tempboxa
       \dimexpr\ht\@tempboxa+\fboxsep\relax
    \dp\@tempboxa
       \dimexpr\dp\@tempboxa+\fboxsep\relax
    % BACKGROUND
    % draw background and move back to reference point
    {\color{#1}%
     \colorframed@artifact
       {\vrule\@height\ht\@tempboxa
              \@depth\dp\@tempboxa
              \@width\wd\@tempboxa}%
     \kern-\wd\@tempboxa
    }%
    % CONTENTS
    \box\@tempboxa
  }%
}
%
% `framed', `oframed' and `titled-frame'
% The \CustomFBox redefinition.
% Refer to framed.sty for significance of the parameters.
% We have not wrapped #3, #4, #5, #6 thicknesses in \dimexpr.
% Generally speaking, no attempt here to make this macro more
% versatile than is the original.
% Our version tries to let #1 and #2 have same effect as in original
% (where they are only used for titled-frame environment, and
%  it thus seems to be sort of a convention that #2 has no height.)
\long\def\CustomFBox#1#2#3#4#5#6#7{%
  \leavevmode\begingroup
  \setbox\@tempboxa\hbox{%
    \color@begingroup
      \kern\fboxsep{#7}\kern\fboxsep
    \color@endgroup}%
  \hbox{%
    \ht\@tempboxa
       \dimexpr\ht\@tempboxa+\fboxsep+#3\relax % cf "overlap" remark below
    \dp\@tempboxa
       \dimexpr\dp\@tempboxa+\fboxsep+#4\relax
        \setbox\z@\hbox
                  {\colorframed@artifact
                    {\vrule\@width#5\relax
                     \kern\wd\@tempboxa
                     \vrule\@width#6\relax}%
                  }%
            \ht\z@\ht\@tempboxa
            \dp\z@\dp\@tempboxa
    \vbox{%
        \colorframedbordercolorcommand % defaults to \normalcolor
        \colorframed@artifact{\hrule\@height#3\relax}%
        #1%
        \kern-#3\relax % see discussion of issue #2
        \copy\z@ % deliberate overlap hrules+vrules to avoid anti-aliasing artefacts
        \kern-#4\relax
        #2%
        \colorframed@artifact{\hrule\@height#4\relax}%
        \kern-\dp\@tempboxa
       }%
    \kern-\wd\z@
    \kern#5\relax
    \box\@tempboxa
    \kern#6\relax
  }%
  \endgroup
}
% \TitleBarFrame, whose original in framed.sty has various colour problems.
% It was used by `titled-frame' up to release 1.0 (see below).
% We have indicated the modifications, additionally to using
% our modified \CustomFBox.
% Original let the continuation label use same colour as frame.
% Let make this customizable.
\let\colorframedTFconlabcolorcommand\empty
\renewcommand\TitleBarFrame[3][]{\begingroup
  \ifx\delimiter#1\delimiter
    \let\TF@conlab\@empty
  \else
    \def\TF@conlab{%
     \nointerlineskip
     \hbox{%<<<< ADDED (needed due to \smash doing \leavevmode nowadays)
           \colorframedTFconlabcolorcommand%<<<< ADDED
     \smash{\rlap{\kern\wd\@tempboxa\kern\fboxrule\kern\fboxsep
                  \colorframed@artifact{#1}}}}%
          }%<<<< ADDED
  \fi
  %\let\TF@savecolor\current@color%<<<< REMOVED
  %\textcolor{TFFrameColor}{%      <<<< REMOVED
  \def\colorframedbordercolorcommand{\color{TFFrameColor}}%<<<< ADDED
  \CustomFBox
    {\TF@Title{#2}}{\TF@conlab}%
    \fboxrule\fboxrule\fboxrule\fboxrule
    {%\let\current@color\TF@savecolor\set@color%<<<< REMOVED
    #3}%
  %}%                              <<<< REMOVED
  \endgroup
}
% There are various issues with \TitleBarFrame/\TF@Title/TF@conlab
% we provide an alternative
% Since 1.1 it is the one used by `titled-frame', and its layout parameters
% are the three macros
%   \colorframedContinuationMarkSep  horizontal distance between the frame
%                                    and the continuation mark
%   \colorframedTitleBarHSep         horizontal distance between the frame
%                                    and the title, on each side
%   \colorframedTitleBarVSep         vertical space above and below the
%                                    title in its bar
% They expand to dimensions (they are not length registers).  The first
% two default to the macros which release 0.9b provided for this:
% \colorframedTFconlabsep and \colorframedTFtitlesep are kept only for
% compatibility.
\def\colorframedTFconlabsep{3pt}
\newcommand\colorframedContinuationMarkSep{\colorframedTFconlabsep}
\newcommand\colorframedTitleBarFrame[3][]{\begingroup
  \ifx\delimiter#1\delimiter
    \let\TF@conlab\@empty
  \else
    \def\TF@conlab{%
     \nointerlineskip
     \hbox{\colorframedTFconlabcolorcommand
     \smash{\rlap{\kern\wd\@tempboxa
                  % 2\fboxrule, not \fboxrule\fboxsep!
                  \kern2\fboxrule
                  \kern\dimexpr\colorframedContinuationMarkSep\relax
                  \colorframed@artifact{#1}}}}%
          }%
  \fi
  \def\colorframedbordercolorcommand{\color{TFFrameColor}}%
  \CustomFBox
    {\colorframed@TF@Title{#2}}{\TF@conlab}%
    \fboxrule\fboxrule\fboxrule\fboxrule
    {#3}%
  \endgroup
}
% The title bar for \colorframedTitleBarFrame, it will wrap its argument
% as paragraphs in case it is too long, the horizontal placement is improved
% and it will be suitably vertically centered. Nota Bene: for the title of
% a `titled-frame' to be allowed to contain \par, \colorframedTitleFormat
% (default \textbf) must be redefined to use some \bfseries.
% Macro to customize the horizontal placement. For example
% \renewcommand\colorframedTitleBarHSep{0pt}
% if \fboxrule is set by the environment to a high value.
% Don't use negative value, some parts of the title may then be hidden
% behind the left border.
\def\colorframedTFtitlesep{\fboxsep}
\newcommand\colorframedTitleBarHSep{\colorframedTFtitlesep}
\newcommand\colorframedTitleBarVSep{0.8ex}
\newcommand\colorframed@TF@Title[1]{%
  \ifx\delimiter#1\delimiter\else
  %\kern-0.04pt\relax
  \kern-.5\fboxrule
  \begingroup
  \setbox\@tempboxa\vbox{%
   \kern\dimexpr\colorframedTitleBarVSep\relax
   \hbox{\kern\fboxrule
         \kern\dimexpr\colorframedTitleBarHSep\relax
         \vbox{\hsize\dimexpr\linewidth-2\fboxrule-
                             2\dimexpr\colorframedTitleBarHSep\relax\relax
               \colorframed@notagpara
               \noindent\color{TFTitleColor}%
               \colorframed@tagtitle{#1}\par}}%
   \kern\dimexpr\colorframedTitleBarVSep\relax}%
  \colorframed@artifact{\hrule\@height\ht\@tempboxa}%
  \kern-\ht\@tempboxa
  \box\@tempboxa
  \endgroup
  %\nointerlineskip 
  %\kern-0.04pt\relax
  \colorframed@artifact{\hrule\@height.5\fboxrule}%
  \fi
}
% maybe provide a titled-frame variant using the above and acting like
% snugshade respective to being used in a list?
%
% The `titled-frame' environment itself.
% Its definition in framed.sty hard-codes the continuation mark as
% $\blacktriangleright$ (an error if no package defining it is loaded), the
% text " (cont)" appended to the title after a page break, the \textbf
% applied to the title, the thickness of the frame (2pt) and its separation
% from the contents (8pt).  These five things are now macros.  And the frame
% is now drawn by \colorframedTitleBarFrame, not by \TitleBarFrame: this
% changes the placement of the title and of the continuation mark.
%
% The mark at the bottom right of a frame continued on the next page.
\newcommand\colorframedContinuationMark{%
  \ifdefined\blacktriangleright $\blacktriangleright$\else $\triangleright$\fi}
% The title of the continuation pieces, from the title of the frame.
\newcommand\colorframedContinuedTitle[1]{#1\ (cont)}
% What is applied to the title: a command with one argument.
\newcommand\colorframedTitleFormat{\textbf}
% The thickness of the frame, and its separation from the contents.  They
% expand to dimensions (they are not length registers).
\newcommand\colorframedTitledFrameRule{2pt}
\newcommand\colorframedTitledFrameSep{8pt}
\renewenvironment{titled-frame}[1]{%
  \def\FrameCommand{%
     \fboxsep\dimexpr\colorframedTitledFrameSep\relax
     \fboxrule\dimexpr\colorframedTitledFrameRule\relax
     \colorframedTitleBarFrame{\colorframedTitleFormat{#1}}}%
  \def\FirstFrameCommand{%
     \fboxsep\dimexpr\colorframedTitledFrameSep\relax
     \fboxrule\dimexpr\colorframedTitledFrameRule\relax
     \colorframedTitleBarFrame[\colorframedContinuationMark]%
       {\colorframedTitleFormat{#1}}}%
  \def\MidFrameCommand{%
     \fboxsep\dimexpr\colorframedTitledFrameSep\relax
     \fboxrule\dimexpr\colorframedTitledFrameRule\relax
     \colorframedTitleBarFrame[\colorframedContinuationMark]%
       {\colorframedTitleFormat{\colorframedContinuedTitle{#1}}}}%
  \def\LastFrameCommand{%
     \fboxsep\dimexpr\colorframedTitledFrameSep\relax
     \fboxrule\dimexpr\colorframedTitledFrameRule\relax
     \colorframedTitleBarFrame
       {\colorframedTitleFormat{\colorframedContinuedTitle{#1}}}}%
%  The text width is reduced by twice (separation + thickness).  Don't use
%  \width because the frame title could interfere with the width
%  measurement.
  \MakeFramed{\advance\hsize-2\dimexpr\colorframedTitledFrameSep
                                     +\colorframedTitledFrameRule\relax
              \FrameRestore}}%
 {\endMakeFramed}
%
% Tagging
% Nothing from here on is read by a document not using \DocumentMetadata.
% More details and observations are in the file TAGGING_MEMO.md of the
% repository.
\@ifundefined{tag_mc_add_missing_to_stream:Nn}{\endinput}{}
% With pdfLaTeX a paragraph continuing on the next page must have its
% marked content closed at the end of the page and opened again on the
% next one.  tagpdf does this in the output routine, but it can not see
% inside the boxes which framed has split by itself.  We apply the same
% tagpdf command to each such piece, and to the last one.  With LuaLaTeX
% this command does nothing (and nothing is needed).
%
% \tag_mc_new_stream:n of tagpdf 1.0i does not create the variable which
% \tag_mc_add_missing_to_stream:Nn needs, hence the second line; see
% https://github.com/latex3/tagpdf/issues/152
% This is fixed in tagpdf 1.0j, where the second line does nothing.
\ExplSyntaxOn
\tag_mc_new_stream:n { colorframed }
\seq_if_exist:cF { g__tag_mc_colorframed_marks_seq }
  { \seq_new:c { g__tag_mc_colorframed_marks_seq } }
\cs_new_protected:Npn \colorframed@fixmc #1
  { \tag_mc_add_missing_to_stream:Nn #1 { colorframed } }
\ExplSyntaxOff
% This is \fb@put@frame of framed.sty 0.96 without its debugging lines.
% The only changes are the added \colorframed@fixmc\tw@ and
% \colorframed@conttrue (see below about the latter).
\def\fb@put@frame#1#2{\relax
 \ifdim\pagegoal=\maxdimen \pagegoal\vsize \fi
 \ifinner
   \fb@putboxa#1%
   \fb@afterframe
 \else
  \dimen@\pagegoal \advance\dimen@-\pagetotal
  \ifdim\dimen@<2\baselineskip
    \eject \fb@adjheight \fb@put@frame#1#2%
  \else
     \fb@sizeofframe#1%
     \begingroup
     \advance\dimen@.8\pageshrink
     \advance\dimen@-\fb@frh\relax
     \expandafter\endgroup
     \ifdim\dimen@>\ht\@tempboxa
        \fb@putboxa#1%
        \fb@afterframe
     \else
        \fb@sizeofframe#2%
        \setbox\@tempboxa\vbox{%
           \vskip \fb@frh \@plus\pagestretch \@minus.8\pageshrink
           \kern137sp\kern-137sp\penalty-30
           \unvbox\@tempboxa}%
        \edef\fb@resto@set{\boxmaxdepth\the\boxmaxdepth
                           \splittopskip\the\splittopskip}%
        \boxmaxdepth\z@ \splittopskip\z@
        \setbox\tw@\vsplit\@tempboxa to\dimen@
        \setbox\tw@\vbox{\unvbox\tw@}%
        \begingroup
        \advance\dimen@\topskip
        \expandafter\endgroup
        \ifdim\dimen@>\pagegoal
          \dimen@ii\pagegoal
          \advance\dimen@ii -\topskip
          \advance\dimen@ii \FrameHeightAdjust\relax
        \else
          \advance\dimen@.8\pageshrink
          \ifdim\ht\tw@>\dimen@
            \dimen@ii\dimen@
          \else
            \dimen@ii\ht\tw@
          \fi
        \fi
        \advance\dimen@ii -\fb@frh
        \setbox\tw@\vbox to\dimen@ii \bgroup
        \vskip -\fb@frh \@plus-\pagestretch \@minus-.8\pageshrink
        \unvbox\tw@ \unpenalty\unpenalty
        \ifdim\lastkern=-137sp
           \egroup \fb@resto@set \eject
           \fb@adjheight
           \fb@put@frame#1#2%
        \else
           \egroup \fb@resto@set
           \ifvoid\@tempboxa
              \setbox\@tempboxa\box\tw@
              \fb@putboxa#1%
              \fb@afterframe
           \else
              \ifdim\wd\tw@>\z@
                \wd\tw@\wd\@tempboxa
                \colorframed@fixmc\tw@%<<<< ADDED
                \centerline{#2{\box\tw@}}%
              \else
                \box\tw@
              \fi
              \hrule \@height\z@ \@width\hsize
              \eject
              \fb@adjheight
              \colorframed@conttrue%<<<< ADDED
              \fb@put@frame\LastFrameCommand\MidFrameCommand
  \fi\fi\fi\fi\fi
}
% This is \fb@putboxa of framed.sty 0.96 without its debugging lines.
% The only change is the added \colorframed@fixmc\@tempboxa.
\def\fb@putboxa#1{%
  \ifvoid\@tempboxa
    \PackageWarning{framed}{Boxa is void -- discard it. }%
  \else
    \colorframed@fixmc\@tempboxa%<<<< ADDED
    \centerline{#1{\box\@tempboxa}}%
  \fi
}
% framed executes the frame commands on a dummy box to measure the frame.
% Nothing of this must be tagged (a title may contain mathematics, which
% would create a structure).
% This is \fb@sizeofframe of framed.sty 0.96 without its debugging lines.
% The only change is the added \SuspendTagging.
\def\fb@sizeofframe#1{\begingroup
 \SuspendTagging{colorframed}%<<<< ADDED
 \setbox\z@\vbox{\vskip-5in \hbox{\hskip-5in
   #1{\hbox{\vrule \@height 4.7in \@depth.3in \@width 5in}}}%
   \vskip\z@skip}%
 \global\fb@frw\wd\z@ \global\fb@frh\ht\z@
 \endgroup
}
% Structure of a frame.
% As tcolorbox does, each frame is a Sect structure, and its title (argument
% #2 of \TitleBarFrame and \colorframedTitleBarFrame), if any, is a Caption
% structure which is the first child of the Sect.  The Sect is opened at
% the start of \MakeFramed and closed at the end of \endMakeFramed.  This
% applies to all environments, leftbar included.
%
% A title is typeset by a frame command, hence after the contents of the
% frame.  To get it before them in the structure tree, an empty Caption
% is created at the start of \MakeFramed, and the structure of the title
% (a P), when it is typeset, is declared as a child of that one.  The title
% itself may contain what creates structures (mathematics for example).
% Whether a frame has a title is only known from the previous compilation
% (via a label): in a first compilation the Caption is created when the
% title is typeset, so it comes after the contents of the frame, and a
% warning asks for another compilation.
% Only the title of the first piece of a frame is handled this way (the
% one from \FrameCommand or \FirstFrameCommand).  Titles of the following
% pieces (\MidFrameCommand, \LastFrameCommand) and all continuation labels
% (argument #1) are artifacts.  \colorframed@artifact is also used for the
% rules, see below.
%
% \colorframed@frameno      numbers the frames (all of them)
% \colorframed@titlelabel   the label of the current frame; only its
%                           existence in the previous compilation is used,
%                           not the value recorded with it
% \colorframed@titleparent  number of the empty Caption created at the
%                           start of the current frame, empty if there is
%                           none
% \colorframed@endstruct    closes the Sect of the current frame, if one
%                           was opened (tagging may be suspended)
% \ifcolorframed@cont       true from the second piece of a frame on; it
%                           is set in \fb@put@frame, inside the group which
%                           \endMakeFramed opens around it
\newcount\colorframed@frameno
\newif\ifcolorframed@cont
\def\colorframed@titlelabel{colorframed-title-0}% if not inside \MakeFramed
\let\colorframed@titleparent\@empty
\let\colorframed@endstruct\relax
\def\colorframed@rerunwarning{%
  \AtEndDocument{\PackageWarningNoLine{colorframed}
    {Titles of frames are not at their place in the structure\MessageBreak
     tree. Rerun to get them right}}%
  \global\let\colorframed@rerunwarning\relax
}
\ExplSyntaxOn
\cs_new_protected:Npn \colorframed@beginstruct
  {
    \global\advance\colorframed@frameno\@ne
    \edef\colorframed@titlelabel{colorframed-title-\the\colorframed@frameno}
    \let\colorframed@titleparent\@empty
    \let\colorframed@endstruct\relax
    \tag_if_active:T
      {
        \tag_struct_begin:n { tag=Sect }
        \let\colorframed@endstruct\tag_struct_end:
        \exp_args:No \property_if_recorded:nT { \colorframed@titlelabel }
          {
            \tag_struct_begin:n { tag=Caption }
            \edef\colorframed@titleparent { \tag_get:n { struct_num } }
            \tag_struct_end:
          }
      }
  }
\cs_set_protected:Npn \colorframed@tagtitle #1
  {
    \tag_if_active:TF
      {
        \ifcolorframed@cont
          \colorframed@artifact {#1}
        \else
          \exp_args:No \property_record:nn { \colorframed@titlelabel } { abspage }
          \tl_if_empty:NTF \colorframed@titleparent
            {
              \colorframed@rerunwarning
              \tag_struct_begin:n { tag=Caption }
              \tag_struct_begin:n { tag=P }
            }
            {
              \exp_args:Ne \tag_struct_begin:n
                { tag=P, parent=\colorframed@titleparent }
            }
          \tag_mc_begin:n { tag=P }
          #1
          \tag_mc_end:
          \tag_struct_end:
          \tl_if_empty:NT \colorframed@titleparent { \tag_struct_end: }
        \fi
      }
      {#1}
  }
\cs_set_protected:Npn \colorframed@artifact #1
  {
    \tag_if_active:TF
      {
        \tag_mc_if_in:TF
          {#1}
          {
            \tag_mc_begin:n { artifact }
            \group_begin:
            \SuspendTagging { colorframed }
            #1
            \group_end:
            \tag_mc_end:
          }
      }
      {#1}
  }
\ExplSyntaxOff
% \MakeFramed (already redefined at the top of this file) gets a prefix,
% and \endMakeFramed a suffix.
% The \par comes first so that the structure of a paragraph in progress is
% closed before the structure of the frame is opened.
\let\colorframed@MakeFramed\MakeFramed
\def\MakeFramed{\par\colorframed@beginstruct\colorframed@MakeFramed}
\let\colorframed@endMakeFramed\endMakeFramed
\def\endMakeFramed{\colorframed@endMakeFramed\colorframed@endstruct}
% The title of \colorframed@TF@Title is a paragraph in a \vbox: it must not
% get a paragraph structure there.
\def\colorframed@notagpara{\tagpdfparaOff}
% This is \TF@Title of framed.sty 0.96, with \colorframed@tagtitle and
% \colorframed@artifact added.
\renewcommand\TF@Title[1]{%
  \ifx\delimiter#1\delimiter\else
  \kern-0.04pt\relax
  \begingroup
  \setbox\@tempboxa\vbox{%
   \kern0.8ex
   \hbox{\kern\fboxsep
         \textcolor{TFTitleColor}{\colorframed@tagtitle{#1}}\vphantom{Tj)}}%
   \kern0.8ex}%
  \colorframed@artifact{\hrule\@height\ht\@tempboxa}%
  \kern-\ht\@tempboxa
  \box\@tempboxa
  \endgroup
  \nointerlineskip
  \kern-0.04pt\relax
  \fi
}
% Rules and coloured backgrounds.
% With pdfLaTeX they must be marked as artifacts (LuaLaTeX does it by
% itself).  In the macros above this is done by \colorframed@artifact,
% which does nothing if a marked content is already open, as is the case
% if such a macro is used inside a paragraph.
% The leftbar environment of framed.sty needs it too.
\renewenvironment{leftbar}{%
  \def\FrameCommand{\colorframed@artifact{\vrule width 3pt}\hspace{10pt}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}
\endinput
