diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-10 01:07:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-10 01:07:17 +0000 |
commit | b53037e64a69b6da11ac2ca3cc81253bbcf73275 (patch) | |
tree | c3f4f9f03d4db608ceafab35df1d3ee4f00050ba /Master/texmf-dist/tex | |
parent | c0c7a95312a208b088a58ff827c8ccd5d64d83fd (diff) |
new latex package tcolorbox (9dec11)
git-svn-id: svn://tug.org/texlive/trunk@24811 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tcolorbox/tcolorbox.sty | 295 |
1 files changed, 295 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tcolorbox/tcolorbox.sty b/Master/texmf-dist/tex/latex/tcolorbox/tcolorbox.sty new file mode 100644 index 00000000000..4e08c294d06 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tcolorbox/tcolorbox.sty @@ -0,0 +1,295 @@ +%% The LaTeX package tcolorbox - version 1.00 (2011/12/08) +%% tcolorbox.sty: Text color boxes +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2006-2011 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% ------------------------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `author-maintained'. +%% +%% This work consists of all files listed in README +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tcolorbox}[2011/12/08 version 1.00 text color boxes] + +\RequirePackage{pgf,calc,verbatim} + +% register +\newif\iftcb@lowerignored +\newif\iftcb@lowervisible +\newif\iftcb@hasTitle +\newif\iftcb@hasLower + +\newsavebox{\tcb@titlebox} +\newsavebox{\tcb@upperbox} +\newsavebox{\tcb@lowerbox} + +\newlength\tcb@textdim + + +% key management +\pgfkeys{/tcb/.is family} + +\def\tcbset{\pgfqkeys{/tcb}} + +\tcbset{ + title/.store in=\kvtcb@title, + notitle/.style={title=}, + width/.store in=\kvtcb@width, + boxsep/.store in=\kvtcb@boxsep, + boxrule/.store in=\kvtcb@boxrule, + left/.store in=\kvtcb@left, + right/.store in=\kvtcb@right, + top/.store in=\kvtcb@top, + bottom/.store in=\kvtcb@bottom, + middle/.store in=\kvtcb@middle, + arc/.store in=\kvtcb@arc, + colback/.store in=\kvtcb@colback, + colframe/.store in=\kvtcb@colframe, + coltext/.store in=\kvtcb@coltext, + coltitle/.store in=\kvtcb@coltitle, + fonttitle/.store in=\kvtcb@fonttitle, + fontupper/.store in=\kvtcb@fontupper, + fontlower/.store in=\kvtcb@fontlower, + tempfile/.store in=\kvtcb@tempfile, + savelowerto/.store in=\kvtcb@savelowerto, + savedelimiter/.estore in=\kvtcb@savedelimiter, + floatplacement/.store in=\kvtcb@floatplacement, + float/.store in=\kvtcb@float, + float/.default=\kvtcb@floatplacement, + nofloat/.style={float=}, + before/.store in=\kvtcb@beforebox, + after/.store in=\kvtcb@afterbox, + lowerbox/.is choice, + lowerbox/visible/.code={\tcb@lowerignoredfalse\tcb@lowervisibletrue}, + lowerbox/invisible/.code={\tcb@lowerignoredfalse\tcb@lowervisiblefalse}, + lowerbox/ignored/.code={\tcb@lowerignoredtrue\tcb@lowervisiblefalse}, +} + +\tcbset{notitle,width=\linewidth,boxsep=1mm,boxrule=0.5mm, + left=4mm,right=4mm,top=2mm,bottom=2mm,middle=2mm,arc=1mm,lowerbox=visible, + colback=black!5,colframe=black!75,coltext=black,coltitle=white, + fonttitle=,fontupper=,fontlower=,floatplacement=htb,nofloat,savelowerto=, + before={\par\pagebreak[0]\noindent},after={\par}, + savedelimiter={tcolorbox},tempfile={\jobname.tcbtemp}}% + + +% lrbox with integrated minipage +\def\tcb@lrbox#1{% + \edef\reserved@a{% + \endgroup + \setbox#1\hbox{% + \begingroup\aftergroup}% + \def\noexpand\@currenvir{\@currenvir}% + \def\noexpand\@currenvline{\on@line}}% + \reserved@a + \@endpefalse + \color@setgroup + \ignorespaces\minipage\tcb@textdim\ignorespaces} +\def\endtcb@lrbox{\unskip\endminipage\unskip\color@endgroup} + +\def\tcb@saveupperbox{% + \begin{tcb@lrbox}{\tcb@upperbox}\color{\kvtcb@coltext}\kvtcb@fontupper\ignorespaces} + +\def\tcb@savelowerbox{% + \begin{tcb@lrbox}{\tcb@lowerbox}\color{\kvtcb@coltext}\kvtcb@fontlower\ignorespaces} + + +% counter for float +\AtBeginDocument{% +\@ifundefined{c@float@type}% + {\edef\ftype@tcbfloat{\ifx\c@figure\@undefined 1\else 4\fi}}% + {\edef\ftype@tcbfloat{\the\c@float@type}% + \addtocounter{float@type}{\value{float@type}}}% +\def\c@tcbfloat{\c@float@type}% tricking the caption package +} + +\def\tcb@colorbox{% + \@ifnextchar[{\tcb@@icolorbox}{\tcb@@icolorbox[]}} + +\def\tcb@@icolorbox[#1]{% + % setting the keys + \tcbset{#1}% + \tcb@hasLowerfalse% + % computation of text width + \setlength{\tcb@textdim}{\kvtcb@width-\kvtcb@boxsep*2-\kvtcb@boxrule*2-\kvtcb@left-\kvtcb@right}% + \ifx\kvtcb@title\@empty\tcb@hasTitlefalse\else% + \tcb@hasTitletrue% + \begin{tcb@lrbox}{\tcb@titlebox}\color{\kvtcb@coltitle}\kvtcb@fonttitle\kvtcb@title\end{tcb@lrbox}% + \fi% + % switch for lower box + \def\tcblower{% + \end{tcb@lrbox}% + \tcb@hasLowertrue% + \ifx\kvtcb@savelowerto\@empty% + \let\tcb@startbox\tcb@savelowerbox% + \let\endtcolorbox\tcb@endboxanddraw% + \else% + \IfFileExists{\kvtcb@savelowerto}{% + \tcb@savelowerbox\input{\kvtcb@savelowerto}\end{tcb@lrbox}}{}% + \let\tcb@startbox\tcb@lowerverbatim% + \expandafter\let\csname end\kvtcb@savedelimiter\expandafter\endcsname\csname tcb@endlowerverbatimanddraw\endcsname% + \fi% + \tcb@startbox}% + % start of upper box + \let\endtcolorbox\tcb@endboxanddraw% + \tcb@saveupperbox% +} + +\let\tcolorbox\tcb@colorbox + +\def\tcb@endboxanddraw{% + \end{tcb@lrbox}% + \tcb@drawcolorbox% +} + +\let\endtcolorbox\tcb@endboxanddraw + +\def\tcb@drawcolorbox{% + % floats + \ifx\kvtcb@float\@empty% + \newenvironment{tcb@float}{\kvtcb@beforebox}{\kvtcb@afterbox}% + \else% + \edef\float@start{\noexpand\@float{tcbfloat}[\kvtcb@float]}% + \newenvironment{tcb@float}{\float@start}{\end@float}% + \fi% + % computation of total height + \setlength{\tcb@textdim}{\kvtcb@boxrule*2+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom+\ht\tcb@upperbox+\dp\tcb@upperbox}% + \iftcb@hasTitle\addtolength{\tcb@textdim}{\kvtcb@boxrule+\kvtcb@boxsep*2+\ht\tcb@titlebox+\dp\tcb@titlebox}\fi% + \iftcb@hasLower\iftcb@lowerignored\else% + \addtolength{\tcb@textdim}{\kvtcb@boxsep*2+\kvtcb@middle*2+\ht\tcb@lowerbox+\dp\tcb@lowerbox}% + \fi\fi% + \begin{tcb@float}\begin{pgfpicture}% + \begin{pgfscope}% + \pgfpathrectangle{\pgfpoint{0mm}{0mm}}{\pgfpoint{\kvtcb@width}{\tcb@textdim}}% + \pgfusepath{use as bounding box}% + % fill box + \pgfsetcornersarced{\pgfpoint{\kvtcb@arc+\kvtcb@boxrule}{\kvtcb@arc+\kvtcb@boxrule}}% + \pgfsetfillcolor{\kvtcb@colframe}% + \pgfpathrectangle{\pgfpoint{0mm}{0mm}}{\pgfpoint{\kvtcb@width}{\tcb@textdim}}% + \pgfusepath{fill}% + \end{pgfscope}% + % set title + \iftcb@hasTitle% + \addtolength{\tcb@textdim}{-\kvtcb@boxrule-\kvtcb@boxsep}% + \pgftext[x=\kvtcb@boxrule+\kvtcb@boxsep+\kvtcb@left, + y=\tcb@textdim,left,top]{\usebox{\tcb@titlebox}}% + % width of inner box + \addtolength{\tcb@textdim}{-\ht\tcb@titlebox-\dp\tcb@titlebox-\kvtcb@boxrule*2-\kvtcb@boxsep}% + \begin{pgfscope}% + % fill inner box with title + \pgfsetcornersarced{\pgfpoint{0mm}{0mm}}% + \pgfmoveto{\pgfpoint{\kvtcb@boxrule}{\kvtcb@boxrule}}% + \pgflineto{\pgfpoint{\kvtcb@boxrule}{\kvtcb@boxrule+\tcb@textdim}}% + \pgflineto{\pgfpoint{\kvtcb@width-\kvtcb@boxrule}{\kvtcb@boxrule+\tcb@textdim}}% + \pgfsetcornersarced{\pgfpoint{\kvtcb@arc}{\kvtcb@arc}}% + \pgflineto{\pgfpoint{\kvtcb@width-\kvtcb@boxrule}{\kvtcb@boxrule}}% + \pgflineto{\pgfpoint{\kvtcb@boxrule}{\kvtcb@boxrule}}% + \pgfpathclose + \pgfsetfillcolor{\kvtcb@colback}% + \pgfusepath{fill}% + \end{pgfscope}% + \else% + \addtolength{\tcb@textdim}{-\kvtcb@boxrule*2}% + \begin{pgfscope}% + % fill inner box without title + \pgfsetcornersarced{\pgfpoint{\kvtcb@arc}{\kvtcb@arc}}% + \pgfsetfillcolor{\kvtcb@colback}% + \pgfpathrectangle{\pgfpoint{\kvtcb@boxrule}{\kvtcb@boxrule}}% + {\pgfpoint{\kvtcb@width-\kvtcb@boxrule*2}{\tcb@textdim}}% + \pgfusepath{fill}% + \end{pgfscope}% + \fi% + % draw upper box + \pgftext[x=\kvtcb@boxrule+\kvtcb@boxsep+\kvtcb@left, + y=\tcb@textdim+\kvtcb@boxrule-\kvtcb@boxsep-\kvtcb@top,left,top]{\usebox{\tcb@upperbox}}% + % draw lower box + \iftcb@hasLower\iftcb@lowerignored\else% + \begin{pgfscope}% + \pgfsetcolor{\kvtcb@colframe}% + \pgfsetdash{{1mm}{1mm}}{0.5mm}% + \pgfpathmoveto{\pgfpoint{\kvtcb@boxrule}{\kvtcb@boxrule+\kvtcb@boxsep*2+\kvtcb@middle+\kvtcb@bottom+\ht\tcb@lowerbox+\dp\tcb@lowerbox}}% + \pgfpathlineto{\pgfpoint{\kvtcb@width-\kvtcb@boxrule}{\kvtcb@boxrule+\kvtcb@boxsep*2+\kvtcb@middle+\kvtcb@bottom+\ht\tcb@lowerbox+\dp\tcb@lowerbox}}% + \pgfusepath{stroke}% + \end{pgfscope}% + \iftcb@lowervisible% + \pgftext[x=\kvtcb@boxrule+\kvtcb@boxsep+\kvtcb@left, + y=\kvtcb@boxrule+\kvtcb@boxsep+\kvtcb@bottom,left,bottom]{\usebox{\tcb@lowerbox}}% + \fi% + \fi\fi% + \end{pgfpicture}\end{tcb@float}% +} + + +% verbatim output as in 'verbatim' + +\newwrite\tcb@out + +\def\tcbverbatimwrite#1{% + \@bsphack + \immediate\openout \tcb@out #1 + \let\do\@makeother\dospecials + \catcode`\^^M\active \catcode`\^^I=12 + \def\verbatim@processline{% + \immediate\write\tcb@out + {\the\verbatim@line}}% + \verbatim@start}%' + + +\def\endtcbverbatimwrite{% + \immediate\closeout\tcb@out + \@esphack% +} + + +% saving of the lower box + +\def\tcb@endlowerverbatimanddraw{% + \tcb@endlowerverbatim% + \tcb@drawcolorbox% +} + +\def\tcb@lowerverbatim{% + \tcbverbatimwrite\kvtcb@savelowerto} + +\let\tcb@endlowerverbatim\endtcbverbatimwrite% + + +% saving of the upper box + +\def\tcbwritetemp{% + \begingroup% + \tcbverbatimwrite\kvtcb@tempfile} + +\def\endtcbwritetemp{% + \endtcbverbatimwrite% + \endgroup% +} + +\def\tcbusetemp{\input{\kvtcb@tempfile}} + + +% libraries +\def\tcb@optionlist{} + +\def\tcbuselibrary#1{\tcbset{library/.cd,#1}} + +\def\tcb@add@library#1#2{% + \tcbset{library/#1/.code={\@ifundefined{tcblibrary@#1@loaded}{\input #2}{}}}% + \DeclareOption{#1}{\edef\tcb@optionlist{\tcb@optionlist,#1}}% +} + +\tcb@add@library{listings}{tcblistings.code.tex} +\tcb@add@library{theorems}{tcbtheorems.code.tex} + +\ProcessOptions* +\edef\tcb@temp{\noexpand\tcbuselibrary{\tcb@optionlist}} +\tcb@temp |