summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/colorframed/colorframed.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/colorframed/colorframed.sty')
-rw-r--r--macros/latex/contrib/colorframed/colorframed.sty82
1 files changed, 64 insertions, 18 deletions
diff --git a/macros/latex/contrib/colorframed/colorframed.sty b/macros/latex/contrib/colorframed/colorframed.sty
index 677cdef8a2..6b6de47977 100644
--- a/macros/latex/contrib/colorframed/colorframed.sty
+++ b/macros/latex/contrib/colorframed/colorframed.sty
@@ -1,23 +1,10 @@
-% colorframed.sty v0.9a 2022/09/23
-% Copyright (c) 2022 Jean-François Burnol
+% colorframed.sty v0.9b 2022/10/01
+% Copyright (C) 2022 Jean-François Burnol
% Distributed under the terms of the LPPL 1.3c, see README.md
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{colorframed}
- [2022/09/23 v0.9a fix `framed' breakable boxes colour leaks (JFB)]
-% This is actually same as 0.9 release of 2022/09/22 apart from these
-% comments:
-%
-% The analysis and original workarounds for using framed.sty
-% with colours were developed by me in some contributions I made
-% to the Sphinx project (\url{https://github.com/sphinx-doc/sphinx})
-% and I am transferring here the general idea.
-%
-% The key thing is that the boxes handled by framed.sty may
-% contain isolated colour push or colour pop. We must make
-% sure an isolated colour push, if followed by colour changes,
-% is always followed by paired ones, and never by a colour pop
-% from a colour command originated "prior".
-%
+ [2022/10/01 v0.9b fix `framed' breakable boxes colour leaks (JFB)]
+% Apart from code comments here, documentation is in colorframed-doc.pdf
\RequirePackage{framed}
\RequirePackage{color}
% First we must make \MakeFramed/\endMakeFramed colour safe.
@@ -123,8 +110,8 @@
\vbox{%
\colorframedbordercolorcommand % defaults to \normalcolor
\hrule\@height#3\relax
- \kern-#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%
@@ -167,4 +154,63 @@
%}% <<<< REMOVED
\endgroup
}
+% There are various issues with \TitleBarFrame/\TF@Title/TF@conlab
+% we provide an alternative
+\def\colorframedTFconlabsep{3pt}
+\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\colorframedTFconlabsep\relax #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 #1 to be
+% allowed to contain \par, the \textbf in titled-frame must be replaced by
+% some \bfseries.
+% Macro to customize the horizontal placement. For example
+% \def\colorframedTFtitleshift{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\colorframed@TF@Title[1]{%
+ \ifx\delimiter#1\delimiter\else
+ %\kern-0.04pt\relax
+ \kern-.5\fboxrule
+ \begingroup
+ \setbox\@tempboxa\vbox{%
+ \kern0.8ex
+ \hbox{\kern\fboxrule
+ \kern\dimexpr\colorframedTFtitlesep\relax
+ \vbox{\hsize\dimexpr\linewidth-2\fboxrule-
+ 2\dimexpr\colorframedTFtitlesep\relax\relax
+ \noindent\color{TFTitleColor}%
+ #1\par}}%
+ \kern0.8ex}%
+ \hrule\@height\ht\@tempboxa
+ \kern-\ht\@tempboxa
+ \box\@tempboxa
+ \endgroup
+ %\nointerlineskip
+ %\kern-0.04pt\relax
+ \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?
\endinput