diff options
author | Karl Berry <karl@freefriends.org> | 2011-09-11 23:33:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-09-11 23:33:45 +0000 |
commit | aa9c5f6a29813abf377376fe0669a48ca5ee5dde (patch) | |
tree | 3cf29c585eb77c4bfec9ea4eb9a296f8c4b391d8 /Master/texmf-dist/tex/latex/mdframed/mdframed.sty | |
parent | 245bdb189ef1aad54d7c3a6da23c072067179b67 (diff) |
mdframed 0.9e (11sep11)
git-svn-id: svn://tug.org/texlive/trunk@23902 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mdframed/mdframed.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/mdframed/mdframed.sty | 234 |
1 files changed, 182 insertions, 52 deletions
diff --git a/Master/texmf-dist/tex/latex/mdframed/mdframed.sty b/Master/texmf-dist/tex/latex/mdframed/mdframed.sty index fe5c8b60e92..085743f886a 100644 --- a/Master/texmf-dist/tex/latex/mdframed/mdframed.sty +++ b/Master/texmf-dist/tex/latex/mdframed/mdframed.sty @@ -32,17 +32,17 @@ %% %% %%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>%% -%%$Id: mdframed.sty 188 2011-09-07 10:32:16Z marco $ -%%$Rev: 188 $ +%%$Id: mdframed.sty 198 2011-09-11 10:50:44Z marco $ +%%$Rev: 198 $ %%$Author: marco $ -%%$Date: 2011-09-07 12:32:16 +0200 (Mi, 07. Sep 2011) $ +%%$Date: 2011-09-11 12:50:44 +0200 (So, 11. Sep 2011) $ %% Allgemeine Angaben -\def\mdversion{v0.9b} +\def\mdversion{v0.9e} \def\mdframedpackagename{mdframed} \def\md@maindate@svn$#1: #2 #3 #4-#5-#6 #7 #8${#4/#5/#6\space } \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{mdframed}[\md@maindate@svn$Id: mdframed.sty 188 2011-09-07 10:32:16Z marco $ \mdversion: \mdframedpackagename] +\ProvidesPackage{mdframed}[\md@maindate@svn$Id: mdframed.sty 198 2011-09-11 10:50:44Z marco $ \mdversion: \mdframedpackagename] %%==================================================%% %%=============== Benoetigte Pakete ================%% %%==================================================%% @@ -53,7 +53,7 @@ \RequirePackage{#1}% }{% \md@PackageWarning{The package #1 does not exist^^J - but it is required by \mdframedpackagename^^J + but needed by \mdframedpackagename^^J see documentation fo further information }% } @@ -63,7 +63,7 @@ \md@LoadFile@IfExist{calc} \md@LoadFile@IfExist{color} \md@LoadFile@IfExist{etoolbox} - +\md@LoadFile@IfExist{zref-abspage} \SetupKeyvalOptions{family=mdf,prefix=mdf@} %%==================================================%% @@ -106,10 +106,10 @@ %%Schleifenmakro zur Optioneneingabe Option==Laenge \DeclareListParser*{\mdf@dolist}{,} -\def\mdf@do#1{% - \mdf@doubledo#1\@nil% +\def\mdf@do@lengthoption#1{% + \mdf@lengthoption@doubledo#1\@nil% } -\def\mdf@doubledo#1==#2\@nil{% +\def\mdf@lengthoption@doubledo#1==#2\@nil{% \mdf@option@length{#1}{#2}% \mdf@define@key@length{#1}% } @@ -117,28 +117,58 @@ %Festlegung welcher Stildatei %% 0 := tex-Kommandos -- rule %% 1 := tikz -%% 2 := tikz-erweitert -%% 3 := pstricks-einfach -%% 4 := pstricks-erweitert -\DeclareStringOption[0]{style} -\define@key{mdf}{globalstyle}[\mdf@style]{% - \def\md@styledo##1{% - \def\@tempa{##1} - \ifcase\number\@tempa\relax +%% 2 := pstricks +%% 3 := pstricks <- veraltet +\newcounter{mdf@globalstyle@cnt} +\defcounter{mdf@globalstyle@cnt}{0} +\newcommand*\mdfglobal@style{0} + +\define@key{mdf}{style}{% + \md@PackageWarning{package option style is depreciated^^J + use framemethod instead\MessageBreak}% + \renewcommand*\mdfglobal@style{#1}% + \defcounter{mdf@globalstyle@cnt}{#1}% + \ifcase\value{mdf@globalstyle@cnt}\relax %0 <- kein Grafikpaket \or\md@LoadFile@IfExist{tikz}%1 <- tikz wird benoetigt \or\md@LoadFile@IfExist{tikz}%2 <- tikz wird benoetigt \or\md@LoadFile@IfExist{pstricks-add}%3 <- pstricks wird benoetigt \or\md@LoadFile@IfExist{pstricks-add}%4 <- pstricks wird benoetigt - \else\md@PackageWarning{Unknown global style \@tempa}% - \fi - }% - \mdf@dolist{\md@styledo}{\mdf@style,#1}% - } + \else\md@PackageWarning{Unknown global style \value{mdf@globalstyle@cnt}}% + \fi% +} + +\providecommand*\mdf@framemethod{} +\define@key{mdf}{framemethod}[default]{% + \def\md@framemethod@i{}% + \def\md@framemethod@ii{}% + \def\md@framemethod@iii{}% + \lowercase{\def\md@tempa{#1}} + \forcsvlist{\listadd\md@framemethod@i}{default,tex,latex,none,0} + \forcsvlist{\listadd\md@framemethod@ii}{tikz,1} + \forcsvlist{\listadd\md@framemethod@iii}{pstricks,ps,2,postscript} + \xifinlist{\md@tempa}{\md@framemethod@i}% + {\def\mdf@@framemethod{default}\defcounter{mdf@globalstyle@cnt}{0}}% + {\xifinlist{\md@tempa}{\md@framemethod@ii}% + {\def\mdf@@framemethod{tikz}\defcounter{mdf@globalstyle@cnt}{1}}% + {\xifinlist{\md@tempa}{\md@framemethod@iii}% + {\def\mdf@@framemethod{pstricks}\defcounter{mdf@globalstyle@cnt}{2}}% + {\md@PackageWarning{Unknown framemethod \md@tempa\MessageBreak}}% + }% + }% + \ifcase\value{mdf@globalstyle@cnt}\relax% + %0 <- kein Grafikpaket + \or\md@LoadFile@IfExist{tikz}%1 <- tikz wird benoetigt + \or\md@LoadFile@IfExist{pstricks-add}%2 <- pstricks wird benoetigt + \or\md@LoadFile@IfExist{pstricks-add}%3 <- pstricks wird benoetigt <- support old style + \fi% +} + + %%%%Optionen mit Laengen -\mdf@dolist{\mdf@do}{% +\mdf@dolist{\mdf@do@lengthoption}{% {skipabove==\z@},% {skipbelow==\z@},% {leftmargin==\z@},% @@ -150,8 +180,8 @@ {innerbottommargin==0.4\baselineskip},% {splittopskip==\z@},% {splitbottomskip==\z@},% - {outermargin==\z@},% - {innermargin==\z@},% + {outermargin==-999pt},% + {innermargin==-999pt},% {linewidth==0.4pt},% {innerlinewidth==\z@},% {middlelinewidth==\expandafter\mdf@linewidth@length},% @@ -194,9 +224,24 @@ \DeclareStringOption[black]{fontcolor} \DeclareStringOption[\mdf@linecolor]{innerlinecolor} \DeclareStringOption[\mdf@linecolor]{outerlinecolor} -\DeclareStringOption[\mdf@backgroundcolor]{middlelinecolor} +\DeclareStringOption[\mdf@linecolor]{middlelinecolor} \DeclareStringOption[\mdf@backgroundcolor]{psroundlinecolor} +%Nutzung des Paketes needspace +\DeclareStringOption[\z@]{needspace} +\newcommand\mdf@sneedspace{} +\define@key{mdf}{needspace}[\z@]{% + \begingroup% + \setlength{\dimen@}{#1}% + \vskip\z@\@plus\dimen@% + \penalty -100\vskip\z@\@plus -\dimen@% + \vskip\dimen@% + \penalty 9999% + \vskip -\dimen@% + \vskip\z@skip % hide the previous |\vskip| from |\addvspace| + \endgroup% +} + \DeclareDefaultOption{% \md@PackageWarning{Unknown Option '\CurrentOption' for mdframed}} @@ -212,9 +257,21 @@ \DeclareStringOption[none]{printheight} -\ProcessKeyvalOptions* + +\ProcessKeyvalOptions*\relax \newcommand*{\mdfsetup}{\setkeys{mdf}} -\mdfsetup{globalstyle=0} + + +%Erlauben von mdfdefinestyle sowie redefinition von style +\define@key{mdf}{style}{% + \ifcsundef{mdf@definestyle@#1}{% + \md@PackageWarning{Unknown definedstyle #1^^J + You have to define a style via \string\mdfdefinedstyle\MessageBreak + }% + }% + {\csuse{mdf@definestyle@#1}}% +} + %%==================================================%% %%========Sicherstellen der key-value-Syntax========%% @@ -281,6 +338,14 @@ \def\md@endparenv{% \addpenalty\@endparpenalty\addvspace\mdf@skipbelow@length\@endpetrue} +%%==================================================%% +%%==================framestyle======================%% +%%==================================================%% +%inspired by Lars Madsen +\newrobustcmd*\mdfdefinestyle[2]{% + \csdef{mdf@definestyle@#1}{\mdfsetup{#2}}% +} + %%==================================================%% @@ -418,18 +483,16 @@ %%======= Laden der gewuenschten Style-Datei =======%% %%==================================================%% \newrobustcmd*\mdf@load@style{% -\ifcase\mdf@style\relax% +\ifcase\value{mdf@globalstyle@cnt}\relax% \input{md-frame-0.mdf}% \or\input{md-frame-1.mdf}% - \or\md@PackageWarning{The style number\mdf@style does not exist\MessageBreak - mdframed ues instead style=0 \mdframedpackagename}% - \input{md-frame-0.mdf}% + \or\input{md-frame-2.mdf} \or\input{md-frame-3.mdf}% \else% - \IfFileExists{md-frame-\mdf@style.mdf}{\input{md-frame-\mdf@style.mdf}% - }{\input{md-frame-1.mdf}% - \md@PackageWarning{The style number \mdf@style does not exist\MessageBreak - mdframed ues instead style=0 \mdframedpackagename}% + \IfFileExists{md-frame-\value{mdf@globalstyle@cnt}.mdf}{\input{md-frame-\value{mdf@globalstyle@cnt}.mdf}% + }{\input{md-frame-0.mdf}% + \md@PackageWarning{The style number \value{mdf@globalstyle@cnt} does not exist^^J + mdframed ues instead style=0 \mdframedpackagename}% }% \fi% }% @@ -438,7 +501,7 @@ %%========= style-abhaengige Modifikation ==========%% %%==================================================%% \newrobustcmd*\md@styledefinition{% - \ifnumequal{\mdf@style}{0}% + \ifnumequal{\value{mdf@globalstyle@cnt}}{0}% {\deflength{\mdf@innerlinewidth@length}{\z@}% \deflength{\mdf@middlelinewidth@length}{\mdf@linewidth@length}% \deflength{\mdf@outerlinewidth@length}{\z@}% @@ -446,18 +509,18 @@ \let\mdf@middlelinecolor\mdf@linecolor% \let\mdf@outerlinecolor\mdf@linecolor% }{}% - \ifnumequal{\mdf@style}{3}% + \ifnumequal{\value{mdf@globalstyle@cnt}}{2}% + {\deflength{\mdf@innerlinewidth@length}{\z@}% + \deflength{\mdf@middlelinewidth@length}{\mdf@linewidth@length}% + \deflength{\mdf@outerlinewidth@length}{\z@}% + \let\mdf@innerlinecolor\mdf@linecolor% + }{}% + \ifnumequal{\value{mdf@globalstyle@cnt}}{3}% {\deflength{\mdf@innerlinewidth@length}{\z@}% \deflength{\mdf@middlelinewidth@length}{\mdf@linewidth@length}% \deflength{\mdf@outerlinewidth@length}{\z@}% \let\mdf@innerlinecolor\mdf@linecolor% }{}% -% \ifnumequal{\mdf@style}{1}% -% {\deflength{\mdf@innerlinewidth@length}{\z@}% -% \deflength{\mdf@middlelinewidth@length}{\mdf@linewidth@length}% -% \deflength{\mdf@outerlinewidth@length}{\z@}% -% \let\mdf@innerlinecolor\mdf@linecolor% -% }{}% } %%==================================================%% @@ -521,6 +584,7 @@ %check is needed? \mdfsetup{#1}%% \mdf@settings% + \md@twoside@checklength% \let\width\z@% \let\height\z@% \setlength{\topsep}{\mdf@skipabove@length}% @@ -542,6 +606,59 @@ \hrule \@height\z@ \@width\hsize \endgroup% } +%%==================================================%% +%%================== Twoside-Modus =================%% +%%==================================================%% +\newtoggle{md:checktwoside} +\settoggle{md:checktwoside}{false} +\newrobustcmd*\md@twoside@checklength{% + \if@twoside + \ifboolexpr{ test {\ifdimequal{\mdf@outermargin@length}{-999pt}} + and + test {\ifdimequal{\mdf@innermargin@length}{-999pt}} + }% + {% + \md@PackageInfo{You haven't set the outermargin/innermargin^^ + mdframed will use leftmargin/rightmargin}% + \settoggle{md:checktwoside}{false}% + }% + {\settoggle{md:checktwoside}{true}}% + \iftoggle{md:checktwoside}{% + \let\mdf@rightmargin@length\mdf@outermargin@length\relax% + \let\mdf@leftmargin@length\mdf@innermargin@length\relax% + }{}% + \fi +} + +\newcounter{md@zref@counter}%keine doppelten laebes +\zref@newprop*{md@pagevalue}[0]{\number\value{page}} +\zref@addprop{\ZREF@mainlist}{md@pagevalue} + +\newrobustcmd*\md@zref@label{% + \stepcounter{md@zref@counter} + \zref@label{md@pagelabel-\number\value{md@zref@counter}}% +} + +\newrobustcmd*\if@md@pageodd{% + \zref@refused{md@pagelabel-\the\value{md@zref@counter}}% + \ifodd\zref@extract{md@pagelabel-\the\value{md@zref@counter}}{md@pagevalue}% + \edef\md@reserveda{\md@pageisodd}% + \else + \edef\md@reserveda{\md@pageiseven}% + \fi + \md@reserveda% +} + +\newrobustcmd*\md@pageisodd{% +\let\mdf@rightmargin@length\mdf@outermargin@length\relax% +\let\mdf@leftmargin@length\mdf@innermargin@length\relax% +} +\newrobustcmd*\md@pageiseven{% +\let\mdf@rightmargin@length\mdf@innermargin@length\relax% +\let\mdf@leftmargin@length\mdf@outermargin@length\relax% +} + +\newrobustcmd*\md@@setzref{\md@zref@label\if@md@pageodd} %%==================================================%% %%================= Platz auf Seite ================%% @@ -663,7 +780,11 @@ innerbottommargin,innerlinewidth,middlelinewidth,outerlinewidth}% \md@keeplines@single% \ifdimless{\md@verticalmarginwhole@length}{\md@freevspace@length}% - {\md@putbox@single%%passt auf Seite + {%passt auf Seite% + \begingroup + \iftoggle{md:checktwoside}{\md@@setzref}{}% + \md@putbox@single%%passt auf Seite + \endgroup \let\md@reserved@a\relax}% {\def\md@reserved@a{\md@put@frame@i}}%passt nicht auf Seite }% @@ -733,7 +854,10 @@ \def\md@reserved@a{\md@put@frame}% }% {% - \md@putbox@first%%%Groesse des Splittens passt + \begingroup + \iftoggle{md:checktwoside}{\md@@setzref}{}% + \md@putbox@first%%%Groesse des Splittens passt + \endgroup \hrule \@height\z@ \@width\hsize \vfill\eject% \def\md@reserved@a{\md@put@frame@ii}% @@ -759,20 +883,26 @@ \setbox\@tempboxa\vbox{\unvbox\@tempboxa}%PRUEFEN!!!! \ifvoid\@tempboxa\relax% \md@PackageWarning{You got a bad break\MessageBreak - because the splittet box is empty\MessageBreak + because the split box is empty\MessageBreak You have to change the settings}% \fi% - \md@putbox@middle% + \begingroup + \iftoggle{md:checktwoside}{\md@@setzref}{}% + \md@putbox@middle% + \endgroup \hrule \@height\z@ \@width\hsize \vfill\eject \def\md@reserved@a{\md@put@frame@ii}% }%Hier die Ausgabe der mittleren Box {\ifvoid\@tempboxa \md@PackageWarning{You got a bad break\MessageBreak - because the last splittet box is empty\MessageBreak + because the last split box is empty\MessageBreak You have to change the settings}% \fi% - \md@putbox@second% + \begingroup + \iftoggle{md:checktwoside}{\md@@setzref}{}% + \md@putbox@second% + \endgroup \let\md@reserved@a\relax% }%Hier kommt die Ausgabe der letzten Box \md@reserved@a% @@ -784,7 +914,7 @@ \DisableKeyvalOption[% action=warning, package=mdframed, -]{mdf}{globalstyle}% +]{mdf}{framemethod}% \DisableKeyvalOption[% action=warning, |