From 9ef4d43a194168faca909a9261e94c3ba72e85af Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 14 Aug 2012 23:23:14 +0000 Subject: tikz-cd (14aug12) git-svn-id: svn://tug.org/texlive/trunk@27403 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty | 253 +++++++++++++----------- 1 file changed, 135 insertions(+), 118 deletions(-) (limited to 'Master/texmf-dist/tex/latex/tikz-cd') diff --git a/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty b/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty index ff9eeabdbd4..12af09e5efb 100644 --- a/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty +++ b/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty @@ -5,12 +5,8 @@ % 1. under the LaTeX Project Public License and/or % 2. under the GNU Public License. % -\ProvidesPackage{tikz-cd}[2012/07/17 v0.2c Commutative diagrams with tikz.] -\RequirePackage{tikz} -\AtBeginDocument{% \fontdimen's can't be read reliably inside a tikzpicture - \setbox\pgfutil@tempboxa\hbox{$ $}% - \pgfmathparse{\the\fontdimen8\textfont3/1ex}\edef\tikzcdrulethickness{\pgfmathresult ex}% - \pgfmathparse{\the\fontdimen22\textfont2/1ex}\edef\tikzcdaxisheight{\pgfmathresult ex}} +\ProvidesPackage{tikz-cd}[2012/08/10 v0.3 Commutative diagrams with tikz.] +\RequirePackage{tikz}[2010/10/13] %pgf version 2.10 required \usetikzlibrary{matrix} @@ -28,9 +24,7 @@ /tikz/commutative diagrams/every diagram/.append style={#1}}, description/.style={ /tikz/anchor=center, - /tikz/fill=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, - /tikz/inner sep=% - \pgfkeysvalueof{/tikz/commutative diagrams/description clearance}}, + /tikz/fill=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}, crossing over/.style={ /tikz/preaction={ /tikz/draw=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, @@ -46,17 +40,52 @@ execute at begin node=\iftikzcd@mathmode$\fi, %$ execute at end node=\iftikzcd@mathmode$\fi}}, %$ start anchor/.code={% - \ifx#1\pgfkeysnovalue\let\tikzcd@sourceanchor\empty% - \else\def\tikzcd@sourceanchor{.#1}\fi}, + \tikzcd@threefold{\tikzcd@setanchor{start}}{}% + {\tikzcd@setanchor{start}[]}#1\relax},% end anchor/.code={% - \ifx#1\pgfkeysnovalue\let\tikzcd@targetanchor\empty% - \else\def\tikzcd@targetanchor{.#1}\fi}, + \tikzcd@threefold{\tikzcd@setanchor{end}}{}% + {\tikzcd@setanchor{end}[]}#1\relax},% arrow style/.is choice} % generic arrow tip selection styles \pgfqkeys{/tikz/commutative diagrams}{ - dashrightarrow/.style={/tikz/commutative diagrams/.cd,rightarrow,dashed}, - dashleftarrow/.style={/tikz/commutative diagrams/.cd,leftarrow,dashed}, + arrow style/generic/.style={ + /tikz/commutative diagrams/.cd, + rightarrow/.style={/tikz/arrows=#1 cap-#1 to}, + Rightarrow/.style={ + /tikz/arrows=#1 implies cap-#1 implies, + /tikz/commutative diagrams/double line}, + leftarrow/.style={/tikz/arrows=#1 to-#1 cap}, + Leftarrow/.style={ + /tikz/arrows=#1 implies-#1 implies cap, + /tikz/commutative diagrams/double line}, + leftrightarrow/.style={/tikz/arrows=#1 to-#1 to}, + Leftrightarrow/.style={ + /tikz/arrows=#1 implies-#1 implies, + /tikz/commutative diagrams/double line}, + mapsto/.style={/tikz/arrows=#1 |-#1 to}, + mapsfrom/.style={/tikz/arrows=#1 to-#1 |}, + hookrightarrow/.style={/tikz/arrows=#1 right hook-#1 to}, + hookleftarrow/.style={/tikz/arrows=#1 to-#1 left hook}, + rightharpoonup/.style={/tikz/arrows=#1 cap-#1 left to}, + rightharpoondown/.style={/tikz/arrows=#1 cap-#1 right to}, + leftharpoonup/.style={/tikz/arrows=#1 right to-#1 cap}, + leftharpoondown/.style={/tikz/arrows=#1 left to-#1 cap}, + dashrightarrow/.style={/tikz/arrows=-#1 to,/tikz/commutative diagrams/dashed}, + dashleftarrow/.style={/tikz/arrows=#1 to-,/tikz/commutative diagrams/dashed}, + rightarrowtail/.style={/tikz/arrows=#1 to reversed-#1 to}, + leftarrowtail/.style={/tikz/arrows=#1 to-#1 to reversed}, + twoheadrightarrow/.style={/tikz/arrows=#1 cap-#1 double to}, + twoheadleftarrow/.style={/tikz/arrows=#1 double to-#1 cap}, + dash/.style={/tikz/arrows=#1 cap-#1 cap}, + equal/.style={ + /tikz/arrows=#1 implies cap-#1 implies cap, + /tikz/commutative diagrams/double line}, + maps to/.code={\pgfsetarrowsstart{#1 |}}, + hook/.code={\pgfsetarrowsstart{#1 right hook}}, + two heads/.code={\pgfsetarrowsend{#1 double to}}, + tail/.code={\pgfsetarrowsstart{#1 to reversed}}}, + equals/.style={/tikz/commutative diagrams/equal}, rightsquigarrow/.style={ /tikz/commutative diagrams/.cd,rightarrow,squiggly}, leftsquigarrow/.style={/tikz/commutative diagrams/.cd,leftarrow,squiggly}, @@ -64,66 +93,38 @@ /tikz/commutative diagrams/.cd,leftrightarrow,squiggly}, squiggly/.code={% \expandafter\ifx\csname tikz@library@decorations.pathmorphing@loaded\endcsname\pgfutil@empty% - \else\PackageError{tikz-cd}{To use squiggly arrows, include % - \protect\usetikzlibrary{decorations.pathmorphing} in the document preamble}{}\fi}, + \else\PackageError{tikz-cd}{You need to say % + \string\usetikzlibrary{decorations.pathmorphing} to use squiggly arrows}{}\fi}, squiggly/.append style={ decorate, decoration={ zigzag, - segment length=4, - amplitude=.9, - post=lineto, post length=2pt, - pre=lineto, pre length=2pt}}} + segment length=9.25\pgflinewidth, + amplitude=1.9\pgflinewidth, + post=lineto, post length=6\pgflinewidth, + pre=lineto, pre length=6\pgflinewidth, + #1}}} % The Computer Modern arrow style \pgfqkeys{/tikz/commutative diagrams/arrow style}{ computer modern/.style={ /tikz/commutative diagrams/.cd, + arrow style/generic={cm}, default arrow/.style={ /tikz/line join=round, - /tikz/arrows=cm cap-cm to, - /tikz/line width=\tikzcdrulethickness}, - rightarrow/.style={/tikz/arrows=cm cap-cm to}, - Rightarrow/.style={ - /tikz/arrows=cm implies cap-cm implies, - /tikz/commutative diagrams/double line}, - leftarrow/.style={/tikz/arrows=cm to-cm cap}, - Leftarrow/.style={ - /tikz/arrows=cm implies-cm implies cap, - /tikz/commutative diagrams/double line}, - leftrightarrow/.style={/tikz/arrows=cm to-cm to}, - Leftrightarrow/.style={ - /tikz/arrows=cm implies-cm implies, - /tikz/commutative diagrams/double line}, - mapsto/.style={/tikz/arrows=cm |-cm to}, - hookrightarrow/.style={/tikz/arrows=cm right hook-cm to}, - hookleftarrow/.style={/tikz/arrows=cm to-cm left hook}, - rightharpoonup/.style={/tikz/arrows=cm cap-cm left to}, - rightharpoondown/.style={/tikz/arrows=cm cap-cm right to}, - leftharpoonup/.style={/tikz/arrows=cm right to-cm cap}, - leftharpoondown/.style={/tikz/arrows=cm left to-cm cap}, - rightarrowtail/.style={/tikz/arrows=cm to reversed-cm to}, - leftarrowtail/.style={/tikz/arrows=cm to-cm to reversed}, - twoheadrightarrow/.style={/tikz/arrows=cm cap-cm double to}, - twoheadleftarrow/.style={/tikz/arrows=cm double to-cm cap}, - equals/.style={ - /tikz/arrows=cm implies cap-cm implies cap, - /tikz/commutative diagrams/double line}, - maps to/.code={\pgfsetarrowsstart{cm |}}, - hook/.code={\pgfsetarrowsstart{cm right hook}}, - two heads/.code={\pgfsetarrowsend{cm double to}}, - tail/.code={\pgfsetarrowsstart{cm to reversed}}, + /tikz/commutative diagrams/rightarrow, + /tikz/line width=0.0929ex}, double line/.style={ /tikz/double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, /tikz/double distance=3.643\pgflinewidth}, - dashed/.style={/tikz/densely dashed}}} + dashed/.style={/tikz/dash pattern={on 7\pgflinewidth off 4\pgflinewidth}}}} % The tikz arrow style \pgfqkeys{/tikz/commutative diagrams/arrow style}{ tikz/.code={% \expandafter\ifx\csname tikz@library@arrows@loaded\endcsname\pgfutil@empty% - \else\PackageError{tikz-cd}{To use the `tikz' arrow style, include % - \protect\usetikzlibrary{arrows} in the document preamble}{}\fi}, + \else\PackageError{tikz-cd}{You need to say \string\usetikzlibrary{arrows} % + to use the `tikz' arrow style}{}\fi}, tikz/.append style={ /tikz/commutative diagrams/.cd, default arrow/.style={/tikz/arrows=->}, @@ -140,17 +141,21 @@ /tikz/arrows=implies-implies, /tikz/commutative diagrams/double line}, mapsto/.style={/tikz/arrows=|->}, + mapsfrom/.style={/tikz/arrows=<-|}, hookrightarrow/.style={/tikz/arrows=right hook->}, hookleftarrow/.style={/tikz/arrows=<-left hook}, rightharpoonup/.style={/tikz/arrows=-left to}, rightharpoondown/.style={/tikz/arrows=-right to}, leftharpoonup/.style={/tikz/arrows=right to-}, leftharpoondown/.style={/tikz/arrows=left to-}, + dashrightarrow/.style={/tikz/arrows=->,/tikz/commutative diagrams/dashed}, + dashleftarrow/.style={/tikz/arrows=<-,/tikz/commutative diagrams/dashed}, rightarrowtail/.style={/tikz/arrows=>->}, leftarrowtail/.style={/tikz/arrows=<-<}, twoheadrightarrow/.style={/tikz/arrows=->>}, twoheadleftarrow/.style={/tikz/arrows=<<-}, %>> - equals/.style={ + dash/.style={/tikz/arrows=-}, + equal/.style={ /tikz/arrows=-, /tikz/commutative diagrams/double line}, maps to/.code={\pgfsetarrowsstart{|}}, @@ -167,13 +172,16 @@ % Default settings \pgfqkeys{/tikz/commutative diagrams}{ every arrow/.style={ + /handlers/first char syntax/the character "/.initial=\tikzcd@passquotes, + /tikz/edge quotes mean/.try={edge node={node [/tikz/commutative diagrams/every label,##2]{\tikzcd@mathmaybe{##1}}}}, /tikz/commutative diagrams/.cd, /tikz/draw, /tikz/commutative diagrams/default arrow}, every label/.style={ /tikz/commutative diagrams/.cd, /tikz/auto, - /tikz/font=\scriptsize, + /tikz/font=\everymath\expandafter{\the\everymath\scriptstyle}, + % replace by \everymath{\scriptstyle} for plain TeX /tikz/inner sep=0.5ex}, every diagram/.style={ /tikz/commutative diagrams/.cd, @@ -182,7 +190,8 @@ column sep=normal, /tikz/baseline=0pt}, math mode=true, - center shift/.initial=\tikzcdaxisheight, + center yshift/.initial=tikzcdaxis, + center shift/.style={/tikz/commutative diagrams/center yshift=#1}, % this has been renamed row sep/huge/.initial=10ex, row sep/large/.initial=7.5ex, row sep/normal/.initial=5ex, @@ -196,12 +205,30 @@ column sep/small/.initial=3ex, column sep/tiny/.initial=1.5ex, arrow style=computer modern, - start anchor, - end anchor, - description clearance/.initial=1.5pt, - crossing over clearance/.initial=6pt, + description clearance/.code={% + \PackageWarning{tikz-cd}{The `description clearance' key has been deprecated}{}}, + crossing over clearance/.initial=1.5ex, background color/.initial=white} +% pgfmath functions to obtain math fontdimens +\pgfmathdeclarefunction{tikzcdaxis}{0}{% + \begingroup% + $\relax$% update fontdimens + \pgfutil@ifundefined{um_axis:N}% check if `unicode-math' is used + {\pgf@x=\the\fontdimen22\textfont2\relax}% + {\pgf@x=\expandafter\the\csname um_axis:N\endcsname\textstyle}% + \pgfmathreturn\pgf@x% + \endgroup} + +\pgfmathdeclarefunction{tikzcdrule}{0}{% + \begingroup% + $\relax$% + \pgfutil@ifundefined{um_fraction_rule:N}% + {\pgf@x=\the\fontdimen8\textfont3\relax}% + {\pgf@x=\expandafter\the\csname um_fraction_rule:N\endcsname\textstyle}% + \pgfmathreturn\pgf@x% + \endgroup} + % The shape used inside matrices \pgfdeclareshape{asymmetrical rectangle} { \inheritsavedanchors[from={rectangle}] @@ -219,17 +246,17 @@ \inheritanchor[from={rectangle}]{mid east} \inheritbackgroundpath[from={rectangle}] \anchor{center}{\pgf@anchor@rectangle@center\pgfmathsetlength\pgf@y% - {\pgfkeysvalueof{/tikz/commutative diagrams/center shift}}} + {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} \anchor{west}{\pgf@anchor@rectangle@west\pgfmathsetlength\pgf@y% - {\pgfkeysvalueof{/tikz/commutative diagrams/center shift}}} + {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} \anchor{east}{\pgf@anchor@rectangle@east\pgfmathsetlength\pgf@y% - {\pgfkeysvalueof{/tikz/commutative diagrams/center shift}}} + {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} \anchor{real center}{\pgf@anchor@rectangle@center} \anchor{real west}{\pgf@anchor@rectangle@west} \anchor{real east}{\pgf@anchor@rectangle@east} \anchorborder{% \pgfmathsetlength\pgfutil@tempdima% - {\pgfkeysvalueof{/tikz/commutative diagrams/center shift}}% + {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}% \pgf@xb=\pgf@x% xb/yb is target \pgf@yb=\pgf@y% \southwest% @@ -284,20 +311,20 @@ \toks@\expandafter{\tikzcd@savedpaths\path[/tikz/commutative diagrams/every arrow,#1]}% \global\edef\tikzcd@savedpaths{\the\toks@% (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn% - \noexpand\tikzcd@sourceanchor) to }% + \noexpand\tikzcd@startanchor) to }% \tikzcd@threefold{\tikzcd@ar@getlabel}{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}} \def\tikzcd@ar@getlabel[#1]#2{% - \expandafter\def\expandafter\tikzcd@savedpaths\expandafter{\tikzcd@savedpaths% + \expandafter\global\expandafter\def\expandafter\tikzcd@savedpaths\expandafter{\tikzcd@savedpaths% node[/tikz/commutative diagrams/every label,#1]{\tikzcd@mathmaybe{#2}}}% \tikzcd@threefold{\tikzcd@ar@getlabel}{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}} \def\tikzcd@ar@final{% - \toks@\expandafter{\tikzcd@savedpaths} + \toks@\expandafter{\tikzcd@savedpaths}% \global\edef\tikzcd@savedpaths{% \the\toks@% (\tikzmatrixname-\the\tikzcd@targetrow-\the\tikzcd@targetcol% - \noexpand\tikzcd@targetanchor); }} + \noexpand\tikzcd@endanchor); }} \def\tikzcd@xar#1{\tikzcd@threefold{\tikzcd@@xar{#1}}{\tikzcd@arrow[]{#1}}{\tikzcd@arrow[]{#1}}} @@ -314,7 +341,25 @@ only the characters l, r, u or d}{}\fi\fi\fi\fi\fi% \tikzcd@tempa} -%The tikzcd environment +% `quotes' library support (see also `every arrow' style) +\def\tikzcd@passquotes#1{\tikzset{every to/.append style={#1}}} + +% start anchor, end anchor keys +\def\tikzcd@setanchor#1[#2]#3\relax{% + \pgfkeysdef{/tikz/tikzcd@#1transform}{\tikzset{#2}}% + \ifx\relax#2\relax\else% + \tikzset{to path={([tikzcd@starttransform]\tikztostart) % + -- ([tikzcd@endtransform]\tikztotarget) \tikztonodes}}% + \fi% + \ifx\relax#3\relax% + \expandafter\let\csname tikzcd@#1anchor\endcsname\empty% + \else% + \expandafter\def\csname tikzcd@#1anchor\endcsname{.#3}% + \fi} + +\pgfqkeys{/tikz/commutative diagrams}{start anchor=,end anchor=} + +% The tikzcd environment \def\tikzcd{\tikzcd@threefold{\tikzcd@}{\tikzcd@[]}{\tikzcd@[]}} \def\tikzcd@[#1]{% @@ -344,7 +389,7 @@ \def\tikzcd@finalize{\tikzcd@savedpaths} -\def\tikzcd@mathmaybe#1{\iftikzcd@mathmode$ #1$\else#1\fi} +\def\tikzcd@mathmaybe#1{\iftikzcd@mathmode$\relax #1$\else#1\fi} \def\tikzcd@sep#1#2{ \pgfkeysifdefined{/tikz/commutative diagrams/#1 sep/#2}% @@ -674,60 +719,32 @@ % be big enough to contain the whole tip. \tikzset{/tikz/commutative diagrams/font arrows/.cd, double distance={3.8\pgflinewidth}, - declare head={math to}{$\to$}{\tikzcdaxisheight}{1ex}, - declare head={math to reversed}{$\leftarrowtail$}{\tikzcdaxisheight}{1ex}, - declare tail={math cap}{$\to$}{\tikzcdaxisheight}{1ex}, - declare tail={math |}{$\mapsto$}{\tikzcdaxisheight}{1ex}, - declare head={math o}{$\multimap$}{\tikzcdaxisheight}{1.4ex}, - declare head={math implies}{$\Rightarrow$}{\tikzcdaxisheight}{1.4ex}, - declare tail={math implies cap}{$\Rightarrow$}{\tikzcdaxisheight}{1ex}, - declare head={math left hook}{$\hookleftarrow$}{\tikzcdaxisheight}{1ex}, - declare tail={math right hook}{$\hookrightarrow$}{\tikzcdaxisheight}{1ex}, - declare head={math double to}{$\twoheadrightarrow$}{\tikzcdaxisheight}{1.4ex}, - declare head={math left to}{$\rightharpoonup$}{\tikzcdaxisheight}{1ex}, - declare head={math right to}{$\rightharpoondown$}{\tikzcdaxisheight}{1ex}, + declare head={math to}{$\to$}{tikzcdaxis}{1ex}, + declare head={math to reversed}{$\leftarrowtail$}{tikzcdaxis}{1ex}, + declare tail={math cap}{$\to$}{tikzcdaxis}{1ex}, + declare tail={math |}{$\mapsto$}{tikzcdaxis}{1ex}, + declare head={math o}{$\multimap$}{tikzcdaxis}{1.4ex}, + declare head={math implies}{$\Rightarrow$}{tikzcdaxis}{1.4ex}, + declare tail={math implies cap}{$\Rightarrow$}{tikzcdaxis}{1ex}, + declare head={math left hook}{$\hookleftarrow$}{tikzcdaxis}{1ex}, + declare tail={math right hook}{$\hookrightarrow$}{tikzcdaxis}{1ex}, + declare head={math double to}{$\twoheadrightarrow$}{tikzcdaxis}{1.4ex}, + declare head={math left to}{$\rightharpoonup$}{tikzcdaxis}{1ex}, + declare head={math right to}{$\rightharpoondown$}{tikzcdaxis}{1ex}, } % The `math font' arrow style \pgfkeys{/tikz/commutative diagrams/arrow style/math font/.style={ /tikz/commutative diagrams/.cd, enable font arrows, + arrow style/generic={math}, default arrow/.style={ - /tikz/arrows=math cap-math to, - /tikz/line width=\tikzcdrulethickness}, - rightarrow/.style={/tikz/arrows=math cap-math to}, - Rightarrow/.style={ - /tikz/arrows=math implies cap-math implies, - /tikz/commutative diagrams/double line}, - leftarrow/.style={/tikz/arrows=math to-math cap}, - Leftarrow/.style={ - /tikz/arrows=math implies-math implies cap, - /tikz/commutative diagrams/double line}, - leftrightarrow/.style={/tikz/arrows=math to-math to}, - Leftrightarrow/.style={ - /tikz/arrows=math implies-math implies, - /tikz/commutative diagrams/double line}, - mapsto/.style={/tikz/arrows=math |-math to}, - hookrightarrow/.style={/tikz/arrows=math right hook-math to}, - hookleftarrow/.style={/tikz/arrows=math to-math left hook}, - rightharpoonup/.style={/tikz/arrows=math cap-math left to}, - rightharpoondown/.style={/tikz/arrows=math cap-math right to}, - leftharpoonup/.style={/tikz/arrows=math right to-math cap}, - leftharpoondown/.style={/tikz/arrows=math left to-math cap}, - rightarrowtail/.style={/tikz/arrows=math to reversed-math to}, - leftarrowtail/.style={/tikz/arrows=math to-math to reversed}, - twoheadrightarrow/.style={/tikz/arrows=math cap-math double to}, - twoheadleftarrow/.style={/tikz/arrows=math double to-math cap}, - equals/.style={ - /tikz/arrows=math implies cap-math implies cap, - /tikz/commutative diagrams/double line}, - maps to/.code={\pgfsetarrowsstart{math |}}, - hook/.code={\pgfsetarrowsstart{math right hook}}, - two heads/.code={\pgfsetarrowsend{math double to}}, - tail/.code={\pgfsetarrowsstart{math to reversed}}, + /tikz/commutative diagrams/rightarrow, + /tikz/line width=tikzcdrule}, double line/.style={ /tikz/double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, /tikz/double distance=\tikzcdfontarrowsdoubledistance}, - dashed/.style={/tikz/densely dashed}}} + dashed/.style={/tikz/dash pattern=on 0.8ex off 0.4ex}, + squiggly/.default={pre length=1ex,post length=1ex}}} \endinput -- cgit v1.2.3