diff options
author | Norbert Preining <preining@logic.at> | 2014-03-03 01:44:52 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2014-03-03 01:44:52 +0000 |
commit | 4936f70d7918f67abee27a4b55746b15bd7095a5 (patch) | |
tree | a5a46a5c688280d05f5319c307c940c89a5e9e6e /Master | |
parent | 39cb23d10578b9db523f4f499d3dea3630787af0 (diff) |
tikz-cd (3Mar)
git-svn-id: svn://tug.org/texlive/trunk@33079 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-cd/README | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf | bin | 193501 -> 339276 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex | 2846 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty | 749 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-cd/tikzlibrarycd.code.tex | 683 |
5 files changed, 1638 insertions, 2645 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-cd/README b/Master/texmf-dist/doc/latex/tikz-cd/README index 0c3873a9930..9f7eee20ada 100644 --- a/Master/texmf-dist/doc/latex/tikz-cd/README +++ b/Master/texmf-dist/doc/latex/tikz-cd/README @@ -6,7 +6,8 @@ commutative diagrams and other kinds of mathematical pictures, generating high-quality results. The present package facilitates the creation of such diagrams by providing a convenient set of macros and reasonable default settings. It also includes an arrow tip library -closely matching the Computer Modern arrow tips. +closely matching the Computer Modern arrow tips, as well as a general +mechanism to use the arrow tips from any math font in TikZ graphics. This software is distributed under the GNU General Public License, -version 3 or later.
\ No newline at end of file +version 3 or later. diff --git a/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf b/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf Binary files differindex cda232b5787..be878f26e8f 100644 --- a/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf +++ b/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf diff --git a/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex b/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex index 34a40d2c936..2d0e1b53c2c 100644 --- a/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex +++ b/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex @@ -1,1335 +1,130 @@ -% Copyright 2011, 2012 by FlorĂȘncio Neves +% Copyright 2011, 2012, 2014 by FlorĂȘncio Neves % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. - +% % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. - +% % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % -% The preamble of this file contains parts of the files -% pgfmanual-en-main.tex and pgfmanual-en-macros.tex of the pgf package, -% copyright 2006 by Till Tantau and distributed under LPPL and/or GNU -% GPL. +% ------------------------------------------------------------------------ % -% To get cross-references to the pgf manual, it is necessary to +% This document requires the file pgfmanual-en-macros.tex (distributed +% with pgf) to compile. To get cross-references to the pgf manual, % compile it and copy all resulting .aux files to the directory of % tikz-cd-doc.tex. -% -% To compile with luatex, the fonts texgyrepagella-math.otf, -% xits-math.otf and lmodern-math.otf are needed. - -\documentclass{ltxdoc} - - \def\xcolorversion{2.00} - - \usepackage[version=latest]{pgf} - - \usepackage{xkeyval,calc,listings,tikz,fp} - - \usepackage{hyperref} - \hypersetup{% - colorlinks=true, % use true to enable colors below: - linkcolor=blue,%red, - filecolor=blue,%magenta, - pagecolor=blue,%red, - urlcolor=blue,%cyan, - citecolor=blue, - pdfborder=0 0 0, - } - - % We need lots of libraries... - \usetikzlibrary{ - arrows, - calc, - fit, - patterns, - plotmarks, - shapes.geometric, - shapes.misc, - shapes.symbols, - shapes.arrows, - shapes.callouts, - shapes.multipart, - shapes.gates.logic.US, - shapes.gates.logic.IEC, - circuits.logic.US, - circuits.logic.IEC, - circuits.logic.CDH, - circuits.ee.IEC, - datavisualization, - datavisualization.formats.functions, - er, - automata, - backgrounds, - chains, - topaths, - trees, - petri, - mindmap, - matrix, - calendar, - folding, - fadings, - shadings, - spy, - through, - turtle, - positioning, - scopes, - decorations.fractals, - decorations.shapes, - decorations.text, - decorations.pathmorphing, - decorations.pathreplacing, - decorations.footprints, - decorations.markings, - shadows, - lindenmayersystems, - intersections, - fixedpointarithmetic, - fpu, - svg.path, - external, - } - - \iffalse - % \iftrue - \tikzexternalize[ - mode=list only,export=true,% simply skips EVERY picture -> good for debugging the text. - ] - {pgfmanual} - - \tikzifexternalizing{% - \pgfkeys{/pdflinks/codeexample links=false}% - }{}% - \fi - - - \usepackage[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry} - \usepackage{amsmath,amssymb} - \usepackage{xxcolor} - \usepackage{pifont} - \usepackage{makeidx} - \usepackage{amsmath} - - \graphicspath{{../../images/}} % TODOsp: under windows this would go up 2 directories, but the file is only one directory up - % \makeindex - - \providecommand\href[2]{\texttt{#1}} - \providecommand\hypertarget[2]{\texttt{#1}} - \providecommand\hyperlink[2]{\texttt{#1}} - - - \colorlet{examplefill}{yellow!80!black} - \definecolor{graphicbackground}{rgb}{0.96,0.96,0.8} - \definecolor{codebackground}{rgb}{0.8,0.8,1} - - \newenvironment{pgfmanualentry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist} - \newcommand\pgfmanualentryheadline[1]{\itemsep=0pt\parskip=0pt\item\strut{#1}\par\topsep=0pt} - \newcommand\pgfmanualbody{\parskip3pt} - - - - \newenvironment{pgflayout}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{\texttt{\string\pgfpagesuselayout\char`\{\declare{#1}\char`\}}\oarg{options}} - \index{#1@\protect\texttt{#1} layout}% - \index{Page layouts!#1@\protect\texttt{#1}}% - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - - \newenvironment{command}[1]{ - \begin{pgfmanualentry} - \extractcommand#1\@@ - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{commandlist}[1]{% - \begin{pgfmanualentry} - \foreach \xx in {#1} {% - \expandafter\extractcommand\xx\@@ - }% - \pgfmanualbody - }{% - \end{pgfmanualentry} - }% - - % \begin{internallist}[register]{\pgf@xa} - % \end{internallist} - % - % \begin{internallist}[register]{\pgf@xa,\pgf@xb} - % \end{internallist} - \newenvironment{internallist}[2][register]{% - \begin{pgfmanualentry} - \foreach \xx in {#2} {% - \expandafter\extractinternalcommand\expandafter{\xx}{#1}% - }% - \pgfmanualbody - }{% - \end{pgfmanualentry} - }% - \def\extractinternalcommand#1#2{% - \pgfmanualentryheadline{Internal #2 \declare{\texttt{\string#1}}}% - \removeats{#1}% - \index{Internals!\strippedat @\protect\myprintocmmand{\strippedat}}% - \index{\strippedat @\protect\myprintocmmand{\strippedat}}% - \pgfmanualpdflabel{\textbackslash\strippedat}{}% - } - - %% MW: START MATH MACROS - \def\mvar#1{{\ifmmode\textrm{\textit{#1}}\else\rmfamily\textit{#1}\fi}} - - \makeatletter - - \def\extractmathfunctionname#1{\extractmathfunctionname@#1(,)\tmpa\tmpb} - \def\extractmathfunctionname@#1(#2)#3\tmpb{\def\mathname{#1}} - - \makeatother - - \newenvironment{math-function}[1]{ - \def\mathdefaultname{#1} - \extractmathfunctionname{#1} - \edef\mathurl{{math:\mathname}}\expandafter\hypertarget\expandafter{\mathurl}{}% - \begin{pgfmanualentry} - \pgfmanualentryheadline{\texttt{#1}}% - \index{\mathname @\protect\texttt{\mathname} math function}% - \index{Math functions!\mathname @\protect\texttt{\mathname}}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \def\pgfmanualemptytext{} - \def\pgfmanualvbarvbar{\char`\|\char`\|} - - \newenvironment{math-operator}[4][]{% - \begin{pgfmanualentry} - \csname math#3operator\endcsname{#2}{#4} - \def\mathtest{#4}% - \ifx\mathtest\pgfmanualemptytext% - \def\mathtype{(#3 operator)} - \else% - \def\mathtype{(#3 operator; uses the \texttt{#4} function)} - \fi% - \pgfmanualentryheadline{\mathexample\hfill\mathtype}% - \def\mathtest{#1}% - \ifx\mathtest\pgfmanualemptytext% - \index{#2@\protect\texttt{#2} #3 math operator}% - \index{Math operators!#2@\protect\texttt{#2}}% - \fi% - \pgfmanualbody - } - {\end{pgfmanualentry}} - - \newenvironment{math-operators}[5][]{% - \begin{pgfmanualentry} - \csname math#4operator\endcsname{#2}{#3} - \def\mathtest{#5}% - \ifx\mathtest\pgfmanualemptytext% - \def\mathtype{(#4 operators)} - \else% - \def\mathtype{(#4 operators; use the \texttt{#5} function)} - \fi% - \pgfmanualentryheadline{\mathexample\hfill\mathtype}% - \def\mathtest{#1}% - \ifx\mathtest\pgfmanualemptytext% - \index{#2#3@\protect\texttt{#2\protect\ #3} #4 math operators}% - \index{Math operators!#2#3@\protect\texttt{#2\protect\ #3}}% -vv \fi% - \pgfmanualbody - } - {\end{pgfmanualentry}} - - \def\mathinfixoperator#1#2{% - \def\mathoperator{\texttt{#1}}% - \def\mathexample{\mvar{x}\space\texttt{#1}\space\mvar{y}}% - } - - \def\mathprefixoperator#1#2{% - \def\mathoperator{\texttt{#1}}% - \def\mathexample{\texttt{#1}\mvar{x}}% - } - - \def\mathpostfixoperator#1#2{% - \def\mathoperator{\texttt{#1}} - \def\mathexample{\mvar{x}\texttt{#1}}% - } - - \def\mathgroupoperator#1#2{% - \def\mathoperator{\texttt{#1\ #2}}% - \def\mathexample{\texttt{#1}\mvar{x}\texttt{#2}}% - } - - \expandafter\let\csname matharray accessoperator\endcsname=\mathgroupoperator - \expandafter\let\csname matharrayoperator\endcsname=\mathgroupoperator - - \def\mathconditionaloperator#1#2{% - \def\mathoperator{#1\space#2} - \def\mathexample{\mvar{x}\ \texttt{#1}\ \mvar{y}\ {\texttt{#2}}\ \mvar{z}} - } - - \newcommand\mathcommand[1][\mathdefaultname]{% - \expandafter\makemathcommand#1(\empty)\stop% - \expandafter\extractcommand\mathcommandname\@@% - \medskip - } - \makeatletter - - \def\makemathcommand#1(#2)#3\stop{% - \expandafter\def\expandafter\mathcommandname\expandafter{\csname pgfmath#1\endcsname}% - \ifx#2\empty% - \else% - \@makemathcommand#2,\stop, - \fi} - \def\@makemathcommand#1,{% - \ifx#1\stop% - \else% - \expandafter\def\expandafter\mathcommandname\expandafter{\mathcommandname{\ttfamily\char`\{#1\char`\}}}% - \expandafter\@makemathcommand% - \fi} - \makeatother - - \def\calcname{\textsc{calc}} - %% MW: END MATH MACROS - - - \def\extractcommand#1#2\@@{% - \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% - \removeats{#1}% - \index{\strippedat @\protect\myprintocmmand{\strippedat}} - \pgfmanualpdflabel{\textbackslash\strippedat}{}% - } - - - % \begin{environment}{{name}\marg{arguments}} - \renewenvironment{environment}[1]{ - \begin{pgfmanualentry} - \extractenvironement#1\@@ - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \def\extractenvironement#1#2\@@{% - \pgfmanualentryheadline{{\ttfamily\char`\\begin\char`\{\declare{#1}\char`\}}#2}% - \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% - \pgfmanualentryheadline{{\ttfamily\char`\\end\char`\{\declare{#1}\char`\}}}% - \index{#1@\protect\texttt{#1} environment}% - \index{Environments!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - } - - - \newenvironment{plainenvironment}[1]{ - \begin{pgfmanualentry} - \extractplainenvironement#1\@@ - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \def\extractplainenvironement#1#2\@@{% - \pgfmanualentryheadline{{\ttfamily\declare{\char`\\#1}}#2}% - \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% - \pgfmanualentryheadline{{\ttfamily\declare{\char`\\end#1}}}% - \index{#1@\protect\texttt{#1} environment}% - \index{Environments!#1@\protect\texttt{#1}}% - } - - - \newenvironment{contextenvironment}[1]{ - \begin{pgfmanualentry} - \extractcontextenvironement#1\@@ - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \def\extractcontextenvironement#1#2\@@{% - \pgfmanualentryheadline{{\ttfamily\declare{\char`\\start#1}}#2}% - \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% - \pgfmanualentryheadline{{\ttfamily\declare{\char`\\stop#1}}}% - \index{#1@\protect\texttt{#1} environment}% - \index{Environments!#1@\protect\texttt{#1}}} - - - \newenvironment{shape}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Shape {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} shape}% - \index{Shapes!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{shading}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Shading {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} shading}% - \index{Shadings!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - - \newenvironment{dataformat}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Format {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} format}% - \index{Formats!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{handler}[1]{ - \begin{pgfmanualentry} - \extracthandler#1\@nil% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \def\gobble#1{} - \def\extracthandler#1#2\@nil{% - \pgfmanualentryheadline{Key handler \meta{key}{\ttfamily/\declare{#1}}#2}% - \index{\gobble#1@\protect\texttt{#1} handler}% - \index{Key handlers!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{/handlers/#1}% - } - - - \makeatletter - - - \newenvironment{stylekey}[1]{ - \begin{pgfmanualentry} - \def\extrakeytext{style, } - \extractkey#1\@nil% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \def\choicesep{$\vert$}% - \def\choicearg#1{\texttt{#1}} - - \newif\iffirstchoice - - % \mchoice{choice1,choice2,choice3} - \newcommand\mchoice[1]{% - \begingroup - \firstchoicetrue - \foreach \mchoice@ in {#1} {% - \iffirstchoice - \global\firstchoicefalse - \else - \choicesep - \fi - \choicearg{\mchoice@}% - }% - \endgroup - }% - - % \begin{key}{/path/x=value} - % \begin{key}{/path/x=value (initially XXX)} - % \begin{key}{/path/x=value (default XXX)} - \newenvironment{key}[1]{ - \begin{pgfmanualentry} - \def\extrakeytext{} - % \def\altpath{\emph{\color{gray}or}}% - \extractkey#1\@nil% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - % \insertpathifneeded{a key}{/pgf} -> assign mykey={/pgf/a key} - % \insertpathifneeded{/tikz/a key}{/pgf} -> assign mykey={/tikz/a key} - % - % #1: the key - % #2: a default path (or empty) - \def\insertpathifneeded#1#2{% - \def\insertpathifneeded@@{#2}% - \ifx\insertpathifneeded@@\empty - \def\mykey{#1}% - \else - \insertpathifneeded@#2\@nil - \ifpgfutil@in@ - \def\mykey{#2/#1}% - \else - \def\mykey{#1}% - \fi - \fi - }% - \def\insertpathifneeded@#1#2\@nil{% - \def\insertpathifneeded@@{#1}% - \def\insertpathifneeded@@@{/}% - \ifx\insertpathifneeded@@\insertpathifneeded@@@ - \pgfutil@in@true - \else - \pgfutil@in@false - \fi - }% - - % \begin{keylist}[default path] - % {/path/option 1=value,/path/option 2=value2} - % \end{keylist} - \newenvironment{keylist}[2][]{% - \begin{pgfmanualentry} - \def\extrakeytext{}% - \foreach \xx in {#2} {% - \expandafter\insertpathifneeded\expandafter{\xx}{#1}% - \expandafter\extractkey\mykey\@nil% - }% - \pgfmanualbody - }{% - \end{pgfmanualentry} - }% - - \def\extractkey#1\@nil{% - \pgfutil@in@={#1}% - \ifpgfutil@in@% - \extractkeyequal#1\@nil - \else% - \pgfutil@in@{(initial}{#1}% - \ifpgfutil@in@% - \extractequalinitial#1\@nil% - \else - \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill(\extrakeytext no value)}% - \def\mykey{#1}% - \def\mypath{}% - \def\myname{}% - \firsttimetrue% - \decompose#1/\nil% - \fi - \fi% - } - - \def\extractkeyequal#1=#2\@nil{% - \pgfutil@in@{(default}{#2}% - \ifpgfutil@in@% - \extractdefault{#1}#2\@nil% - \else% - \pgfutil@in@{(initial}{#2}% - \ifpgfutil@in@% - \extractinitial{#1}#2\@nil% - \else - \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill(\extrakeytext no default)}% - \fi% - \fi% - \def\mykey{#1}% - \def\mypath{}% - \def\myname{}% - \firsttimetrue% - \decompose#1/\nil% - } - - \def\extractdefault#1#2(default #3)\@nil{% - \pgfmanualentryheadline{{\ttfamily\declare{#1}\opt{=}}\opt{#2}\hfill (\extrakeytext default {\ttfamily#3})}% - } - - \def\extractinitial#1#2(initially #3)\@nil{% - \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill (\extrakeytext no default, initially {\ttfamily#3})}% - } - - \def\extractequalinitial#1 (initially #2)\@nil{% - \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill (\extrakeytext initially {\ttfamily#2})}% - \def\mykey{#1}% - \def\mypath{}% - \def\myname{}% - \firsttimetrue% - \decompose#1/\nil% - } - - % Introduces a key alias '/#1/<name of current key>' - % to be used inside of \begin{key} ... \end{key} - \def\keyalias#1{\vspace{-3pt}\item{\small alias {\ttfamily/#1/\myname}}\vspace{-2pt}\par - \pgfmanualpdflabel{/#1/\myname}{}% - } - - \newif\iffirsttime - - \makeatother - - \def\decompose/#1/#2\nil{% - \def\test{#2}% - \ifx\test\empty% - % aha. - \index{#1@\protect\texttt{#1} key}% - \index{\mypath#1@\protect\texttt{#1}}% - \def\myname{#1}% - \else% - \iffirsttime - \begingroup - % also make a pdf link anchor with full key path. - \def\hyperlabelwithoutslash##1/\nil{% - \pgfmanualpdflabel{##1}{}% - }% - \hyperlabelwithoutslash/#1/#2\nil - \endgroup - \def\mypath{#1@\protect\texttt{/#1/}!}% - \firsttimefalse - \else - \expandafter\def\expandafter\mypath\expandafter{\mypath#1@\protect\texttt{#1/}!}% - \fi - \def\firsttime{} - \decompose/#2\nil% - \fi% - } - - \def\indexkey#1{% - \def\mypath{}% - \decompose#1/\nil% - } - - \newenvironment{predefinedmethod}[1]{ - \begin{pgfmanualentry} - \extractpredefinedmethod#1\@nil - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - \def\extractpredefinedmethod#1(#2)\@nil{% - \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt) \hfill(predefined for all classes)} - \index{#1@\protect\texttt{#1} method}% - \index{Methods!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - } - - - \newenvironment{ooclass}[1]{ - \begin{pgfmanualentry} - \def\currentclass{#1} - \pgfmanualentryheadline{Class \declare{\texttt{#1}}} - \index{#1@\protect\texttt{#1} class}% - \index{Class #1@Class \protect\texttt{#1}}% - \index{Classes!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{method}[1]{ - \begin{pgfmanualentry} - \extractmethod#1\@nil - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - \def\extractmethod#1(#2)\@nil{% - \def\test{#1} - \ifx\test\currentclass - \pgfmanualentryheadline{Constructor \declare{\ttfamily #1}\texttt(#2\texttt)} - \else - \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt)} - \fi - \index{#1@\protect\texttt{#1} method}% - \index{Methods!#1@\protect\texttt{#1}} - \index{Class \currentclass!#1@\protect\texttt{#1}}% - \pgfmanualpdflabel{#1}{}% - } - - \newenvironment{attribute}[1]{ - \begin{pgfmanualentry} - \extractattribute#1\@nil - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - \def\extractattribute#1=#2;\@nil{% - \def\test{#2}% - \ifx\test\@empty - \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially empty)} - \else - \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially {\ttfamily #2})} - \fi - \index{#1@\protect\texttt{#1} attribute}% - \index{Attributes!#1@\protect\texttt{#1}} - \index{Class \currentclass!#1@\protect\texttt{#1}}% - \pgfmanualpdflabel{#1}{}% - } - - - - \newenvironment{predefinednode}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Predefined node {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} node}% - \index{Predefined node!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{coordinatesystem}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Coordinate system {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} coordinate system}% - \index{Coordinate systems!#1@\protect\texttt{#1}} - \pgfmanualpdflabel{#1}{}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{snake}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Snake {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} snake}% - \index{Snakes!#1@\protect\texttt{#1}} - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - \newenvironment{decoration}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{Decoration {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} decoration}% - \index{Decorations!#1@\protect\texttt{#1}} - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - - \def\pgfmanualbar{\char`\|} - \makeatletter - \newenvironment{pathoperation}[3][]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\path}\ - \ \dots} - \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% - \def\pgfmanualtest{#1}% - \ifx\pgfmanualtest\@empty% - \index{#2@\protect\texttt{#2} path operation}% - \index{Path operations!#2@\protect\texttt{#2}}% - \pgfmanualpdflabel{#2}{}% - \fi% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - \newenvironment{datavisualizationoperation}[3][]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\datavisualization}\ - \ \dots} - \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% - \def\pgfmanualtest{#1}% - \ifx\pgfmanualtest\@empty% - \index{#2@\protect\texttt{#2} (data visualization)}% - \index{Data visualization!#2@\protect\texttt{#2}}% - \pgfmanualpdflabel{#2}{}% - \fi% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - \makeatother - - \def\extractcommand#1#2\@@{% - \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% - \removeats{#1}% - \index{\strippedat @\protect\myprintocmmand{\strippedat}} - \pgfmanualpdflabel{\textbackslash\strippedat}{}% - } - - \def\doublebs{\texttt{\char`\\\char`\\}} - - - \newenvironment{package}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\char`\\usepackage\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX}} - \index{#1@\protect\texttt{#1} package}% - \index{Packages and files!#1@\protect\texttt{#1}}% - \pgfmanualentryheadline{{\ttfamily\char`\\input \declare{#1}.tex\space\space\space \char`\%\space\space plain \TeX}} - \pgfmanualentryheadline{{\ttfamily\char`\\usemodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t}} - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - - \newenvironment{pgfmodule}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule\char`\{\declare{#1}\char`\}\space\space\space - \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} - \index{#1@\protect\texttt{#1} module}% - \index{Modules!#1@\protect\texttt{#1}}% - \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} - \pgfmanualbody - \pgfmanualpdflabel{#1}{}% - } - { - \end{pgfmanualentry} - } - - \newenvironment{pgflibrary}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary\char`\{\declare{#1}\char`\}\space\space\space - \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} - \index{#1@\protect\texttt{#1} library}% - \index{Libraries!#1@\protect\texttt{#1}}% - \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} - \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space - \char`\%\space\space \LaTeX\space and plain \TeX\space when using \tikzname}} - \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space - \char`\%\space\space Con\TeX t\space when using \tikzname}} - \pgfmanualbody - \pgfmanualpdflabel{#1}{}% - } - { - \end{pgfmanualentry} - } - - \newenvironment{tikzlibrary}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX\space and plain \TeX}} - \index{#1@\protect\texttt{#1} library}% - \index{Libraries!#1@\protect\texttt{#1}}% - \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space \char`\%\space\space Con\TeX t}} - \pgfmanualbody - \pgfmanualpdflabel{#1}{}% - } - { - \end{pgfmanualentry} - } - - - - \newenvironment{filedescription}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{File {\ttfamily\declare{#1}}}% - \index{#1@\protect\texttt{#1} file}% - \index{Packages and files!#1@\protect\texttt{#1}}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - - \newenvironment{packageoption}[1]{ - \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\char`\\usepackage[\declare{#1}]\char`\{pgf\char`\}}} - \index{#1@\protect\texttt{#1} package option}% - \index{Package options for \textsc{pgf}!#1@\protect\texttt{#1}}% - \pgfmanualbody - } - { - \end{pgfmanualentry} - } - - - - \newcommand\opt[1]{{\color{black!50!green}#1}} - \newcommand\ooarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} - - \def\opt{\afterassignment\pgfmanualopt\let\next=} - \def\pgfmanualopt{\ifx\next\bgroup\bgroup\color{black!50!green}\else{\color{black!50!green}\next}\fi} - - - - \def\beamer{\textsc{beamer}} - \def\pdf{\textsc{pdf}} - \def\eps{\texttt{eps}} - \def\pgfname{\textsc{pgf}} - \def\tikzname{Ti\emph{k}Z} - \def\pstricks{\textsc{pstricks}} - \def\prosper{\textsc{prosper}} - \def\seminar{\textsc{seminar}} - \def\texpower{\textsc{texpower}} - \def\foils{\textsc{foils}} - - { - \makeatletter - \global\let\myempty=\@empty - \global\let\mygobble=\@gobble - \catcode`\@=12 - \gdef\getridofats#1@#2\relax{% - \def\getridtest{#2}% - \ifx\getridtest\myempty% - \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1} - \else% - \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1\protect\printanat} - \getridofats#2\relax% - \fi% - } - - \gdef\removeats#1{% - \let\strippedat\myempty% - \edef\strippedtext{\stripcommand#1}% - \expandafter\getridofats\strippedtext @\relax% - } - - \gdef\stripcommand#1{\expandafter\mygobble\string#1} - } - - \def\printanat{\char`\@} - - \def\declare{\afterassignment\pgfmanualdeclare\let\next=} - \def\pgfmanualdeclare{\ifx\next\bgroup\bgroup\color{red!75!black}\else{\color{red!75!black}\next}\fi} - - - \let\textoken=\command - \let\endtextoken=\endcommand - - \def\myprintocmmand#1{\texttt{\char`\\#1}} - - \def\example{\par\smallskip\noindent\textit{Example: }} - \def\themeauthor{\par\smallskip\noindent\textit{Theme author: }} - - - \def\indexoption#1{% - \index{#1@\protect\texttt{#1} option}% - \index{Graphic options and styles!#1@\protect\texttt{#1}}% - } - - \def\itemcalendaroption#1{\item \declare{\texttt{#1}}% - \index{#1@\protect\texttt{#1} date test}% - \index{Date tests!#1@\protect\texttt{#1}}% - } - - - - \def\class#1{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}% - \extractclass#1@\par\topsep=0pt} - \def\endclass{\endlist} - \def\extractclass#1#2@{% - \item{{{\ttfamily\char`\\documentclass}#2{\ttfamily\char`\{\declare{#1}\char`\}}}}% - \index{#1@\protect\texttt{#1} class}% - \index{Classes!#1@\protect\texttt{#1}}} - - \def\partname{Part} - - \makeatletter - \def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index} - This index only contains automatically generated entries. A good - index should also contain carefully selected keywords. This index is - not a good index. - \bigskip - } - \c@IndexColumns=2 - \def\theindex{\@restonecoltrue - \columnseprule \z@ \columnsep 29\p@ - \twocolumn[\index@prologue]% - \parindent -30pt - \columnsep 15pt - \parskip 0pt plus 1pt - \leftskip 30pt - \rightskip 0pt plus 2cm - \small - \def\@idxitem{\par}% - \let\item\@idxitem \ignorespaces} - \def\endtheindex{\onecolumn} - \def\noindexing{\let\index=\@gobble} - - - - \newcommand\symarrow[1]{ - \index{#1@\protect\texttt{#1} arrow tip}% - \index{Arrow tips!#1@\protect\texttt{#1}} - \texttt{#1}& yields thick - \begin{tikzpicture}[arrows={#1-#1},thick,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} and thin - \begin{tikzpicture}[arrows={#1-#1},thin,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} - } - \newcommand\symarrowdouble[1]{ - \index{#1@\protect\texttt{#1} arrow tip}% - \index{Arrow tips!#1@\protect\texttt{#1}} - \texttt{#1}& yields thick - \begin{tikzpicture}[arrows={#1-#1},thick,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} - and thin - \begin{tikzpicture}[arrows={#1-#1},thin,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture}, double - \begin{tikzpicture}[arrows={#1-#1},thick,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} and - \begin{tikzpicture}[arrows={#1-#1},thin,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} - } - - \newcommand\sarrow[2]{ - \index{#1@\protect\texttt{#1} arrow tip}% - \index{Arrow tips!#1@\protect\texttt{#1}} - \index{#2@\protect\texttt{#2} arrow tip}% - \index{Arrow tips!#2@\protect\texttt{#2}} - \texttt{#1-#2}& yields thick - \begin{tikzpicture}[arrows={#1-#2},thick,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} and thin - \begin{tikzpicture}[arrows={#1-#2},thin,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} - } - - \newcommand\sarrowdouble[2]{ - \index{#1@\protect\texttt{#1} arrow tip}% - \index{Arrow tips!#1@\protect\texttt{#1}} - \index{#2@\protect\texttt{#2} arrow tip}% - \index{Arrow tips!#2@\protect\texttt{#2}} - \texttt{#1-#2}& yields thick - \begin{tikzpicture}[arrows={#1-#2},thick,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} and thin - \begin{tikzpicture}[arrows={#1-#2},thin,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture}, double - \begin{tikzpicture}[arrows={#1-#2},thick,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} and - \begin{tikzpicture}[arrows={#1-#2},thin,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); - \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); - \end{tikzpicture} - } - - \newcommand\carrow[1]{ - \index{#1@\protect\texttt{#1} arrow tip}% - \index{Arrow tips!#1@\protect\texttt{#1}} - \texttt{#1}& yields for line width 1ex - \begin{tikzpicture}[arrows={#1-#1},line width=1ex,baseline] - \useasboundingbox (0pt,-0.5ex) rectangle (1.5cm,2ex); - \draw (0pt,.5ex) -- (1.5cm,.5ex); - \end{tikzpicture} - } - \def\myvbar{\char`\|} - \newcommand\plotmarkentry[1]{% - \index{#1@\protect\texttt{#1} plot mark}% - \index{Plot marks!#1@\protect\texttt{#1}} - \texttt{\char`\\pgfuseplotmark\char`\{\declare{#1}\char`\}} & - \tikz\draw[color=black!25] plot[mark=#1,mark options={fill=examplefill,draw=black}] coordinates{(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ - } - \newcommand\plotmarkentrytikz[1]{% - \index{#1@\protect\texttt{#1} plot mark}% - \index{Plot marks!#1@\protect\texttt{#1}} - \texttt{mark=\declare{#1}} & \tikz\draw[color=black!25] - plot[mark=#1,mark options={fill=examplefill,draw=black}] - coordinates {(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ - } - - - - \ifx\scantokens\@undefined - \PackageError{pgfmanual-macros}{You need to use extended latex - (elatex) or (pdfelatex) to process this document}{} - \fi - - \begingroup - \catcode`|=0%| - \catcode`[= 1 - \catcode`]=2 - \catcode`\{=12 - \catcode `\}=12 - \catcode`\\=12 |gdef|find@example#1\end{codeexample}[|endofcodeexample[#1]] - |endgroup - - % define \returntospace. - % - % It should define NEWLINE as {}, spaces and tabs as \space. - \begingroup - \catcode`\^=7 - \catcode`\^^M=13 - \catcode`\^^I=13 - \catcode`\ =13% - \gdef\returntospace{\catcode`\ =13\def {\space}\catcode`\^^I=13\def^^I{\space}} - \gdef\showreturn{\show^^M} - \endgroup - - \begingroup - \catcode`\%=13 - \catcode`\^^M=13 - \gdef\commenthandler{\catcode`\%=13\def%{\@gobble@till@return}} - \gdef\@gobble@till@return#1^^M{} - \gdef\@gobble@till@return@ignore#1^^M{\ignorespaces} - \gdef\typesetcomment{\catcode`\%=13\def%{\@typeset@till@return}} - \gdef\@typeset@till@return#1^^M{{\def%{\char`\%}\textsl{\char`\%#1}}\par} - \endgroup - - % Define tab-implementation functions - % \codeexample@tabinit@replacementchars@ - % and - % \codeexample@tabinit@catcode@ - % - % They should ONLY be used in case that tab replacement is active. - % - % This here is merely a preparation step. - % - % Idea: - % \codeexample@tabinit@catcode@ will make TAB active - % and - % \codeexample@tabinit@replacementchars@ will insert as many spaces as - % /codeexample/tabsize contains. - { - \catcode`\^^I=13 - % ATTENTION: do NOT use tabs in these definitions!! - \gdef\codeexample@tabinit@replacementchars@{% - \begingroup - \count0=\pgfkeysvalueof{/codeexample/tabsize}\relax - \toks0={}% - \loop - \ifnum\count0>0 - \advance\count0 by-1 - \toks0=\expandafter{\the\toks0\ }% - \repeat - \xdef\codeexample@tabinit@replacementchars@@{\the\toks0}% - \endgroup - \let^^I=\codeexample@tabinit@replacementchars@@ - }% - \gdef\codeexample@tabinit@catcode@{\catcode`\^^I=13}% - }% - - % Called after any options have been set. It assigns - % \codeexample@tabinit@catcode - % and - % \codeexample@tabinit@replacementchars - % which are used inside of - % \begin{codeexample} - % ... - % \end{codeexample} - % - % \codeexample@tabinit@catcode is either \relax or it makes tab - % active. - % - % \codeexample@tabinit@replacementchars is either \relax or it inserts - % a proper replacement sequence for tabs (as many spaces as - % configured) - \def\codeexample@tabinit{% - \ifnum\pgfkeysvalueof{/codeexample/tabsize}=0\relax - \let\codeexample@tabinit@replacementchars=\relax - \let\codeexample@tabinit@catcode=\relax - \else - \let\codeexample@tabinit@catcode=\codeexample@tabinit@catcode@ - \let\codeexample@tabinit@replacementchars=\codeexample@tabinit@replacementchars@ - \fi - } - - \pgfqkeys{/codeexample}{% - width/.code= {\setlength\codeexamplewidth{#1}}, - graphic/.code= {\colorlet{graphicbackground}{#1}}, - code/.code= {\colorlet{codebackground}{#1}}, - execute code/.is if=code@execute, - code only/.code= {\code@executefalse}, - pre/.store in=\code@pre, - post/.store in=\code@post, - % #1 is the *complete* environment contents as it shall be - % typeset. In particular, the catcodes are NOT the normal ones. - typeset listing/.code= {#1}, - render instead/.store in=\code@render, - vbox/.code= {\def\code@pre{\vbox\bgroup\setlength{\hsize}{\linewidth-6pt}}\def\code@post{\egroup}}, - ignorespaces/.code= {\let\@gobble@till@return=\@gobble@till@return@ignore}, - leave comments/.code= {\def\code@catcode@hook{\catcode`\%=12}\let\commenthandler=\relax\let\typesetcomment=\relax}, - tabsize/.initial=0,% FIXME : this here is merely used for indentation. It is just a TAB REPLACEMENT. - every codeexample/.style={width=4cm+7pt}, - } - - \let\code@pre\pgfutil@empty - \let\code@post\pgfutil@empty - \let\code@render\pgfutil@empty - \def\code@catcode@hook{} - - \newdimen\codeexamplewidth - \newif\ifcode@execute - \newbox\codeexamplebox - \def\codeexample[#1]{% - \begingroup% - \code@executetrue - \pgfqkeys{/codeexample}{every codeexample,#1}% - \codeexample@tabinit% assigns \codeexample@tabinit@[catcode,replacementchars] - \parindent0pt - \begingroup% - \par% - \medskip% - \let\do\@makeother% - \dospecials% - \obeylines% - \@vobeyspaces% - \catcode`\%=13% - \catcode`\^^M=13% - \code@catcode@hook% - \codeexample@tabinit@catcode - \relax% - \find@example} - \def\endofcodeexample#1{% - \endgroup% - \ifcode@execute% - \setbox\codeexamplebox=\hbox{% - \ifx\code@render\pgfutil@empty% - {% - {% - \returntospace% - \commenthandler% - \xdef\code@temp{#1}% removes returns and comments - }% - \catcode`\^^M=9% - \colorbox{graphicbackground}{\color{black}\ignorespaces% - \code@pre\expandafter\scantokens\expandafter{\code@temp\ignorespaces}\code@post\ignorespaces}% - }% - \else% - \colorbox{graphicbackground}{\color{black}\ignorespaces% - \code@render}% - \fi% - }% - \ifdim\wd\codeexamplebox>\codeexamplewidth% - \def\code@start{\par}% - \def\code@flushstart{}\def\code@flushend{}% - \def\code@mid{\parskip2pt\par\noindent}% - \def\code@width{\linewidth-6pt}% - \def\code@end{}% - \else% - \def\code@start{% - \linewidth=\textwidth% - \parshape \@ne 0pt \linewidth - \leavevmode% - \hbox\bgroup}% - \def\code@flushstart{\hfill}% - \def\code@flushend{\hbox{}}% - \def\code@mid{\hskip6pt}% - \def\code@width{\linewidth-12pt-\codeexamplewidth}% - \def\code@end{\egroup}% - \fi% - \code@start% - \noindent% - \begin{minipage}[t]{\codeexamplewidth}\raggedright - \hrule width0pt% - \footnotesize\vskip-1em% - \code@flushstart\box\codeexamplebox\code@flushend% - \vskip-1ex - \leavevmode% - \end{minipage}% - \else% - \def\code@mid{\par} - \def\code@width{\linewidth-6pt} - \def\code@end{} - \fi% - \code@mid% - \colorbox{codebackground}{% - \begin{minipage}[t]{\code@width}% - {% - \let\do\@makeother - \dospecials - \frenchspacing\@vobeyspaces - \normalfont\ttfamily\footnotesize - \typesetcomment% - \codeexample@tabinit@replacementchars - \@tempswafalse - \def\par{% - \if@tempswa - \leavevmode \null \@@par\penalty\interlinepenalty - \else - \@tempswatrue - \ifhmode\@@par\penalty\interlinepenalty\fi - \fi}% - \obeylines - \everypar \expandafter{\the\everypar \unpenalty}% - \pgfkeysvalueof{/codeexample/typeset listing/.@cmd}{#1}\pgfeov - } - \end{minipage}}% - \code@end% - \par% - \medskip - \end{codeexample} - } - - \def\endcodeexample{\endgroup} - - - \makeatother - - \usepackage{pgfmanual} - - \makeatletter - % \pgfautoxrefs will be defined by 'make dist' - \pgfutil@ifundefined{pgfautoxrefs}{% - \def\pgfmanualpdflabel#1#2{#2}% NO-OP - \def\pgfmanualpdfref#1#2{#2}% - \pgfkeys{ - /pdflinks/codeexample links=false,% DISABLED. - }% - }{} - \makeatother - - - \makeatletter - \renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.8em}} - \renewcommand*\l@subsubsection{\@dottedtocline{3}{4.3em}{3.2em}} - \makeatother - - % \includeonly{pgfmanual-en-library-profiler} - - % Global styles: - \tikzset{ - every plot/.style={prefix=plots/pgf-}, - shape example/.style={ - color=black!30, - draw, - fill=yellow!30, - line width=.5cm, - inner xsep=2.5cm, - inner ysep=0.5cm} - } + +\def\pgfautoxrefs{1} + +\documentclass[a4paper]{ltxdoc} + +\def\xcolorversion{2.00} + +\usepackage[version=latest]{pgf} + +\usepackage{xkeyval,calc,listings,tikz,fp} + +\usepackage{hyperref} +\hypersetup{% + colorlinks=true, % use true to enable colors below: + linkcolor=blue,%red, + filecolor=blue,%magenta, + pagecolor=blue,%red, + urlcolor=blue,%cyan, + citecolor=blue, + pdfborder=0 0 0, +} + +% We need lots of libraries... +\usetikzlibrary{ + arrows, + arrows.meta, + calc, + fit, + patterns, + plotmarks, + shapes.geometric, + shapes.misc, + shapes.symbols, + shapes.arrows, + shapes.callouts, + shapes.multipart, + shapes.gates.logic.US, + shapes.gates.logic.IEC, + circuits.logic.US, + circuits.logic.IEC, + circuits.logic.CDH, + circuits.ee.IEC, + datavisualization, + datavisualization.formats.functions, + er, + automata, + backgrounds, + chains, + topaths, + trees, + petri, + mindmap, + matrix, + calendar, + folding, + fadings, + shadings, + spy, + through, + turtle, + positioning, + scopes, + decorations.fractals, + decorations.shapes, + decorations.text, + decorations.pathmorphing, + decorations.pathreplacing, + decorations.footprints, + decorations.markings, + shadows, + lindenmayersystems, + intersections, + fixedpointarithmetic, + fpu, + svg.path, + external, +} + +\usepackage[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry} +\usepackage{amsmath,amssymb} +\usepackage{xxcolor} +\usepackage{pifont} +\usepackage{makeidx} +\usepackage{amsmath} + +\graphicspath{{../../images/}} % TODOsp: under windows this would go up 2 directories, but the file is only one directory up +\input{pgfmanual-en-macros} % TODOsp: same here + +\makeindex + +\makeatletter +\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.8em}} +\renewcommand*\l@subsubsection{\@dottedtocline{3}{4.3em}{3.2em}} +\makeatother + +% Global styles: +\tikzset{ + every plot/.style={prefix=plots/pgf-}, + shape example/.style={ + color=black!30, + draw, + fill=yellow!30, + line width=.5cm, + inner xsep=2.5cm, + inner ysep=0.5cm} +} \usepackage{iftex,tikz-cd,xr} \ifLuaTeX @@ -1342,131 +137,203 @@ vv \fi% pdftitle={The tikz-cd package}, pdfauthor={FlorĂȘncio Neves}, pdfkeywords={commutative diagrams, latex, tikz, pgf}, - colorlinks, } \externaldocument[pgfman-]{pgfmanual} - + +\pgfkeys{ + /pdflinks/search key prefixes in= + {/tikz/commutative diagrams/},%,/tikz/,/pgf/} % This really needs to be commented out! + /pdflinks/internal link prefix=tikzcd, + % + /pdflinks/warnings=false, + % for debugging: + /pdflinks/show labels=false, +} + \title{The \texttt{tikz-cd} package} -\author{FlorĂȘncio Neves\footnote{\emph{E-mail:} \href{mailto:florencioneves@gmail.com}{\texttt{florencioneves@gmail.com}}}} -\date{Version 0.3c, of December 30, 2012} +\author{FlorĂȘncio Neves} +\date{Version 0.9, of February 28, 2014} + +\tikzset{/codeexample/every codeexample/.append style={/tikz/commutative diagrams/background color=graphicbackground}} + +\pgfarrowsdeclare{gray x}{gray x} +{ + \pgfarrowsrightextend{4\pgflinewidth} +} +{ + \pgfsetdash{}{0pt} + \pgfsetlinewidth{0.8\pgflinewidth} + \pgfsetstrokecolor{gray} + \pgfpathmoveto{\pgfpoint{5\pgflinewidth}{5\pgflinewidth}} + \pgfpathlineto{\pgfpoint{-5\pgflinewidth}{-5\pgflinewidth}} + \pgfusepathqstroke + \pgfpathmoveto{\pgfpoint{-5\pgflinewidth}{5\pgflinewidth}} + \pgfpathlineto{\pgfpoint{5\pgflinewidth}{-5\pgflinewidth}} + \pgfusepathqstroke +} -\tikzset{commutative diagrams/background color=graphicbackground} +\newcommand{\displayarrow}[2][]{% + \index{#2@\protect\texttt{#2} arrow tip}% + \index{Arrow tips!#2@\protect\texttt{#2}}% + \texttt{#2} & yields \tikz[baseline=-axis_height] \draw[{#2}-{#2}, line width=rule_thickness, #1] (0,0) -- (1,0);} -\newcommand{\displayarrow}[2][]{\texttt{#2} & yields \tikz[baseline=-2.5pt] \draw[#2-#2, line width=0.0929ex, #1] (0,0) -- (1,0);} -\newcommand{\displayarrowstyle}[2][]{\texttt{#2} #1 & yields - \tikz[baseline=-tikzcdaxis, line width=tikzcdrule] \draw[commutative diagrams/.cd, #2] (0,0) -- (0.6,0);} +\newcommand{\displayarrowstyle}[1]{ + \def\mykey{/tikz/commutative diagrams/#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + %\pgfmanualdecomposecount=0\relax% + \decompose/tikz/commutative diagrams/#1/\nil% + \texttt{#1} & yields + \tikz[baseline=-axis_height, line width=rule_thickness] \draw[arrows=gray + x-gray x,commutative diagrams/.cd, #1] (0,0) -- (0.6,0);} -\usepackage{microtype,ellipsis} +\usepackage{multicol,microtype,ellipsis} \begin{document} \maketitle The general-purpose drawing package Ti\emph{k}Z can be used to typeset commutative diagrams and other kinds of mathematical pictures, -generating high-quality results (see for example \cite{lenders} or -\cite{milne}). The present package facilitates the creation of such diagrams -by providing a convenient set of macros and reasonable default -settings. Familiarity with Ti\emph{k}Z is helpful but not necessary, -since the examples contained here cover the most common situations. +generating high-quality results. The present package facilitates the +creation of such diagrams by providing a convenient set of macros and +reasonable default settings. Familiarity with Ti\emph{k}Z is helpful +but not necessary, since the examples contained here cover the most +common situations. -This package also includes an arrow tip library closely matching the -Computer Modern arrow tips. +This software is distributed under the GNU General Public License, +version 3 or later. \tableofcontents -\section{Basic usage} +\setcounter{section}{-1} +\section{Disclaimer} +\label{sec:disclaimer} + +Before version 1.0 of this package is released, minor modifications and +bug fixes may be performed. All documents making an orthodox use of +this package will continue to compile and generate essentially the +same output. However, if you have strict stability requirements (for +instance, if you want to assure no page break changes will happen in +your documents), keep a copy of the current version of the file +\texttt{tikzlibrarycd.code.tex} in your document's directory. + +\section{Getting started} \label{sec:basic-usage} -Commutative diagrams are created with the |tikzcd| environment. Its -content describes a matrix, similarly to the |\matrix| command in -\tikzname{} or the |align| environment in \LaTeX. Everything is -typeset in math mode, but you will probably want use \texttt{tikzcd} -inside |\[| \dots\ |\]| or an \texttt{equation} environment, so that -the diagram is placed on a new line and centered. +To invoke this package in \LaTeX, type + +\begin{quote} + \index{tikz-cd@\protect\texttt{tikz-cd} package}% + \index{Packages and files!tikz-cd@\protect\texttt{tikz-cd}}% +{{\ttfamily\char`\\usepackage\char`\{\declare{tikz-cd}\char`\}}} +\end{quote} +or load \tikzname{} and then type +\begin{quote}% + \index{cd@\protect\texttt{cd} library}% + \index{Libraries!cd@\protect\texttt{cd}}% + {{\ttfamily\char`\\usetikzlibrary\char`\{\declare{cd}\char`\}}}\pgfmanualpdflabel{cd}{}% +\end{quote} + +\subsection{Creating a diagram} +\label{sec:creating-diagrams} + +The basic tool to create a commutative diagram is the following +environment. + +\begin{environment}{{tikzcd}\opt{\oarg{options}}} +\end{environment} + +The environment contents should describe a matrix, as in \LaTeX's +familiar |{tabular}| environment. The optional argument +\meta{options} may be used to modify the appearance of the diagram. +Any of the customization keys described in this manual, as well as +those originally provided by \tikzname{}, can be used here. Arrows +between matrix entries can be created with the |\arrow| command +described below. -% Diagrams will not be displayed correctly in the \textsc{dvi} file. It -% is necessary to convert it to \textsc{pdf} or \textsc{ps} format---or, -% even better, use \texttt{pdflatex} to obtain a \textsc{pdf} file -% directly. +Everything inside |{tikzcd}| is typeset in math mode, but you will +probably want use it inside an |{equation}| environment or |\[| \dots\ +|\]|, so that the diagram is placed on a new line and centered. + +It is important to note that \textsc{dvi} viewers will not display +diagrams correctly. It is necessary to convert the \textsc{dvi} file +to the \textsc{pdf} or \textsc{ps} format---or, even better, use +\texttt{pdflatex} to obtain a \textsc{pdf} file directly. \subsection{Inserting arrows} \label{sec:inserting-arrows} -Inside the |tikzcd| environment, the command |\arrow| is provided to -produce arrows. In its simplest form, it takes one argument, a string -containing the characters |r|, |l|, |u| or |d|, standing for right, left, -up and down, that determine the arrow target. A label can be -placed on an arrow by providing a second argument. +Inside the |{tikzcd}| environment, the following synonymous commands +are provided to produce arrows. + +\begin{pgfmanualentry} + \extractcommand\arrow|[|\meta{options}|]|\@@ + \extractcommand\ar|[|\meta{options}|]|\@@ + \pgfmanualbody +\end{pgfmanualentry} + +Here, \meta{options} is a comma-separated list of options which can be +used to specify the arrow target, add labels, change arrow tips, and +perform additional modifications. + +The arrow target is determined by a direction parameter, which +consists of a string of characters |r|, |l|, |d|, |u| (standing for +right, left, down and up). Labels can be placed on an arrow by means +of the quotes syntax, described in detail in the \pgfname{} manual +\cite[\S\ref*{pgfman-section-label-quotes}]{pgfman}. Notice the use of +|"\phi"| in the example below. + \begin{codeexample}[] \begin{tikzcd} - A \arrow{rd} \arrow{r}{\phi} & B \\ - & C + A \arrow[rd] \arrow[r, "\phi"] & B \\ + & C \end{tikzcd} \end{codeexample} -You can control the appearance of the arrow by placing an argument -in square braces before the direction parameter. It may contain -any option that can be passed to \tikzname{}'s -|\path| command. Similarly, a label can be modified by an argument in -square braces right before it. It may contain anything that can be -passed to \tikzname's |node| operator. +To further modify the appearance of an arrow, note that \meta{options} +may contain any key that can be passed to \tikzname's |\path| command. +Similarly, a label can receive additional options via the syntax +\begin{quote} + |"|\meta{label text}|"|\opt{\meta{label options}}. +\end{quote} +Both \meta{label text} and \meta{label options} need to be enclosed in +curly braces if they contain commas. + \begin{codeexample}[] \begin{tikzcd} - A \arrow{r}{\psi} \arrow[color=red]{d} - & B \arrow{d}[color=red]{\psi} \\ - C \arrow[color=red]{r}[color=blue]{\eta} + A \arrow[r, "\phi"] \arrow[d, red] + & B \arrow[d, "\psi" red] \\ + C \arrow[r, red, "\eta" blue] & D \end{tikzcd} \end{codeexample} -Arrows can actually have an arbitrary number of labels, each one -specified by juxtaposing |{|\meta{text}|}| or -|[|\meta{options}|]{|\meta{text}|}| to the |\arrow| command. +Arrows can have an arbitrary number of labels, by repeated use of +arguments in quotes. The example below shows how to control the +positioning of labels. Notice in particular that an apostrophe as +\meta{label option} causes the label to be placed on the opposite side +of the arrow. \begin{codeexample}[] \begin{tikzcd} - A \arrow{r}[near start]{\phi}[swap]{\psi}[near end]{\eta} & B + A \arrow[r, "\phi" near start, "\psi"', "\eta" near end] & B \end{tikzcd} \end{codeexample} -% If using \tikzname's \texttt{quotes} library, the above could be rewritten as follows: - -% \usetikzlibrary{quotes} -% \begin{codeexample}[] -% \begin{tikzcd} -% A \arrow["\phi" near start, "\psi"', "\eta" near end]{r} & B -% \end{tikzcd} -% \end{codeexample} - -To save typing, the command |\ar| is provided as a shorthand to -|\arrow|. There are also commands |\rar|, |\lar|, |\uar|, |\dar|, -|\urar|, |\ular|, |\drar| and |\dlar| that act like |\arrow{r}|, -|\arrow{l}|, \dots, |\arrow{dl}|. They can take an optional -argument in square braces to modify the arrow, followed by label -specifiers of the form |{|\meta{text}|}| or -|[|\meta{options}|]{|\meta{text}|}|. -\begin{codeexample}[] -\begin{tikzcd} - A \rar{\psi} \dar[color=red] - & B \dar[][color=red]{\psi} \\ - C \rar[color=red][color=blue]{\eta} \urar[dashed] - & D -\end{tikzcd} -\end{codeexample} - -We provide one more example, reproduced from X\raisebox{-0.3ex}{Y}-pic -user's guide. +We provide one more example, reproduced from the +X\raisebox{-0.3ex}{Y}-pic user's guide. \begin{codeexample}[] \begin{tikzcd} T - \arrow[bend left]{drr}{x} - \arrow[bend right]{ddr}{y} - \arrow[dotted]{dr}[description]{(x,y)} & & \\ - & X \times_Z Y \arrow{r}{p} \arrow{d}{q} - & X \arrow{d}{f} \\ - & Y \arrow{r}{g} + \arrow[drr, bend left, "x"] + \arrow[ddr, bend right, "y"] + \arrow[dr, dotted, "{(x,y)}" description] & & \\ + & X \times_Z Y \arrow[r, "p"] \arrow[d, "q"] + & X \arrow[d, "f"] \\ + & Y \arrow[r, "g"] & Z \end{tikzcd} \end{codeexample} @@ -1474,130 +341,294 @@ user's guide. \subsection{Changing arrow tips} \label{sec:changing-arrow-tips} -For some \LaTeX\ arrow-producing commands, there is a -corresponding option (without a ``|\|'') that can be passed to -|\arrow| to produce that kind of arrow. Notice the use of -|hookrightarrow| and |dashrightarrow| in the example below. +A set of |\arrow| options is provided to create different kinds of +arrows. Some of these options have a short descriptive name, such as +|hook|, and others are named after \TeX{} arrow-producing commands +(without a ``|\|''), like |dashrightarrow|.%| \begin{codeexample}[] \begin{tikzcd} - X \arrow[hookrightarrow]{r} \arrow[dashrightarrow]{rd} - & \bar{X} \arrow{d}\\ + X \arrow[r, hook] \arrow[dr, dashrightarrow] + & \bar{X} \arrow[d]\\ & Y \end{tikzcd} \end{codeexample} -The following list shows all available arrows. +The following list shows all available arrow types (each of them is a +style key located in |/tikz/commutative diagrams|). + +\begin{multicols}{2}\raggedcolumns + \subsubsection*{Basic arrows} + \begin{tabular}{ll} + \displayarrowstyle{to head}\\ + \displayarrowstyle{rightarrow}\\ + \displayarrowstyle{leftarrow}\\ + \displayarrowstyle{leftrightarrow}\\ + \displayarrowstyle{Rightarrow}\\ + \displayarrowstyle{Leftarrow}\\ + \displayarrowstyle{Leftrightarrow} + \end{tabular} + + \subsubsection*{Arrows from bar} + \begin{tabular}{ll} + \displayarrowstyle{maps to}\\ + \displayarrowstyle{mapsto}\\ + \displayarrowstyle{mapsfrom}\\ + \end{tabular} + + \subsubsection*{Arrows with hook} + \begin{tabular}{ll} + \displayarrowstyle{hook}\\ + \displayarrowstyle{hook'}\\ + \displayarrowstyle{hookrightarrow}\\ + \displayarrowstyle{hookleftarrow}\\ + \end{tabular} + + \subsubsection*{Arrows with tail} + \begin{tabular}{ll} + \displayarrowstyle{tail}\\ + \displayarrowstyle{rightarrowtail}\\ + \displayarrowstyle{leftarrowtail}\\ + \end{tabular} + + \subsubsection*{Two-headed arrows} + \begin{tabular}{ll} + \displayarrowstyle{two heads}\\ + \displayarrowstyle{twoheadrightarrow}\\ + \displayarrowstyle{twoheadleftarrow}\\ + \end{tabular} + + \subsubsection*{Harpoons} + \begin{tabular}{ll} + \displayarrowstyle{harpoon}\\ + \displayarrowstyle{harpoon'}\\ + \displayarrowstyle{rightharpoonup}\\ + \displayarrowstyle{rightharpoondown}\\ + \displayarrowstyle{leftharpoonup}\\ + \displayarrowstyle{leftharpoondown}\\ + \end{tabular} + + \subsubsection*{Dashed arrows} + \begin{tabular}{ll} + \displayarrowstyle{dashed}\\ + \displayarrowstyle{dashrightarrow}\\ + \displayarrowstyle{dashleftarrow}\\ + \end{tabular} + + \subsubsection*{Squiggly arrows} + \begin{tabular}{ll} + \displayarrowstyle{squiggly}\\ + \displayarrowstyle{rightsquigarrow}\\ + \displayarrowstyle{leftsquigarrow}\\ + \displayarrowstyle{leftrightsquigarrow} + \end{tabular} + + \subsubsection*{Non-arrows} + \begin{tabular}{ll} + \displayarrowstyle{no head}\\ + \displayarrowstyle{no tail}\\ + \displayarrowstyle{dash}\\ + \displayarrowstyle{equal}\\ + \end{tabular} +\end{multicols} + +A gray cross +(\begin{tikzpicture}[baseline=0pt, yshift=axis_height] + \pgfsetdash{}{0pt} \pgfsetlinewidth{0.8\pgflinewidth} + \pgfsetstrokecolor{gray} + \pgfpathmoveto{\pgfpoint{5\pgflinewidth}{5\pgflinewidth}} + \pgfpathlineto{\pgfpoint{-5\pgflinewidth}{-5\pgflinewidth}} + \pgfusepathqstroke + \pgfpathmoveto{\pgfpoint{-5\pgflinewidth}{5\pgflinewidth}} + \pgfpathlineto{\pgfpoint{5\pgflinewidth}{-5\pgflinewidth}} + \pgfusepathqstroke +\end{tikzpicture}) in the samples above indicates that the corresponding tip +is kept unchanged. This allows several arrow styles to be superimposed. -{\tikzset{commutative diagrams/.cd, background color=white} - \begin{quote} - \begin{tabular}{ll} - \displayarrowstyle{rightarrow}\\ - \displayarrowstyle{leftarrow}\\ - \displayarrowstyle{leftrightarrow}\\ - \displayarrowstyle{dash}\\ - \displayarrowstyle{Rightarrow}\\ - \displayarrowstyle{Leftarrow}\\ - \displayarrowstyle{Leftrightarrow}\\ - \displayarrowstyle{equal}\\ - \displayarrowstyle[(or \texttt{maps to})]{mapsto}\\ - \displayarrowstyle{mapsfrom}\\ - \displayarrowstyle[(or \texttt{hook})]{hookrightarrow}\\ - \displayarrowstyle{hookleftarrow}\\ - \displayarrowstyle{rightharpoonup}\\ - \displayarrowstyle{rightharpoondown}\\ - \displayarrowstyle{leftharpoonup}\\ - \displayarrowstyle{leftharpoondown}\\ - \displayarrowstyle[(or \texttt{dashed})]{dashrightarrow}\\ - \displayarrowstyle{dashleftarrow}\\ - \displayarrowstyle[(or \texttt{tail})]{rightarrowtail}\\ - \displayarrowstyle{leftarrowtail}\\ - \displayarrowstyle[(or \texttt{two heads})]{twoheadrightarrow}\\ - \displayarrowstyle{twoheadleftarrow}\\ - \displayarrowstyle[(or \texttt{squiggly})]{rightsquigarrow}\\ - \displayarrowstyle{leftsquigarrow}\\ - \displayarrowstyle{leftrightsquigarrow} - \end{tabular} - \end{quote} -} +\begin{codeexample}[] +\begin{tikzcd} + A \arrow[r, tail, two heads, dashed] & B +\end{tikzcd} +\end{codeexample} + +% It is also possible to select arrow tips using \tikzname{}'s |arrow| +% option directly (e.g., by saying |right hook->|). However, the method +% described here above is more appropriate, as it abstracts the choice +% of an actual arrow tip design (see also the |arrow style| key below), +% and is arguably better from the mnemonic standpoint. -Some of the arrows above have an alternate name shown in parenthesis. -These forms behave a little differently from the original ones, in -that they can be superimposed with other arrows. + +\subsection{Alternative syntax for arrows} +\label{sec:altern-synt-arrows} + +The following forms of the arrow command were used before the +appearance of the quotes syntax for labels, and now may seem somewhat +convoluted. They are nonetheless still available for backwards +compatibility. + +\begin{command}{\arrow\opt{\oarg{options}}\marg{direction}\meta{labels}} +\end{command} + +Here, \meta{direction} is a string containing the characters |r|, |l|, +|d|, |u| determining the arrow target, and \meta{labels} can be the +empty string or of the form +\begin{quote} + \opt{\oarg{label options}}\marg{label text}\meta{more labels}. +\end{quote} +The equivalent command |\ar| can also be used in this form. Here is +an example. \begin{codeexample}[] \begin{tikzcd} - A \arrow[tail, two heads, dashed]{r} & B + A \arrow{d} \arrow{r}[near start]{\phi}[near end]{\psi} + & B \arrow[red]{d}{\xi} \\ + C \arrow[red]{r}[blue]{\eta} + & D \end{tikzcd} \end{codeexample} -It is also possible to select arrow tips using \tikzname{}'s |arrow| -option directly (e.g., by saying |right hook->|). However, the method -described here above is more appropriate, as it abstracts the choice -of an actual arrow tip design (see also the key \texttt{commutative - diagrams/arrow style} below), and is arguably better from the -mnemonic standpoint. +There are further shortened forms: +\begin{pgfmanualentry} + \extractcommand\rar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\lar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\dar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\uar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\drar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\urar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\dlar\opt{\oarg{options}}\meta{labels}\@@ + \extractcommand\ular\opt{\oarg{options}}\meta{labels}\@@ + \pgfmanualbody +\end{pgfmanualentry} +The first one is equivalent to +\begin{quote} + |\arrow|{\oarg{options}}|{r}|\meta{labels} +\end{quote} +and the other ones work analogously. -\section{Controlling the appearance of diagrams} -\label{sec:chang-appe-diagr} +\subsection{Usage in plain \TeX{}} +\label{sec:usage-plain-tex} -This section lists all customization keys defined by this package. -Options can be made take effect in different scopes: -\begin{enumerate} -\item Globally, using the command |\tikzset|. This can be done in the - document preamble, or in the body, to affect all diagrams - appearing thereafter. -\item For a particular diagram, by placing options in the optional - argument to the |tikzcd| environment. Such options are applied to - the |tikzpicture| environment generated by |tikzcd| (cf.\ - \S\ref{sec:intern-arrow-comm}). -\item For a particular arrow or label, by placing options in one of - the optional arguments of |\arrow|. -\end{enumerate} -Of course, not all options make sense in all contexts. - -All keys provided by this package are located in the path -|/tikz/commutative diagrams|. Methods 2 and 3 above will search in -this path by default; if a key is not found there, an attempt is made -to find it in |/tikz|. When using method 1, it is convenient to -change the default search path by using +To use this software in plain \TeX{}, load \tikzname{} and the +\texttt{cd} library by saying \begin{quote} - |\tikzset{commutative diagrams/.cd, |\meta{options}|}|. + \ttfamily\char`\\input \declare{tikz}.tex\\ + \index{cd@\protect\texttt{cd} library}% + \index{Libraries!cd@\protect\texttt{cd}}% + \ttfamily\char`\\usetikzlibrary\char`\{\declare{cd}\char`\} \end{quote} +The |{tikzcd}| environment should then be replaced by the following: +\begin{plainenvironment}{{tikzcd}\opt{\oarg{options}}} +\end{plainenvironment} +All other functions of this library work as described in this manual +without change. + +\subsection{Usage in Con\TeX t} +\label{sec:usage-plain-context} + +To use this software in Con\TeX t, load \tikzname{} and then the +\texttt{cd} library by saying +\begin{quote} + \ttfamily\char`\\usemodule[\declare{tikz}]\\ + \index{cd@\protect\texttt{cd} library}% + \index{Libraries!cd@\protect\texttt{cd}}% + \ttfamily\char`\\usetikzlibrary[\declare{cd}] +\end{quote} +The |{tikzcd}| environment should then be replaced by the following: +\begin{contextenvironment}{{tikzcd}\opt{\oarg{options}}} +\end{contextenvironment} +All other functions of this library work as described in this manual +without change. + +\section{Controlling the appearance of diagrams} +\label{sec:chang-appe-diagr} + +This section describes a number of customization keys defined by this +package. All keys are located in the path |/tikz/commutative diagrams|. +Options passed to |{tikzcd}| or |\arrow| are searched for +in that path, and, if not found there, in |/tikz|. To set options +globally, it is convenient to use the following command. + +\begin{command}{\tikzcdset\marg{options}} + Executes \meta{options} in the path |/tikz/commutative diagrams|. +\end{command} Besides the keys described in this manual, numerous \tikzname\ parameters can affect the appearance of a diagram. However, only a -few of them (namely those appearing in \texttt{every diagram}, -\texttt{every arrow} and \texttt{every label} below) are reinitialized -when |tikzcd| is called. This means that modifying a certain -\tikzname\ parameter globally may or may not affect the output of -|tikzcd|. +few of them (namely those appearing in |every diagram|, |every cell|, +|every arrow|, and |every label| below) are reinitialized when +|{tikzcd}| is called. This means that modifying a certain \tikzname\ +parameter globally may or may not affect the output of |{tikzcd}|. + +We also point out that besides the options and styles provided by this +package, several keys defined by \tikzname{} are useful for arrows. +Some examples are \texttt{dashed}, |dotted|, and its relatives, +|line width=|\meta{dimension}, |color=|\meta{color}, |bend right|, |bend left|, +|in=|\meta{angle}, |out=|\meta{angle}, |loop|, etc. See the +\pgfname{} manual~\cite[\S\ref*{pgfman-section-cap-joins} and +\S\ref*{pgfman-library-to-paths}]{pgfman}. Likewise, \tikzname{} +provides several keys that are useful for labels, such as |above|, +|below|, |left|, |right|, |swap| (which makes the label be placed on +the right side of the arrow, relative to its direction), |sloped|, +|pos=|\meta{fraction}, |near start|, |near end|, |inner sep=|\meta{dimension}, +|font=|\meta{font command}, |text width=|\meta{dimension}, etc. See the \pgfname{} +manual~\cite[\S\ref*{pgfman-section-nodes}, esp.\ +\S\ref*{pgfman-section-pos-option}]{pgfman}. + + + \subsection{General options} \label{sec:general-options} \begin{stylekey}{/tikz/commutative diagrams/every diagram} - This style is applied to every |tikzcd| environment. Initially, it + This style is applied to every |{tikzcd}| environment. Initially, it contains the following: -\begin{quote}\ttfamily{} -/tikz/commutative diagrams/.cd,\\ -|/tikz/cells={nodes={shape={asymmetrical rectangle}}}|,\\ -/tikz/baseline=0pt,\\ -row sep=normal,\\ -column sep=normal +\begin{quote} +|row sep=normal||,|\\ +|column sep=normal||,|\\ +|/tikz/baseline=0pt| \end{quote} \end{stylekey} The |baseline=0pt| setting is used to make equation numbers be placed -correctly. The \texttt{asymmetrical rectangle} shape, used in the -matrix nodes, is described in \S\ref{sec:asymm-rect-shape}. +correctly (as an exception, one-row diagrams are anchored at their +matrix base, which is exactly what you want). \begin{key}{/tikz/commutative diagrams/diagrams=\meta{options}} - This key appends \meta{options} to the style - |/tikz/commutative diagrams/every diagram|. + This key appends \meta{options} to the style |every diagram|. +\end{key} + +\begin{stylekey}{/tikz/commutative diagrams/every matrix} + This style is applied to the \tikzname{} matrix created internally + by |{tikzcd}|. Initially, it contains the following: +\begin{quote} +|/tikz/inner sep=0pt| +\end{quote} +\end{stylekey} + +\begin{stylekey}{/tikz/commutative diagrams/every cell} + This style is applied to every \tikzname{} matrix cell created by + |{tikzcd}|. Initially, it contains the following: +\begin{quote} +|/tikz/shape=asymmetrical rectangle||,|\\ +|/tikz/inner xsep=1ex||,|\\ +|/tikz/inner ysep=0.85ex| +\end{quote} +\end{stylekey} + +The |asymmetrical rectangle| shape is described in +\S\ref{sec:asymm-rect-shape}. The |inner xsep|, |inner ysep| options +determine the spacing between a diagram entry and any arrows reaching +it. + +\begin{key}{/tikz/commutative diagrams/cells=\meta{options}} + This key appends \meta{options} to the style |every cell|. \end{key} -\begin{key}{/tikz/commutative diagrams/row sep=\meta{size} (initially normal)} +\def\printsepaux+#1em{#1\,em} +\def\printsep#1#2{\edef\temp{\pgfkeysvalueof{/tikz/commutative diagrams/#1 sep/#2}}\expandafter\printsepaux\temp} + +\begin{key}{/tikz/commutative diagrams/row sep=\meta{size}} This key acts as a ``frontend'' to \tikzname's |/tikz/row sep| key. If the key \begin{quote} @@ -1608,37 +639,37 @@ stores a set. If the key above is not initialized, then \meta{size} is presumably a dimension, and |/tikz/row sep|=\meta{size} is set. - The initially available \meta{size}'s, and their values, are + The initially available sizes, and their values, are the following: \begin{center} \begin{tabular}{cccccc} |tiny| & |small| & |scriptsize| & |normal| & |large| & |huge| \\ - 1.25\,ex & 2.5\,ex & 3.75\,ex & 5\,ex & 7.5\,ex & 10\,ex + \printsep{row}{tiny} & \printsep{row}{small} & \printsep{row}{scriptsize} & \printsep{row}{normal} & \printsep{row}{large} & \printsep{row}{huge} \end{tabular} \end{center} \end{key} -Notice that setting, say, |row sep=1cm| globally with |\tikzset| will +Notice that setting, say, |row sep=1cm| globally with |\tikzcdset| will have no effect, since the |row sep| option is re-set at the beginning of each diagram. To make all diagrams have |row sep| equal to 1\,cm, you can modify the meaning of |normal| by saying \begin{quote} -|\tikzset{commutative diagrams/row sep/normal=1cm}|. +|\tikzcdset{row sep/normal=1cm}|. \end{quote} -You can also create new sizes, but \pgfname\ requires new keys to be +You can also create new sizes, but note that \pgfname\ requires new keys to be initialized explicitly. For example, to create a size |my size|, meaning 1\,ex, you should use \begin{quote} -|\tikzset{commutative diagrams/row sep/my size/.initial=1ex}|. +|\tikzcdset{row sep/my size/.initial=1ex}|. \end{quote} -\begin{key}{/tikz/commutative diagrams/column sep=\meta{size} (initially normal)} +\begin{key}{/tikz/commutative diagrams/column sep=\meta{size}} This works analogously to the |row sep| key above. The sizes available initially are the following: \begin{center} \begin{tabular}{cccccc} |tiny| & |small| & |scriptsize| & |normal| & |large| & |huge| \\ - 1.5\,ex & 3\,ex & 4.5\,ex & 6\,ex & 9\,ex & 12\,ex + \printsep{column}{tiny} & \printsep{column}{small} & \printsep{column}{scriptsize} & \printsep{column}{normal} & \printsep{column}{large} & \printsep{column}{huge} \end{tabular} \end{center} \end{key} @@ -1648,16 +679,16 @@ too tall if the column or row separation were not set appropriately. \begin{codeexample}[] \begin{tikzcd}[column sep=small] - & A \arrow{dl}\arrow{dr} & \\ - B \arrow{rr} & & C + & A \arrow[dl] \arrow[dr] & \\ + B \arrow{rr} & & C \end{tikzcd} \end{codeexample} \begin{codeexample}[] \begin{tikzcd}[row sep=tiny] - & B \arrow{dd} \\ - A \arrow{ur}\arrow{dr} & \\ - & C + & B \arrow[dd] \\ + A \arrow[ur] \arrow[dr] & \\ + & C \end{tikzcd} \end{codeexample} @@ -1665,11 +696,11 @@ Section \ref*{pgfman-section-matrices}.3.2 of the \pgfname{} manual \cite{pgfman} contains further details on the spacing of matrix cells. \begin{key}{/tikz/commutative diagrams/math mode=\meta{boolean} - (initially true)} - This keys determines whether the contents of a diagram are typeset in - math mode or not. If set globally or diagram-wise, it affects both - the diagram entries and arrow labels. If used with |\arrow|, it affects - only its labels. + (default true)} + This keys determines whether or not the contents of a diagram are + typeset in math mode. If set globally or diagram-wise, it affects + both the diagram entries and arrow labels. If used with |\arrow|, + it affects only its labels. \end{key} \begin{key}{/tikz/commutative diagrams/background color=\meta{color} (initially white)} @@ -1678,120 +709,218 @@ Section \ref*{pgfman-section-matrices}.3.2 of the \pgfname{} manual It does not cause the background of diagrams to be filled. \end{key} -\subsection{Options for arrows} +\subsection{Global options for arrows} \label{sec:options-arrows} -Besides the options and styles provided by this package, several keys -defined by \tikzname{} are useful for arrows, such as |dashed|, -|dotted|, and its relatives, |line width=|\meta{dimension}, -|color=|\meta{color}, |bend right|, |bend left|, |in=|\meta{angle}, -|out=|\meta{angle}, |loop|, etc. See the \pgfname{} -manual~\cite[\S\ref*{pgfman-section-cap-joins} and -\S\ref*{pgfman-library-to-paths}]{pgfman}. - \begin{stylekey}{/tikz/commutative diagrams/every arrow} This style is applied to every |\arrow|. Initially, it contains the following: -\begin{quote}\ttfamily{} -/tikz/commutative diagrams/.cd,\\ -/tikz/draw,\\ -default arrow +\begin{quote} +|/tikz/draw,|\\ +|/tikz/line width=rule_thickness||,|\\ +|rightarrow| \end{quote} \end{stylekey} -The |default arrow| style is similar to |rightarrow|, but may perform -some additional tasks, such as setting the line width. - \begin{key}{/tikz/commutative diagrams/arrows=\meta{options}} - This key appends \meta{options} to the style - |/tikz/commutative diagrams/every arrow|. + This key appends \meta{options} to the style |every arrow|. \end{key} -\begin{key}{/tikz/commutative diagrams/arrow style=\meta{style} (initially computer - modern)} - Setting this key causes the several arrow-tip-specifying styles - listed in \S\ref{sec:changing-arrow-tips} to be redefined. In - particular, it makes the style \texttt{/tikz/commutative - diagrams/default arrow}, which is automatically applied to every - arrow, to be redefined. Currently, \meta{style} can be one of - the following: +\begin{key}{/tikz/commutative diagrams/arrow style=\meta{style} (initially Computer Modern)} + This key determines which collection of arrow tips is used by the + arrow tip selection styles listed in + \S\ref{sec:changing-arrow-tips}. Currently, \meta{style} can be one + of the following: \begin{description} - \item[|computer modern|] This is the initial setting and is suitable - for documents using Computer Modern or Latin Modern fonts. - \item[|tikz|] This style uses the arrow tips defined in \tikzname's - |arrows| library (which has to be loaded before setting this - option). It honors the option |/tikz/>|, and it keeps the - parameter \texttt{/tikz/line width} untouched. + \item[\texttt{Computer Modern}] This is the initial setting and is suitable + for documents using the Computer Modern font. + \item[\texttt{Latin Modern}] A small variant of the above, intended + for documents using the Latin Modern font. + \item[\texttt{math font}] This setting uses the |Glyph| meta arrow + tip described in \S\ref{sec:font-arrow-tips}. + \item[\texttt{arrows.meta}] This setting uses the arrow tips defined + in \tikzname's |arrows.meta| library (which has to be loaded + manually before setting this option). It honors the option + |/tikz/>|. + \item[\texttt{tikz}] This setting uses the arrow tips defined in + \tikzname's older \texttt{arrows} library (which has to be loaded + manually before setting this option). It honors the option + |/tikz/>|. Unless you have backwards compatibility requirements, + you should use the \texttt{arrows.meta} option and library + instead. \end{description} \end{key} -If you are using a font different from Computer Modern, you may find -better results by selecting the |tikz| arrow style, setting |/tikz/>| -to the value that best matches your font (among those shown in -\cite[\S\ref*{pgfman-section-library-arrows}]{pgfman}), and adjusting |/tikz/line width| if necessary. -The following example, if not particularly elegant, should be -instructive. +If you are using a font different from Computer Modern or Latin +Modern, you may find the best results by selecting the |math font| +style. As detailed in \S\ref{sec:font-arrow-tips}, this is not +guaranteed to work perfectly with all fonts, but gives good results in +many cases. If the \texttt{math font} style gives unsatisfactory +results, you can try selecting the \texttt{arrows.meta} style, and +setting |/tikz/>| to the value that best matches your font (among +those shown in \cite[\S\ref*{pgfman-section-arrows-meta}]{pgfman}). \begin{codeexample}[] -\usetikzlibrary{arrows} +\usetikzlibrary{arrows.meta} -\tikzset{ - commutative diagrams/.cd, - arrow style=tikz, - diagrams={>=open triangle 45, line width=tikzcdrule}} +\tikzcdset{ + arrow style=arrows.meta, + diagrams={>={Straight Barb[scale=0.8]}} +} \begin{tikzcd} - A \arrow{r} \arrow{d} & B \arrow{d}\\ - C \arrow{r} & D + A \arrow[r, tail] \arrow[rd] & B \arrow[d, two heads]\\ + & D \end{tikzcd} \end{codeexample} -The following set of options allow fine-tuning the placement of -arrows. +\subsection{Absolute placement of arrows} +\label{sec:absol-positioning} -\begin{key}{/tikz/commutative diagrams/shift={\ttfamily\char`\{}\meta{coordinate}{\ttfamily\char`\}}} - Shifts arrows by \meta{coordinate}. +The usual behavior of |\arrow| is to produce an arrow starting at the +diagram entry where the command appears, and ending at an entry whose +location is specified relative to that. The following keys override +this behavior, allowing source and target to be selected explicitly. + +\begin{key}{/tikz/commutative diagrams/from=\meta{node}} + Sets the arrow source to \meta{node}. When called with an argument + of the form \meta{row number}\texttt{-}\meta{column number}, sets + the arrow source to be the corresponding entry of the diagram's + matrix. \end{key} -\begin{key}{/tikz/commutative diagrams/xshift=\meta{dimension}} - Shifts arrows right by \meta{dimension}. +\begin{key}{/tikz/commutative diagrams/to=\meta{node}} + Similar to |from|, but refers to the arrow target. \end{key} -\begin{key}{/tikz/commutative diagrams/yshift=\meta{dimension}} - Shifts arrows up by \meta{dimension}. +Recall that it is possible to give a specific entry of a \tikzname{} +matrix a name by using the \verb!|[!\meta{options}\verb!]|! syntax, as +done for entry $C$ in the example below. + +{\catcode`\|=12 +\begin{codeexample}[] +\begin{tikzcd} + A \arrow[to=c, red] \arrow[to=2-2, blue] + & B \\ + |[alias=c]| C + & D + \arrow[from=1-1, to=1-2, purple] +\end{tikzcd} +\end{codeexample} +} + +In the next examples, empty labels are used to create nodes for later +reference. The |draw=red| option is used to show where these empty +nodes are located, but of course you want to remove that when using +this technique. + +\begin{codeexample}[] +\begin{tikzcd}[column sep=scriptsize] + A \arrow[dr] \arrow[rr, ""{name=U, below, draw=red}]{} + & & B \arrow[dl] \\ + & C \arrow[Rightarrow, from=U, "\psi"] +\end{tikzcd} +\end{codeexample} + +\begin{codeexample}[] +\begin{tikzcd} + A \arrow[r, bend left=50, ""{name=U, below, draw=red}] + \arrow[r, bend right=50, ""{name=D, draw=red}] + & B + \arrow[Rightarrow, from=U, to=D] +\end{tikzcd} +\end{codeexample} + +\subsection{Phantom arrows} +\label{sec:phantom-arrows} + +Sometimes it is necessary to insert a symbol outside the grid +subjacent to the diagram. The easiest way to achieve this is as a +label to an invisible arrow. + +\begin{stylekey}{/tikz/commutative diagrams/phantom} + Creates an invisible arrow. Labels to this arrow are not invisible. + They will be anchored at their center and typeset in full size + (i.e., with |\textstyle|). To get smaller labels, as in ordinary + arrows, use the |\scriptstyle| command. +\end{stylekey} + +In the picture below, the arrow containing the |phantom| option goes from +$A$ to $D$, and the |\ulcorner| symbol ($\ulcorner$) is inserted +closer to the starting point $A$. +\begin{codeexample}[] +\begin{tikzcd} + A \arrow[r] \arrow[d] \arrow[dr, phantom, "\ulcorner", very near start] + & B \arrow[d] \\ + C \arrow[r] + & D +\end{tikzcd} +\end{codeexample} + +\subsection{Fine-tuning the placement of arrows} +\label{sec:fine-tuning-arrows} + +\begin{key}{/tikz/commutative diagrams/shift left=\meta{dimension} + (default 0.56ex)} + Shifts arrows by \meta{dimension} to the left, relative to the arrow + direction. A dimensionless argument causes that multiple of the + default value to be used. +\end{key} + +\begin{key}{/tikz/commutative diagrams/shift right=\meta{dimension} + (default 1)} + A shortcut to |shift left=-|\meta{dimension}. \end{key} \begin{codeexample}[] - \begin{tikzcd} - A \arrow[yshift=0.7ex]{r} \arrow[yshift=-0.7ex]{r} - & B \arrow[xshift=0.7ex]{d} \arrow[xshift=-0.7ex]{d} \\ - & C - \end{tikzcd} +\begin{tikzcd} + A \arrow[r, red, shift left=1.5ex] \arrow[r] + \arrow[dr, blue, shift right=1.5ex] \arrow[dr] + & B \arrow[d, purple, shift left=1.5ex] \arrow[d]\\ + & C +\end{tikzcd} \end{codeexample} -\begin{key}{/tikz/commutative diagrams/shift left=\meta{dimension}} - Shifts arrows by \meta{dimension} in the direction making a $90^\circ$ - angle with the arrow. +The default values of |shift left| and |shift right| are appropriate +for a pair of parallel arrows, and dimensionless arguments are useful +to create sets of multiple parallel arrows. +\begin{codeexample}[] +\begin{tikzcd} + A \arrow[r] + & B \arrow[r, shift left] + \arrow[r, shift right] + & C \arrow[r] + \arrow[r, shift left=2] + \arrow[r, shift right=2] + & \cdots +\end{tikzcd} +\end{codeexample} + +\begin{key}{/tikz/commutative diagrams/shift=\marg{coordinate}} + Shifts arrows by \meta{coordinate}. \end{key} -\begin{key}{/tikz/commutative diagrams/shift right=\meta{dimension}} - Shifts arrows by \meta{dimension} in the direction making a $-90^\circ$ - angle with the arrow. +\begin{key}{/tikz/commutative diagrams/xshift=\meta{dimension}} + Shifts arrows right by \meta{dimension}. +\end{key} + +\begin{key}{/tikz/commutative diagrams/yshift=\meta{dimension}} + Shifts arrows up by \meta{dimension}. \end{key} \begin{codeexample}[] - \begin{tikzcd} - A \arrow[red, shift left=1.5ex]{r} \arrow{r} - \arrow[blue, shift right=1.5ex]{dr} \arrow{dr} - & B \arrow[purple, shift left=1.5ex]{d} \arrow{d}\\ - & C - \end{tikzcd} +\begin{tikzcd} + A \arrow[r, yshift=0.7ex] \arrow[r, yshift=-0.7ex] + & B \arrow[d, xshift=0.7ex] \arrow[d, xshift=-0.7ex] \\ + & C +\end{tikzcd} \end{codeexample} \begin{key}{/tikz/commutative diagrams/start anchor=\opt{{\ttfamily\char`\{}\ooarg{coordinate transformations}}\meta{anchor}\opt{\ttfamily\char`\}}} - This key specifies at which anchor of the current node the arrow + This key specifies at which anchor of the source node the arrow should start. Optionally, additional coordinate transformations can - be supplied. An empty argument causes no anchor to be specified. + be supplied. An empty \meta{anchor} argument causes no anchor to be + specified, which is the usual behavior. \end{key} \begin{key}{/tikz/commutative diagrams/end anchor=\opt{{\ttfamily\char`\{}\ooarg{coordinate transformations}}\meta{anchor}\opt{\ttfamily\char`\}}} @@ -1802,24 +931,27 @@ See the picture on \S\ref{sec:asymm-rect-shape} for some of the possible values for \meta{anchor}. \begin{codeexample}[] \begin{tikzcd}[cells={nodes={draw=gray}}] - A \arrow[black]{r} - \arrow[blue, end anchor=north east]{r} - \arrow[red, + A \arrow[r, black] + \arrow[r, blue, end anchor=north east] + \arrow[r, + red, start anchor={[xshift=-1ex]}, - end anchor={[yshift=2ex]north east}]{r} + end anchor={[yshift=2ex]north east}] & B \end{tikzcd} \end{codeexample} +\subsection{Three-dimensional diagrams} +\label{sec:crossing-over} + \begin{stylekey}{/tikz/commutative diagrams/crossing over} - This style makes a thicker line, with color - |/tikz/commutative diagrams/background color|, to be drawn under the - current arrow, simulating the effect of its passing over other - arrows. + This style makes a thicker line, with color |background color|, to + be drawn under the current arrow, simulating the effect of its + passing over other arrows. \begin{codeexample}[] \begin{tikzcd} - A \arrow{dr} & B \arrow[crossing over]{dl} \\ + A \arrow[dr] & B \arrow[dl, crossing over] \\ C & D \end{tikzcd} \end{codeexample} @@ -1830,19 +962,18 @@ arrows may need to run ``backwards'' to achieve the desired result. %The option \texttt{on background layer} %\cite[\S\ref*{pgfman-section-tikz-backgrounds}]{pgfman} may also %be useful in this context. -The following picture, adapted from -\cite{lenders}, illustrates the use of \texttt{crossing over}. +The following picture illustrates this. \begin{codeexample}[] \begin{tikzcd}[row sep=scriptsize, column sep=scriptsize] - & f^* E_V \arrow{dl}\arrow{rr}\arrow{dd} & & E_V \arrow{dl}\arrow{dd} \\ - f^* E \arrow[crossing over]{rr}\arrow{dd} & & E \\ - & U \arrow{dl}\arrow{rr} & & V \arrow{dl} \\ - M \arrow{rr} & & N\arrow[crossing over, leftarrow]{uu}\\ + & f^* E_V \arrow[dl] \arrow[rr] \arrow[dd] & & E_V \arrow[dl] \arrow[dd] \\ + f^* E \arrow[rr, crossing over] \arrow[dd] & & E \\ + & U \arrow[dl] \arrow[rr] & & V \arrow[dl] \\ + M \arrow[rr] & & N \arrow[uu, crossing over, leftarrow]\\ \end{tikzcd} \end{codeexample} -\begin{key}{/tikz/commutative diagram/crossing over clearance=\meta{dimension} +\begin{key}{/tikz/commutative diagrams/crossing over clearance=\meta{dimension} (initially 1.5ex)} This key specifies the width of the background-colored line drawn under a |crossing over| arrow. @@ -1851,37 +982,25 @@ The following picture, adapted from \subsection{Options for labels} \label{sec:options-labels} -Besides the options provided by this package and listed below, there -are many options provided by \tikzname{} that are useful for -labels, such as |above|, |below|, |left|, -|right|, |swap| (which makes the label be placed in the opposite side -to the default), |sloped|, |pos=|\meta{fraction}, |near start|, -|near end|, |inner sep=|\meta{dimension}, |font=|\meta{font - command}, |text width=|\meta{dimension}, etc. See the \pgfname{} -manual~\cite[\S\ref*{pgfman-section-nodes}, esp.\ \S\ref*{pgfman-section-pos-option}]{pgfman}. - \begin{stylekey}{/tikz/commutative diagrams/every label} This style is applied to every label produced with |\arrow|. It is initially set to -\begin{quote}\ttfamily{} -/tikz/commutative diagrams/.cd,\\ -/tikz/auto,\\ -/tikz/font=\meta{\rmfamily something},\\ -/tikz/inner sep=0.5ex +\begin{quote} +|/tikz/auto,|\\ +|/tikz/font=|\meta{something}|,|\\ +|/tikz/inner sep=0.5ex| \end{quote} where \meta{something} is something that makes |\scriptstyle| be applied to labels in math mode. \end{stylekey} -The key |/tikz/auto| makes the label be placed to the left of the -arrow, considering ``front'' as the direction the arrow points at. -The key |/tikz/inner sep| controls the distance between a label and -the corresponding arrow. +The key |/tikz/auto| makes the label be placed on the left side of the +arrow, relative to its direction. The key |/tikz/inner sep| controls +the distance between a label and the corresponding arrow. \begin{key}{/tikz/commutative diagrams/labels=\meta{options}} - This key appends \meta{options} to the style - \texttt{/tikz/commutative diagrams/every label}. + This key appends \meta{options} to |every label|. \end{key} \begin{stylekey}{/tikz/commutative diagrams/description} @@ -1891,7 +1010,7 @@ the corresponding arrow. \begin{codeexample}[] \begin{tikzcd} - A \arrow{r}[description]{\phi} & B + A \arrow[r, "\phi" description] & B \end{tikzcd} \end{codeexample} \end{stylekey} @@ -1900,71 +1019,51 @@ the corresponding arrow. \label{sec:advanced-usage} This section provides further details on the functioning of this -package, with the aim of showing how a more or less arbitrary -interaction with other \tikzname{} features is possible. +package, with the aim of allowing the advanced user to make a more or +less arbitrary use of other \tikzname{} features within |{tikzcd}|. \subsection{Internals of \texttt{tikzcd} and the arrow commands} \label{sec:intern-arrow-comm} -The |tikzcd| environment works by substituting code of the form +The |{tikzcd}| environment works by substituting code of the form \begin{quote} - |\begin{tikzcd}[|\meta{options}|]| - \meta{contents} + |\begin{tikzcd}[|\meta{options}|]|\\ + \hspace*{1.5ex} \meta{contents}\\ |\end{tikzcd}| \end{quote} with roughly the following: \begin{quote} - |\begin{tikzpicture}[commutative diagrams/every diagram,| - \meta{options}|]|\\ - | \matrix[matrix of |[|math|]| nodes] {|\\ - | |\meta{contents} |\\|\\ - | };|\\ - | |\meta{paths}\\ + |\begin{tikzpicture} [|\meta{options}|]|\\ + \hspace*{1.5ex}| \matrix [matrix of nodes] {|\\ + \hspace*{3ex}| |\meta{contents} |\\|\\ + \hspace*{1.5ex}| };|\\ + \hspace*{1.5ex}| |\meta{paths}\\ |\end{tikzpicture}| \end{quote} Not shown above are a number of initialization procedures, such as -defining |\arrow| and its relatives. Note that the next-row command -|\\| for the last row is inserted by |tikzcd|, and therefore does not -need to be present in \meta{contents}. The |\matrix| is supplied the -option \texttt{matrix of nodes} or \texttt{matrix of math nodes} as -specified by the option \texttt{commutative diagrams/math mode}. -Notice also that you can use the key |execute at end picuture| in -\meta{options} to have arbitrary \tikzname{} code executed after a -diagram is drawn. - -Initially, \meta{paths} is empty. The command -|\arrow[|\meta{path options}|]{|\meta{direction}|}| does nothing at the -point it is inserted, and causes the following code to be appended to -\meta{paths}: +defining |\arrow| and its relatives, as well as applying the default +settings specified by |every diagram| and its relatives. Note that +the next-row command |\\| for the last row is inserted by |{tikzcd}|, +and therefore should not be present in \meta{contents}. Notice also +that you can use the key |execute at end picuture| in \meta{options} +to have arbitrary \tikzname{} code executed after a diagram is drawn. + +Initially, \meta{paths} is the empty string. A command +|\arrow[|\meta{options}|]| does nothing at the point it is inserted, +and causes the following code to be appended to \meta{paths}: \begin{quote} - |\path[commutative diagrams/every arrow, |\meta{path options}|]|\\ - | (| \meta{current node}|) to |\meta{labels}| (|\meta{target~node}|);| + |\path[|\meta{options}|] (|\meta{current node}|) to (|\meta{target~node}|);| \end{quote} - Here, \meta{current node} is the node corresponding to the matrix cell -where the command |\arrow| is present, and \meta{target node} is determined by -\meta{direction} as explained in \S\ref{sec:inserting-arrows}. - -Initially, \meta{labels} is the empty string. A label specifier of -the form |{|\meta{label text}|}| or |[|\meta{label - options}|]{|\meta{label text}|}| immediately following the -\meta{direction} argument or a previous label specifier causes the -string -\begin{quote} - |node [commutative diagrams/every label, |\meta{label options}|] {|[|$|]\meta{label text}[|$|]|}| -\end{quote} -to be appended to \meta{labels}. Dollars signs surround \meta{label - text} depending on the setting \texttt{commutative diagrams/math - mode}. - -The abbreviated forms |\rar|, |\dar|, \dots, have entirely analogous -effect. +where the command |\arrow| is present. A special |.unknown| key +handler is set up to parse direction arguments in \meta{options} and +set \meta{target node} accordingly. \subsection{Tweaking \texttt{to} paths} \label{sec:tweaking-to-paths} -Recall that the |to| path operation used in the paths created by +Recall that the \texttt{to} path operation used in the paths created by |\arrow| can take a number of options, as described in \S\ref*{pgfman-library-to-paths} of the \pgfname{} manual~\cite{pgfman}. In particular, the key |/tikz/to path| determines the path that is actually drawn, and @@ -1972,69 +1071,53 @@ can be used to do all sorts of fiddling. \begin{codeexample}[] \begin{tikzcd} - A \arrow[controls={+(1.5,0.5) and +(-1,0.8)}]{dr} - \arrow[dashed, to path=|- (\tikztotarget)]{dr} + A \arrow[dr, controls={+(1.5,0.5) and +(-1,0.8)}] + \arrow[dr, dashed, to path=|- (\tikztotarget)] & \\ - & B \arrow[loop right]{} + & B \arrow[loop right] \end{tikzcd} -\end{codeexample} +\end{codeexample}%| The following example shows how to produce a ``snake'' map. The arrow -with |draw=none| goes from $B$ to $E$, and its only purpose is to -create a coordinate, named |Z|, lying halfway between these two cells. -The arrow starting at $C$ has target $D$, so the macros |\tikztostart| -and |\tikztotarget| will expand to the nodes corresponding to these -two cells in the argument of |to path|. Notice also the use of -|\tikztonodes| at the point where we want the label to be inserted. +with the |phantom| option (going from $B$ to $E$) has the sole purpose +of creating a coordinate, named |Z|, lying halfway between these two +cells. The arrow starting at $C$ has target $D$, so the macros +|\tikztostart| and |\tikztotarget| will expand to the nodes +corresponding to these two cells in the argument of |to path|. Notice +also the use of |\tikztonodes| at the point where we want the label to +be inserted. \begin{codeexample}[] \begin{tikzcd} - A \arrow{r} - & B \arrow{r} - \arrow[draw=none]{d}[name=Z, shape=coordinate]{} - & C \arrow[rounded corners, - to path={ -- ([xshift=2ex]\tikztostart.east) - |- (Z) [near end]\tikztonodes - -| ([xshift=-2ex]\tikztotarget.west) - -- (\tikztotarget)}] - {dll}{\delta} \\ - D \arrow{r} - & E \arrow{r} + A \arrow[r] + & B \arrow[r] + \arrow[d, phantom, ""{coordinate, name=Z}] + & C \arrow[dll, + "\delta", + rounded corners, + to path={ -- ([xshift=2ex]\tikztostart.east) + |- (Z) [near end]\tikztonodes + -| ([xshift=-2ex]\tikztotarget.west) + -- (\tikztotarget)}] \\ + D \arrow[r] + & E \arrow[r] & F \end{tikzcd} \end{codeexample} -In the next examples, empty labels are used to create nodes for later -reference, and the |to path| key is used in a way that, in the -terminology of the previous section, \meta{current node} and/or -\meta{target node} are completely ignored. -\begin{codeexample}[] -\begin{tikzcd} - A \arrow{d} \arrow[bend left]{dr}[name=U,below]{}\\ - B \arrow{r} \arrow[Rightarrow,to path=-- (U) \tikztonodes]{}{\psi} & C -\end{tikzcd} -\end{codeexample} -\begin{codeexample}[] -\begin{tikzcd} - A \arrow[bend left=50]{r}[name=U,below]{} - \arrow[bend right=50]{r}[name=D]{} - & B - \arrow[Rightarrow,to path=(U) -- (D)]{} -\end{tikzcd} -\end{codeexample} - \subsection{Drawing diagrams directly with Ti\emph{k}Z} \label{sec:draw-diagr-directly} -If the tools provided by this package prove not flexible enough for -some application, you can use the methods described in \cite{lenders} -and \cite{milne} to draw diagrams directly with \tikzname. In this -case, you can still use the styles provided here in order to achieve -uniformity with diagrams drawn with |tikzcd|. The pictures below show -how this can be done (the second one is adapted from \cite{milne}). +If you find that this package is not flexible enough for some +particular application, you can use the methods described in +\cite{lenders}, \cite{milne} and draw diagrams directly with +\tikzname. In this case, you can still use the styles provided here +to obtain pictures with a uniform appearance throughout your document. +The pictures below show how this can be done (the second one is +adapted from \cite{milne}). \begin{codeexample}[] \begin{tikzpicture}[commutative diagrams/every diagram] - \matrix[matrix of math nodes, name=m] { + \matrix[matrix of math nodes, name=m, commutative diagrams/every cell] { X & \bar X \\ & Y \\}; \path[commutative diagrams/.cd, every arrow, every label] @@ -2047,11 +1130,11 @@ how this can be done (the second one is adapted from \cite{milne}). \begin{codeexample}[] \begin{tikzpicture}[commutative diagrams/every diagram] - \node (P0) at (90:2.8cm) {$X\otimes (Y\otimes (Z\otimes T))$}; - \node (P1) at (90+72:2.5cm) {$X\otimes ((Y\otimes Z)\otimes T))$} ; - \node (P2) at (90+2*72:2.5cm) {\makebox[5ex][r]{$(X\otimes (Y\otimes Z))\otimes T$}}; - \node (P3) at (90+3*72:2.5cm) {\makebox[5ex][l]{$((X\otimes Y)\otimes Z)\otimes T$}}; - \node (P4) at (90+4*72:2.5cm) {$(X\otimes Y)\otimes (Z\otimes T)$}; + \node (P0) at (90:2.3cm) {$X\otimes (Y\otimes (Z\otimes T))$}; + \node (P1) at (90+72:2cm) {$X\otimes ((Y\otimes Z)\otimes T))$} ; + \node (P2) at (90+2*72:2cm) {\makebox[5ex][r]{$(X\otimes (Y\otimes Z))\otimes T$}}; + \node (P3) at (90+3*72:2cm) {\makebox[5ex][l]{$((X\otimes Y)\otimes Z)\otimes T$}}; + \node (P4) at (90+4*72:2cm) {$(X\otimes Y)\otimes (Z\otimes T)$}; \path[commutative diagrams/.cd, every arrow, every label] (P0) edge node[swap] {$1\otimes\phi$} (P1) @@ -2070,36 +1153,58 @@ matrices, and this causes the error message \begin{quote} |! Package pgfbasematrix Error: Single ampersand used with wrong catcode.| \end{quote} -when |tikzcd| is used inside the argument to a macro such as a Beamer -frame or a footnote. One solution to this problem is to call |tikzcd| +when |{tikzcd}| is used inside the argument to a macro such as a Beamer +frame or a footnote. One solution to this problem is to call |{tikzcd}| with the option |ampersand replacement=\&|, and replace all -occurrences of |&| with |\&| in the diagram. +occurrences of |&| with |\&| in the diagram. This procedure is also +needed if you want to use matrices in a diagram cell or label. + +\begin{codeexample}[/tikz/commutative diagrams/diagrams={column sep=large}] +\begin{tikzcd}[ampersand replacement=\&] + A \oplus B \ar[r, "{\begin{pmatrix} e & f \\ g & h \end{pmatrix}}"] + \& C \oplus D +\end{tikzcd} +\end{codeexample} + +An alternative fix to this issue that does not require replacing |&| +with a different column separator consists in adding the following +line to your document after all packages have been loaded: +\begin{quote} + |\def\temp{&} \catcode`&=\active \let&=\temp| +\end{quote} +However, this may interfere in unexpected ways with other +packages. Use it at your own risk. \section{Additional goodies} \label{sec:general-infra} -This package provides some general \pgfname\ infrastructure to meet its ends, -as described in this section. +This package provides some general \pgfname\ infrastructure to achieve +its goals. These additional goodies are documented in this section. \subsection{The \texttt{asymmetrical rectangle} shape} \label{sec:asymm-rect-shape} -The \texttt{asymmetrical rectangle} shape is similar to the -\texttt{rectangle} shape, except that the \texttt{center} anchor is -not located at its geometric center, but rather right above the -\texttt{base} anchor, at a distance that can be specified by the -following key. +The following shape is used inside |{tikzcd}| to ensure that arrows +between nodes in the same row are horizontal. + +\begin{shape}{asymmetrical rectangle} + This shape is similar to the |rectangle| shape, but its |center| is + located at a fixed distance of the |base|, as determined by the + |center yshift| key, rather than lying at the shape's geometric + center. The numerical anchors, as well as |east| and |west|, are + modified accordingly, and there are anchors called |real center|, + |real east|, and |real west| matching |rectangle|'s original + definitions. All other anchors provided by |rectangle| are + available and remain unmodified. +\end{shape} \begin{key}{/tikz/commutative diagrams/center yshift=\meta{dimension} - (initially tikzcdaxis)} + (initially axis\_height)} + Determines the distance between |asymmetrical rectangle|'s |base| + and |center| anchors. \end{key} -The picture below shows some of the available anchors. All anchors -provided by \texttt{rectangle} are available and behave exactly the -same, except for \texttt{center}, \texttt{west}, \texttt{east}, and -the numerical anchors. The anchors \texttt{real center}, \texttt{real - west} and \texttt{real east} agree with \texttt{rectangle}'s -\texttt{center}, \texttt{west} and \texttt{east}. +The picture below shows some of the available anchors. \begin{center}\Huge \begin{tikzpicture} @@ -2115,17 +1220,17 @@ the numerical anchors. The anchors \texttt{real center}, \texttt{real \end{tikzpicture} \end{center} -This shape is used in \texttt{tikzcd}'s matrix cells to ensure arrows -between nodes in the same row are drawn horizontally. When -\tikzname{} draws a path between two nodes, it chooses endpoints lying -on their borders in such a way that the path points towards the -\texttt{center} of the nodes. With the \texttt{rectangle} shape, the -anchor \texttt{center} lies halfway between two nonadjacent vertices -and therefore its position depends on the height and depth of the -text, potentially causing slanted lines to be draw. The picture -above, for instance, has a humongous ascender (namely, the rule after -the word ``rectangle''), so its \texttt{real center} lies well above -its \texttt{center}. +% This shape is used for |{tikzcd}|'s matrix cells to ensure arrows +% between nodes in the same row are drawn horizontally. When +% \tikzname{} draws a path between two nodes, it chooses endpoints lying +% on their borders in such a way that the path points towards the +% \texttt{center} of the nodes. With the \texttt{rectangle} shape, the +% anchor \texttt{center} lies halfway between two nonadjacent vertices +% and therefore its position depends on the height and depth of the +% text, potentially causing slanted lines to be draw. The picture +% above, for instance, has a humongous ascender (namely, the rule after +% the word ``rectangle''), so its \texttt{real center} lies well above +% its \texttt{center}. \subsection{Reading font parameters} \label{sec:read-font-param} @@ -2134,187 +1239,130 @@ The following are |pgfmath| functions used to access relevant math font parameters. They take no arguments, but the result depends of the currently selected font size. -\begin{math-function}{tikzcdaxis} -Returns the ``axis height'' parameter of the document's math font. +\begin{math-function}{axis\_height} +Returns the axis height parameter (a.k.a.\ $\sigma_{22}$) of the document's math font. \end{math-function} -\begin{math-function}{tikzcdrule} -Returns the fraction rule thickness of the document's math font. +\begin{math-function}{rule\_thickness} +Returns the fraction rule thickness (a.k.a.\ $\xi_8$) of the document's math font. \end{math-function} \subsection{Computer Modern arrow tips} \label{sec:comp-modern-arrow} -The naming scheme of the Computer Modern-like arrow tips provided by -this package parallels that of \pgfname's |arrows| library, documented -in \S\ref*{pgfman-section-library-arrows} of the \pgfname{} manual~\cite{pgfman}. To match the Computer Modern -typeface at size 10\,pt, line width should be set to 0.4\,pt; for -larger font sizes, scale this parameter accordingly, or use the value 0.0929\,ex. +The following arrow tips mimic the Computer Modern designs. It is +useful to know that at size 10\,pt, the Computer Modern arrow stems +are 0.4\,pt thick; for larger font sizes, this parameter should be +scaled accordingly, or replaced by the equivalent figure 0.0928\,ex. +Two tips that look significantly different in the Latin Modern font +are also supplied. Notice that by using the mechanism explained in \S\ref{sec:changing-arrow-tips}, it is not necessary, and in fact not advisable, to directly refer to the arrow tips listed in this section -when creating diagrams with |tikzcd|. - -Incidentally, \tikzname's original |to| arrow tip seems to be based on -the pre-1992 version of Computer Modern which, in spite of its -author's wish \cite{knuth}, can still be found in many systems. +inside a |{tikzcd}|. + +\begin{multicols}{2}\raggedcolumns + \begin{tabular}{ll} + \displayarrow{cm to}\\ + \displayarrow[/tikz/commutative diagrams/double line]{cm implies}\\ + \displayarrow[line width=1.5*rule_thickness]{cm bold to}\\ + \displayarrow{cm double to}\\ + \displayarrow{cm left hook}\\ + \displayarrow{cm right hook}\\ + \end{tabular} + + \begin{tabular}{ll} + \displayarrow{cm bar}\\ +% \displayarrow{cm o}\\ +% \displayarrow{cm *}\\ + \displayarrow{cm left to}\\ + \displayarrow{cm right to}\\ + \displayarrow{cm to reversed}\\ + \displayarrow{lm left hook}\\ + \displayarrow{lm bar}\\ + \end{tabular} +\end{multicols} + +Incidentally, \tikzname's original \texttt{to} arrow tip seems to be +based on the pre-1992 version of Computer Modern, which, in spite of +its author's wish \cite{knuth}, can still be found in many systems. \TeX{}Live, for instance, distributed the old version up until 2007 or 2008. Therefore, an up-to-date \TeX{} distribution may be necessary to get matching arrows in formulas and diagrams. -\begin{description} -\item[Basic arrow tips]\ \\ -\begin{tabular}{ll} - \displayarrow{cm to}\\ - \displayarrow{cm to reversed}\\ - \displayarrow[line width=0.66pt]{cm bold to} (with a line 50\% thicker)\\ - \texttt{cm \char`\|} & yields \tikz[baseline=-2.5pt] \draw[cm |-cm |, line width=0.0929ex] (0,0) -- (1,0);\\ - \displayarrow{cm o}\\ - \displayarrow{cm *}\\ - \displayarrow{cm cap}\\ -\end{tabular} - -\item[Arrow tips for double lines]\ \\ -\begin{tabular}{ll} - \displayarrow[/tikz/double distance=3.643\pgflinewidth]{cm implies}\\ - \displayarrow[/tikz/double distance=3.643\pgflinewidth]{cm implies cap} -\end{tabular} - -\item[Hooks]\ \\ -\begin{tabular}{ll} - \displayarrow{cm left hook}\\ - \displayarrow{cm right hook}\\ -\end{tabular} - -\item[Double arrow tips]\ \\ -\begin{tabular}{ll} - \displayarrow{cm double to}\\ - \displayarrow{cm double to reversed}\\ -\end{tabular} - -\item[Partial arrow tips]\ \\ -\begin{tabular}{ll} - \displayarrow{cm left to}\\ - \displayarrow{cm left to reversed}\\ - \displayarrow{cm right to}\\ - \displayarrow{cm right to reversed}\\ -\end{tabular} -\end{description} - -\subsection{Font arrow tips} +\subsection{Glyph arrow tips} \label{sec:font-arrow-tips} -{\it This is - an experimental feature. It may be modified, moved elsewhere or - even removed in the future.} - As an attempt to provide a general solution to the problem of having -matching arrow tips in text and pictures, this feature produces -arrow tips that consist of (pieces of) characters carefully placed at -the endpoints of the path. To activate it in |tikzcd| diagrams, say -\begin{quote} - |\tikzset{commutative diagrams/arrow style=math font}|. -\end{quote} -It is also necessary to load |amssymb| or some other package defining -the symbols corresponding to the arrow tips you want to use. -\ifLuaTeX -Here are some samples: +matching arrow tips in text and pictures, this feature produces arrow +tips that consist of (pieces of) font glyphs carefully placed at the +endpoints of the path. To activate it in |{tikzcd}| diagrams, refer +to the |arrow style| key. + +\begin{arrowtipsimple}{Glyph} + An arrow tip made from a piece of text. It accepts the following +parameters. + +\begin{key}{/pgf/arrow keys/glyph math command=\meta{name}} + The name of a command (to be used inside |$\csname| \dots + |\endcsname$|) producing the desired glyph. +\end{key} -\begin{center} - \begin{tikzpicture} - \node[draw=gray,name=P]{ - \begin{minipage}[t]{0.25\linewidth}\centering - \setmainfont{texgyrepagella-math.otf} - \tikzset{commutative diagrams/.cd, - arrow style=math font, - default arrow/.append style={line width=0.6pt}, - font arrows/.cd, - declare head={math to}{â}{2.5pt}{1ex}, - declare tail={math cap}{â}{2.5pt}{1ex}, - declare tail={math right hook}{âȘ}{2.5pt}{1ex}, - declare head={math double to}{â }{2.5pt}{1.4ex}, - } - \begin{tikzcd}[math mode=false] - \relax\ar[bend right]{rr}\rar[hook]% - đŽ\pgfmatrixnextcell đ”\rar[two heads]% - \pgfmatrixnextcell đ¶ - \end{tikzcd}\\ - \TeX\ Gyre Pagella - \end{minipage}}; - \node[draw=gray,name=Q,right=5mm of P]{ - \begin{minipage}[t]{0.25\linewidth}\centering - \setmainfont{STIXGeneral.otf} - \tikzset{commutative diagrams/.cd, - arrow style=math font, - default arrow/.append style={line width=0.66pt}, - font arrows/.cd, - declare head={math to}{â}{2.5pt}{1ex}, - declare tail={math cap}{â}{2.5pt}{1ex}, - declare tail={math right hook}{âȘ}{2.5pt}{1ex}, - declare head={math double to}{â }{2.5pt}{1.4ex}, - } - \begin{tikzcd}[math mode=false] - \relax\ar[bend right]{rr}\rar[hook]% - đŽ\pgfmatrixnextcell đ”\rar[two heads]% - \pgfmatrixnextcell đ¶ - \end{tikzcd}\\ - STIX - \end{minipage}}; - \node[draw=gray,name=R,right=5mm of Q]{ - \begin{minipage}[t]{0.25\linewidth}\centering - \setmainfont{lmodern-math.otf} - \tikzset{commutative diagrams/.cd, - arrow style=math font, - default arrow/.append style={line width=0.4pt}, - font arrows/.cd, - declare head={math to}{â}{2.5pt}{1ex}, - declare tail={math cap}{â}{2.5pt}{1ex}, - declare tail={math right hook}{âȘ}{2.5pt}{1ex}, - declare head={math double to}{â }{2.5pt}{1.4ex}, - } - \begin{tikzcd}[math mode=false] - \relax\ar[bend right]{rr}\rar[hook]% - đŽ\pgfmatrixnextcell đ”\rar[two heads]% - \pgfmatrixnextcell đ¶ - \end{tikzcd}\\ - Latin Modern - \end{minipage}}; -\end{tikzpicture} -\end{center} -\fi +\begin{key}{/pgf/arrow keys/glyph length=\meta{dimension} (initially 1ex)} + The length of the portion of the glyph not clipped away. Also used + to set the `tip end' parameter. +\end{key} -Setting the key above also makes arrow tips named |math to|, -\texttt{math to reversed}, \texttt{math cap}, \texttt{math \char`\|}, -|math o|, \texttt{math implies}, |math implies cap|, |math left hook|, -\texttt{math right hook}, \texttt{math double to}, |math left to|, and -\texttt{math right to} available for use in \tikzname{} pictures in -the usual way. These tips do not scale with the line width, but their -size depends on the current font size, so you will probably want to -set \texttt{line width=tikzcdrule} when using them. It is possible to -define more arrows or tweak the existing ones. Look into the source -code of this package if you are interested. (And let me know what you -think!) - -The transition between a line and the arrow tip may be visible with some -document viewers and printers, as you may notice from the picture -below. When using \pdf\TeX{} (or Lua\TeX) with \pdf{} output, a -measure is taken to alleviate this. -\begin{center}\tikzset{commutative diagrams/enable font arrows} - \pdf\TeX{} \tikz[baseline=-tikzcdaxis] - \draw[math to-math to, line width=tikzcdrule] (0,0) -- (1,0); - \hspace{1cm} - Other \TeX{} engines - \makeatletter\def\tikzcd@arrowset{\tikzcd@arrowset@generic}\makeatother - \tikz[baseline=-tikzcdaxis] - \draw[math to-math to,line width=tikzcdrule] (0,0) -- (1,0); -\end{center} +\begin{key}{/pgf/arrow keys/glyph axis=\meta{dimension} (initially axis\_height)} + A vertical displacement applied to the glyph in order to make the + glyph's central axis (typically an arrow stem) aligned with the + path. +\end{key} + +\begin{key}{/pgf/arrow keys/glyph shorten=\meta{dimension} (initially -0.1ex)} + An additional amount by which the end of the path is shortened. + This is used to compensate for the gap that usually exists between + the tip end and the glyph's bounding box. +\end{key} +\end{arrowtipsimple} -I don't know of any automatic way of determining the distance between -the lines in a $\Rightarrow$, -so this parameter has to be entered manually via the key -\texttt{/tikz/commutative diagrams/font arrows/double distance} if you -want to use double lines. +Below are some usage examples. Notice that glyph arrow tips do not +scale with \pgfname{} line width but their size depends on the current +font size, so you will probably want to set \texttt{line + width=rule\_thickness} when using them. Also, contrarily to the arrow +parameters defined by the \texttt{arrows.meta} library, the parameters +described above are evaluated only at the time the arrow tip is drawn, +so they can (and should) be given in the units em or ex. + +\begin{codeexample}[] +\tikzset{ + math to/.tip={Glyph[glyph math command=rightarrow]}, + loop/.tip={Glyph[glyph math command=looparrowleft, swap]}, + weird/.tip={Glyph[glyph math command=Rrightarrow, glyph length=1.5ex]}, + pi/.tip={Glyph[glyph math command=pi, glyph length=1.5ex, glyph axis=0pt]}, +} + +\begin{tikzpicture}[line width=rule_thickness] + \draw[loop-math to, bend left] (0,2) to (1,2); + \draw[math to-weird] (0,1) to (1,1); + \draw[pi-pi] (0,0) to (1,0); +\end{tikzpicture} +\end{codeexample} + +It is important to be aware of some drawbacks of this feature. First, +the transition between a line and the arrow tip may become visible +with some printers (especially in low resolutions or draft mode) and +document viewers, as you may be able to see in the samples above. +Second, these rather long tips may +(\tikz[baseline=-axis_height]\draw[dash pattern=on 0.8ex off +0.4ex,-{Glyph[glyph math command=rightarrow]}] (0,0) -- (3.4ex,0);) or may +not (\tikz[baseline=-axis_height]\draw[dash pattern=on 0.8ex off +0.4ex,-{Glyph[glyph math command=rightarrow]}] (0,0) -- (4ex,0);) fit +nicely with dashed or curved lines. Finally, the method used to place +the arrow tip at the end of a stroked path and clip away the arrow +stem makes certain assumptions about the font design and could fail in +cases where unusual design choices are made. \begin{thebibliography}{9} \bibitem{knuth} @@ -2331,10 +1379,12 @@ want to use double lines. Available at \url{http://www.jmilne.org/not/CDGuide.html}. \bibitem{pgfman} Till Tantau, - \emph{The \tikzname{} and \pgfname{} packages: Manual for version 2.10}. + \emph{The \tikzname{} and \pgfname{} packages: Manual for version 3.0.0}. Available at \url{http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}. \end{thebibliography} +\printindex + \end{document} %%% Local Variables: 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 093b2e93e59..cabf3aab1e4 100644 --- a/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty +++ b/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty @@ -1,4 +1,4 @@ -% Copyright 2011, 2012 by FlorĂȘncio Neves +% Copyright 2011, 2012, 2014 by FlorĂȘncio Neves % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -13,749 +13,8 @@ % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. -\ProvidesPackage{tikz-cd}[2012/12/30 v0.3c Commutative diagrams with tikz.] -\RequirePackage{tikz}[2010/10/13] % pgf version 2.10 required - -\usetikzlibrary{matrix} - -\newif\iftikzcd@mathmode - -\pgfqkeys{/tikz/commutative diagrams}{ - .search also={/tikz}, - arrows/.style={ - /tikz/commutative diagrams/every arrow/.append style={#1}}, - labels/.style={ - /tikz/commutative diagrams/every label/.append style={#1}}, - diagrams/.style={ - /tikz/commutative diagrams/every diagram/.append style={#1}}, - description/.style={ - /tikz/anchor=center, - /tikz/fill=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}, - crossing over/.style={ - /tikz/preaction={ - /tikz/draw=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, - /tikz/arrows=-, - /tikz/line width=\pgfkeysvalueof{/tikz/commutative diagrams/crossing over clearance}}}, - row sep/.code={\tikzcd@sep{row}{#1}}, - column sep/.code={\tikzcd@sep{column}{#1}}, - math mode/.is if=tikzcd@mathmode, - matrix of math nodes maybe/.style={% - /tikz/matrix of nodes, - /tikz/nodes={ - execute at begin node=\iftikzcd@mathmode$\fi, %$ - execute at end node=\iftikzcd@mathmode$\fi}}, %$ - arrow style/.is choice} - -% generic arrow tip selection styles -\pgfkeysdef{/tikz/commutative diagrams/arrow style/generic}{% - \pgfqkeys{/tikz/commutative diagrams}{ - rightarrow/.style={/tikz/arrows=-#1 to}, - Rightarrow/.style={ - /tikz/arrows=-#1 implies, - /tikz/commutative diagrams/double line}, - leftarrow/.style={/tikz/arrows=#1 to-}, - Leftarrow/.style={ - /tikz/arrows=#1 implies-, - /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 left to}, - rightharpoondown/.style={/tikz/arrows=-#1 right to}, - leftharpoonup/.style={/tikz/arrows=#1 right to-}, - leftharpoondown/.style={/tikz/arrows=#1 left to-}, - rightarrowtail/.style={/tikz/arrows=#1 to reversed-#1 to}, - leftarrowtail/.style={/tikz/arrows=#1 to-#1 to reversed}, - twoheadrightarrow/.style={/tikz/arrows=-#1 double to}, - twoheadleftarrow/.style={/tikz/arrows=#1 double to-}, - maps to/.code={\pgfsetarrowsstart{#1 |}},%| - hook/.code={\pgfsetarrowsstart{#1 right hook}}, - two heads/.code={\pgfsetarrowsend{#1 double to}}, - tail/.code={\pgfsetarrowsstart{#1 to reversed}}}} - -\pgfqkeys{/tikz/commutative diagrams}{ - dash/.style={/tikz/arrows=-}, - dashrightarrow/.style={ - /tikz/commutative diagrams/rightarrow, - /tikz/commutative diagrams/dashed}, - dashleftarrow/.style={ - /tikz/commutative diagrams/leftarrow, - /tikz/commutative diagrams/dashed}, - equal/.style={ - /tikz/arrows=-, - /tikz/commutative diagrams/double line}, - equals/.style={/tikz/commutative diagrams/equal}, - rightsquigarrow/.style={ - /tikz/commutative diagrams/rightarrow, - /tikz/commutative diagrams/squiggly}, - leftsquigarrow/.style={ - /tikz/commutative diagrams/leftarrow, - /tikz/commutative diagrams/squiggly}, - leftrightsquigarrow/.style={ - /tikz/commutative diagrams/leftrightarrow, - /tikz/commutative diagrams/squiggly}, - squiggly/.code={% - \expandafter\ifx\csname tikz@library@decorations.pathmorphing@loaded\endcsname\pgfutil@empty% - \else\PackageError{tikz-cd}{You need to say % - \string\usetikzlibrary{decorations.pathmorphing} to use squiggly arrows}{}\fi% - \pgfkeysalso{ - /tikz/decorate, - /tikz/decoration={ - zigzag, - 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 -\pgfkeysdef{/tikz/commutative diagrams/arrow style/computer modern}{% - \pgfqkeys{/tikz/commutative diagrams}{ - arrow style/generic={cm}, - default arrow/.style={ - /tikz/line join=round, - /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/dash pattern={on 7\pgflinewidth off 4\pgflinewidth}}}} - -% The tikz arrow style -\pgfkeysdef{/tikz/commutative diagrams/arrow style/tikz}{% - \expandafter\ifx\csname tikz@library@arrows@loaded\endcsname\pgfutil@empty% - \else\PackageError{tikz-cd}{You need to say \string\usetikzlibrary{arrows} % - to use the `tikz' arrow style}{}\fi - \pgfqkeys{/tikz/commutative diagrams}{ - arrow style/generic={\pgfutil@firstofone}, - default arrow/.style={/tikz/commutative diagrams/rightarrow}, - rightarrow/.style={/tikz/arrows=->}, - leftarrow/.style={/tikz/arrows=<-}, - leftrightarrow/.style={/tikz/arrows=<->}, - mapsto/.style={/tikz/arrows=|->},%| - mapsfrom/.style={/tikz/arrows=<-|},%| - hookrightarrow/.style={/tikz/arrows=right hook->}, - hookleftarrow/.style={/tikz/arrows=<-left hook}, - rightarrowtail/.style={/tikz/arrows=>->}, - leftarrowtail/.style={/tikz/arrows=<-<}, - twoheadrightarrow/.style={/tikz/arrows=->>}, - twoheadleftarrow/.style={/tikz/arrows=<<-}, %>> - two heads/.code={\pgfsetarrowsend{\csname tikz@special@arrow@end>>\endcsname}}, - tail/.code={\pgfsetarrowsstart{\csname tikz@special@arrow@start>\endcsname}}, - dashed/.style={/tikz/dashed}, - double line/.style={ - /tikz/double equal sign distance, - /tikz/double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}}} - -% Default settings -\pgfqkeys{/tikz/commutative diagrams}{ - every arrow/.style={ - /tikz/commutative diagrams/.cd, - @enablequotes, - /tikz/draw, - default arrow}, - every label/.style={ - /tikz/commutative diagrams/.cd, - /tikz/auto, - /tikz/font=\everymath\expandafter{\the\everymath\scriptstyle}, - /tikz/inner sep=0.5ex}, - every diagram/.style={ - /tikz/commutative diagrams/.cd, - /tikz/cells={/tikz/nodes={/tikz/shape={asymmetrical rectangle}}}, - row sep=normal, - column sep=normal, - /tikz/baseline=0pt}, - 1-row diagram/.style={/tikz/baseline=(#1.base)}, - math mode=true, - center yshift/.initial=tikzcdaxis, - row sep/huge/.initial=10ex, - row sep/large/.initial=7.5ex, - row sep/normal/.initial=5ex, - row sep/scriptsize/.initial=3.75ex, - row sep/small/.initial=2.5ex, - row sep/tiny/.initial=1.25ex, - column sep/huge/.initial=12ex, - column sep/large/.initial=9ex, - column sep/normal/.initial=6ex, - column sep/scriptsize/.initial=4.5ex, - column sep/small/.initial=3ex, - column sep/tiny/.initial=1.5ex, - arrow style=computer modern, - 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}] - \inheritanchor[from={rectangle}]{base} - \inheritanchor[from={rectangle}]{north} - \inheritanchor[from={rectangle}]{south} - \inheritanchor[from={rectangle}]{base west} - \inheritanchor[from={rectangle}]{north west} - \inheritanchor[from={rectangle}]{south west} - \inheritanchor[from={rectangle}]{base east} - \inheritanchor[from={rectangle}]{north east} - \inheritanchor[from={rectangle}]{south east} - \inheritanchor[from={rectangle}]{mid} - \inheritanchor[from={rectangle}]{mid west} - \inheritanchor[from={rectangle}]{mid east} - \inheritbackgroundpath[from={rectangle}] - \anchor{center}{\pgf@anchor@rectangle@center\pgfmathsetlength\pgf@y% - {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} - \anchor{west}{\pgf@anchor@rectangle@west\pgfmathsetlength\pgf@y% - {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} - \anchor{east}{\pgf@anchor@rectangle@east\pgfmathsetlength\pgf@y% - {\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 yshift}}% - \pgf@xb=\pgf@x% xb/yb is target - \pgf@yb=\pgf@y% - \southwest% - \pgf@xa=\pgf@x% xa/ya is se - \pgf@ya=\pgf@y% - \northeast% - \advance\pgf@x by-\pgf@xa% - \advance\pgf@y by-\pgf@ya% - \pgf@xc=.5\pgf@x% x/y is half width/height - \pgf@yc=.5\pgf@y% - \advance\pgf@xa by\pgf@xc% xa/ya becomes center - \advance\pgf@ya by\pgf@yc% - \ifdim\pgf@yb>0pt% - \northeast% - \pgf@yc=\pgf@y% - \advance\pgf@yc by-\pgfutil@tempdima% - \else% - \southwest% - \pgf@yc=-\pgf@y% - \advance\pgf@yc by\pgfutil@tempdima% - \fi - \edef\pgf@marshal{% - \noexpand\pgfpointborderrectangle - {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}} - {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% - }% - \pgf@process{\pgf@marshal}% - \advance\pgf@x by\pgf@xa% - \advance\pgf@y by\pgfutil@tempdima% - }% -}% - -% The arrow commands -\def\tikzcd@arrow{% - \begingroup% - \pgfutil@ifnextchar[{\tikzcd@ar@getdir}{\tikzcd@ar@getdir[]}} - -\def\tikzcd@ar@getdir[#1]#2{% - \c@pgf@counta\pgfmatrixcurrentrow% - \c@pgf@countb\pgfmatrixcurrentcolumn% - \tikzcd@parse#2\relax% - \toks@\expandafter{\tikzcd@savedpaths\path[/tikz/commutative diagrams/every arrow,#1]}% - \global\edef\tikzcd@savedpaths{% - \the\toks@% - (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn\noexpand\tikzcd@startanchor) to }% - \pgfutil@ifnextchar[{\tikzcd@ar@getlabel}{\pgfutil@ifnextchar\bgroup{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}}} - -\def\tikzcd@ar@getlabel[#1]#2{% - \expandafter\global\expandafter\def\expandafter\tikzcd@savedpaths\expandafter{\tikzcd@savedpaths% - node[/tikz/commutative diagrams/every label,#1]{\tikzcd@mathmaybe{#2}}}% - \pgfutil@ifnextchar[{\tikzcd@ar@getlabel}{\pgfutil@ifnextchar\bgroup{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}}} - -\def\tikzcd@ar@final{% - \toks@\expandafter{\tikzcd@savedpaths}% - \global\edef\tikzcd@savedpaths{% - \the\toks@% - (\tikzmatrixname-\the\c@pgf@counta-\the\c@pgf@countb\noexpand\tikzcd@endanchor); }% - \endgroup}% restore pgf counters - -\def\tikzcd@xar#1{\pgfutil@ifnextchar[{\tikzcd@@xar{#1}}{\tikzcd@arrow[]{#1}}} - -\def\tikzcd@@xar#1[#2]{\tikzcd@arrow[#2]{#1}} - -\def\tikzcd@parse#1{% Parser for arrow direction argument - \def\tikzcd@temp{\tikzcd@parse}% - \ifx#1r\advance\c@pgf@countb by1\else% - \ifx#1d\advance\c@pgf@counta by1\else% - \ifx#1l\advance\c@pgf@countb by-1\else% - \ifx#1u\advance\c@pgf@counta by-1\else% - \ifx#1\relax\let\tikzcd@temp\empty% - \else\PackageError{tikz-cd}{Arrow direction argument must contain % - only the characters u, d, l, r}{}\fi\fi\fi\fi\fi% - \tikzcd@temp} - -% `quotes' library support -\def\tikzcd@passquotes#1{\tikzset{every to/.append style={#1}}} - -\pgfqkeys{/tikz/commutative diagrams}{ - @enablequotes/.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}}}}}} - -% `start anchor', `end anchor', and `shift' keys -\def\tikzcd@setanchor#1[#2]#3\relax{% - \ifx\relax#2\relax\else% - \pgfqkeys{/tikz/commutative diagrams}{@#1transform/.append style={#2},@shiftabletopath}% - \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}{ - @shiftabletopath/.style={ - /tikz/execute at begin to={% - \begingroup% - \def\tikz@tonodes{coordinate[pos=0,commutative diagrams/@starttransform/.try](tikzcd@nodea) % - coordinate[pos=1,commutative diagrams/@endtransform/.try](tikzcd@nodeb)}% - \path (\tikztostart) \tikz@to@path;% - \endgroup% - \def\tikztostart{tikzcd@nodea}% - \def\tikztotarget{tikzcd@nodeb}% - \toks@\expandafter{\tikz@to@path}% - \edef\tikz@to@path{(tikzcd@nodea) \the\toks@} - }, - /tikz/commutative diagrams/@shiftabletopath/.code={}}, - start anchor/.code={% - \pgfutil@ifnextchar[{\tikzcd@setanchor{start}}{\tikzcd@setanchor{start}[]}#1\relax},%] - end anchor/.code={% - \pgfutil@ifnextchar[{\tikzcd@setanchor{end}}{\tikzcd@setanchor{end}[]}#1\relax},%] - start anchor=, - end anchor=, - shift left/.style={ - /tikz/commutative diagrams/@shiftabletopath, - /tikz/execute at begin to={% - \pgfpointnormalised{% - \pgfpointdiff{\pgfpointanchor{tikzcd@nodeb}{center}}{\pgfpointanchor{tikzcd@nodea}{center}}}% - \pgfgetlastxy{\tikzcd@x}{\tikzcd@y}% - \pgfmathparse{(#1)/1pt}% - \coordinate (tikzcd@nodea) at ([shift={(\pgfmathresult*\tikzcd@y,-\pgfmathresult*\tikzcd@x)}]tikzcd@nodea);% - \coordinate (tikzcd@nodeb) at ([shift={(\pgfmathresult*\tikzcd@y,-\pgfmathresult*\tikzcd@x)}]tikzcd@nodeb);}}, - shift right/.style={ - /tikz/commutative diagrams/shift left={-(#1)}}, - transform nodes/.style={ - /tikz/commutative diagrams/@shiftabletopath, - /tikz/commutative diagrams/@starttransform/.append style={#1}, - /tikz/commutative diagrams/@endtransform/.append style={#1}}, - shift/.style={ - /tikz/shift={#1},% we need this for labels to receive a shift - /tikz/commutative diagrams/transform nodes={/tikz/shift={#1}}}, - xshift/.style={ - /tikz/xshift={#1}, - /tikz/commutative diagrams/transform nodes={/tikz/xshift={#1}}}, - yshift/.style={ - /tikz/yshift={#1}, - /tikz/commutative diagrams/transform nodes={/tikz/yshift={#1}}}} - -% The `tikzcd' environment -\def\tikzcd{\pgfutil@ifnextchar[{\tikzcd@}{\tikzcd@[]}} - -\def\tikzcd@[#1]{% - \tikzpicture[/tikz/commutative diagrams/every diagram,#1]% - \def\arrow{\tikzcd@arrow}% - \def\ar{\tikzcd@arrow}% - \def\rar{\tikzcd@xar{r}}% - \def\lar{\tikzcd@xar{l}}% - \def\dar{\tikzcd@xar{d}}% - \def\uar{\tikzcd@xar{u}}% - \def\urar{\tikzcd@xar{ur}}% - \def\ular{\tikzcd@xar{ul}}% - \def\drar{\tikzcd@xar{dr}}% - \def\dlar{\tikzcd@xar{dl}}% - \global\let\tikzcd@savedpaths\empty - \matrix[/tikz/commutative diagrams/matrix of math nodes maybe]\bgroup} - -\def\endtikzcd{% - \toks@\expandafter{\tikzcd@savedpaths}% - \global\edef\tikzcd@savedpaths{% - \noexpand\tikzset{commutative diagrams/\the\pgfmatrixcurrentrow-row diagram/.try=\tikzmatrixname}% - \the\toks@}% - \pgfmatrixendrow\egroup;% - \tikzcd@savedpaths% - \endtikzpicture} - -\def\tikzcd@mathmaybe#1{\iftikzcd@mathmode$\relax #1$\else#1\fi} - -\def\tikzcd@sep#1#2{ - \pgfkeysifdefined{/tikz/commutative diagrams/#1 sep/#2}% - {\pgfkeysalso{/tikz/#1 sep=\pgfkeysvalueof{/tikz/commutative diagrams/#1 sep/#2}}}% - {\pgfkeysalso{/tikz/#1 sep=#2}}} - -% Computer modern arrow tips -\pgfarrowsdeclare{cm to}{cm to} -{ - \pgfarrowsleftextend{-5.833\pgflinewidth} - \pgfarrowsrightextend{0.5\pgflinewidth} -} -{ - \pgfutil@tempdima=\pgflinewidth - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfsetroundjoin - \pgfpathmoveto{\pgfqpoint{-5.333\pgfutil@tempdima}{6\pgfutil@tempdima}} - \pgfpathcurveto - {\pgfqpoint{-4.2\pgfutil@tempdima}{2.5\pgfutil@tempdima}} - {\pgfqpoint{-2.133\pgfutil@tempdima}{0.6\pgfutil@tempdima}} - {\pgfpointorigin} - \pgfpathcurveto - {\pgfqpoint{-2.133\pgfutil@tempdima}{-0.6\pgfutil@tempdima}} - {\pgfqpoint{-4.2\pgfutil@tempdima}{-2.5\pgfutil@tempdima}} - {\pgfqpoint{-5.333\pgfutil@tempdima}{-6\pgfutil@tempdima}} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm implies}{cm implies} -{ - \pgfmathsetlength{\pgfutil@tempdima}{-0.729\pgflinewidth+.25*\pgfinnerlinewidth} - \pgfarrowsleftextend{\pgfutil@tempdima} - \pgfmathsetlength{\pgfutil@tempdima}{1.094\pgflinewidth-.25*\pgfinnerlinewidth} - \pgfarrowsrightextend{\pgfutil@tempdima} -} -{ - \pgfmathsetlength{\pgfutil@tempdimb}{.5\pgflinewidth-.5*\pgfinnerlinewidth} - \pgfutil@tempdima\pgflinewidth - \pgfsetlinewidth{\pgfutil@tempdimb} - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfsetroundjoin - \pgfpathmoveto{\pgfqpoint{-0.542\pgfutil@tempdima}{1.142\pgfutil@tempdima}} - \pgfpathcurveto - {\pgfqpoint{-0.247\pgfutil@tempdima}{0.476\pgfutil@tempdima}} - {\pgfqpoint{0.29\pgfutil@tempdima}{0.114\pgfutil@tempdima}} - {\pgfqpoint{0.844\pgfutil@tempdima}{0pt}} - \pgfpathcurveto - {\pgfqpoint{0.29\pgfutil@tempdima}{-0.114\pgfutil@tempdima}} - {\pgfqpoint{-0.247\pgfutil@tempdima}{-0.476\pgfutil@tempdima}} - {\pgfqpoint{-0.542\pgfutil@tempdima}{-1.142\pgfutil@tempdima}} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm bold to}{cm bold to} -{ - \pgfarrowsleftextend{-4.055\pgflinewidth} - \pgfarrowsrightextend{0.5\pgflinewidth} -} -{ - \pgfutil@tempdima=0.667\pgflinewidth - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfsetroundjoin - \pgfpathmoveto{\pgfqpoint{-5.333\pgfutil@tempdima}{6\pgfutil@tempdima}} - \pgfpathcurveto - {\pgfqpoint{-4.2\pgfutil@tempdima}{2.5\pgfutil@tempdima}} - {\pgfqpoint{-2.133\pgfutil@tempdima}{0.6\pgfutil@tempdima}} - {\pgfpointorigin} - \pgfpathcurveto - {\pgfqpoint{-2.133\pgfutil@tempdima}{-0.6\pgfutil@tempdima}} - {\pgfqpoint{-4.2\pgfutil@tempdima}{-2.5\pgfutil@tempdima}} - {\pgfqpoint{-5.333\pgfutil@tempdima}{-6\pgfutil@tempdima}} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm left to}{cm left to} -{ - \pgfarrowsleftextend{-5.833\pgflinewidth} - \pgfarrowsrightextend{0.5\pgflinewidth} -} -{ - \pgfutil@tempdima=\pgflinewidth - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfsetroundjoin - \pgfpathmoveto{\pgfqpoint{-5.333\pgfutil@tempdima}{6\pgfutil@tempdima}} - \pgfpathcurveto - {\pgfqpoint{-4.2\pgfutil@tempdima}{2.5\pgfutil@tempdima}} - {\pgfqpoint{-2.133\pgfutil@tempdima}{0.6\pgfutil@tempdima}} - {\pgfpointorigin} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm right to}{cm right to} -{ - \pgfarrowsleftextend{-5.833\pgflinewidth} - \pgfarrowsrightextend{0.5\pgflinewidth} -} -{ - \pgfutil@tempdima=\pgflinewidth - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfsetroundjoin - \pgfpathmoveto{\pgfpointorigin} - \pgfpathcurveto - {\pgfqpoint{-2.133\pgfutil@tempdima}{-0.6\pgfutil@tempdima}} - {\pgfqpoint{-4.2\pgfutil@tempdima}{-2.5\pgfutil@tempdima}} - {\pgfqpoint{-5.333\pgfutil@tempdima}{-6\pgfutil@tempdima}} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm |}{cm |} -{ - \pgfarrowsleftextend{-0.5\pgflinewidth} - \pgfarrowsrightextend{0.5\pgflinewidth} -} -{ - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfpathmoveto{\pgfqpoint{0pt}{-4\pgflinewidth}} - \pgfpathlineto{\pgfqpoint{0pt}{4\pgflinewidth}} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm left hook}{cm left hook} -{ - \pgfarrowsleftextend{-0.5\pgflinewidth} - \pgfarrowsrightextend{3.5\pgflinewidth} -} -{ - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfpathmoveto{\pgfqpoint{0pt}{4.667\pgflinewidth}} - \pgfpathcurveto - {\pgfqpoint{4\pgflinewidth}{4.667\pgflinewidth}} - {\pgfqpoint{4\pgflinewidth}{0pt}} - {\pgfpointorigin} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm right hook}{cm right hook} -{ - \pgfarrowsleftextend{-0.5\pgflinewidth} - \pgfarrowsrightextend{3.5\pgflinewidth} -} -{ - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfpathmoveto{\pgfqpoint{0pt}{-4.667\pgflinewidth}} - \pgfpathcurveto - {\pgfqpoint{4\pgflinewidth}{-4.667\pgflinewidth}} - {\pgfqpoint{4\pgflinewidth}{0pt}} - {\pgfpointorigin} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm o}{cm o} -{ - \pgfarrowsleftextend{+-.5\pgflinewidth} - \pgfarrowsrightextend{7.167\pgflinewidth} -} -{ - \pgfpathcircle{\pgfqpoint{3.333\pgflinewidth}{0pt}}{3.333\pgflinewidth} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm *}{cm *} -{ - \pgfarrowsleftextend{+-.5\pgflinewidth} - \pgfarrowsrightextend{7.167\pgflinewidth} -} -{ - \pgfpathcircle{\pgfqpoint{3.333\pgflinewidth}{0pt}}{3.333\pgflinewidth} - \pgfusepathqfillstroke -} - -\pgfarrowsdeclare{cm cap}{cm cap} -{ - \pgfarrowsleftextend{+0pt} - \pgfarrowsrightextend{+\pgflinewidth} -} -{ - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfpathmoveto{\pgfpointorigin} - \pgfpathlineto{\pgfqpoint{0.5\pgflinewidth}{0pt}} - \pgfusepathqstroke -} - -\pgfarrowsdeclare{cm implies cap}{cm implies cap} -{ - \pgfmathsetlength{\pgfutil@tempdima}{.5\pgflinewidth-.5*\pgfinnerlinewidth} - \pgfarrowsleftextend{+0pt} - \pgfarrowsrightextend{+\pgfutil@tempdima} -} -{ - \pgfmathsetlength{\pgfutil@tempdima}{.5\pgflinewidth-.5*\pgfinnerlinewidth} - \pgfmathsetlength{\pgfutil@tempdimb}{.5\pgflinewidth-.5*\pgfutil@tempdima} - \pgfsetlinewidth{\pgfutil@tempdima} - \pgfsetdash{}{+0pt} - \pgfsetroundcap - \pgfpathmoveto{\pgfqpoint{0pt}{+1\pgfutil@tempdimb}} - \pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{+1\pgfutil@tempdimb}} - \pgfpathmoveto{\pgfqpoint{0pt}{-1\pgfutil@tempdimb}} - \pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{-1\pgfutil@tempdimb}} - \pgfusepathqstroke -} - -\pgfarrowsdeclarereversed{cm to reversed}{cm to reversed}{cm to}{cm to} -\pgfarrowsdeclarereversed{cm left to reversed}{cm left to reversed}{cm left to}{cm left to} -\pgfarrowsdeclarereversed{cm right to reversed}{cm right to reversed}{cm right to}{cm right to} - -\pgfarrowsdeclaredouble{cm double to}{cm double to}{cm to}{cm to} -\pgfarrowsdeclaredouble{cm double to reversed}{cm double to reversed}{cm to reversed}{cm to reversed} - -% Font arrows (experimental) -\pgfkeysdef{/tikz/commutative diagrams/enable font arrows}{% - % A little surgery on pgf's arrow selection commands - \pgfutil@ifundefined{tikzcd@orig@pgfsetarrowsend}% - {\let\tikzcd@orig@pgfsetarrowsend\pgfsetarrowsend - \let\tikzcd@orig@pgfsetarrowsstart\pgfsetarrowsstart - \def\pgfsetarrowsend##1{% - \pgfutil@ifundefined{tikzcd@arrows@cmd@##1}% - {\tikzcd@orig@pgfsetarrowsend{##1}} - {\tikzcd@arrowset{end}{##1}}}% - \def\pgfsetarrowsstart##1{% - \pgfutil@ifundefined{tikzcd@arrows@cmd@##1}% - {\tikzcd@orig@pgfsetarrowsstart{##1}} - {\tikzcd@arrowset{start}{##1}}}}% - {}} - -\pgfqkeys{/tikz/commutative diagrams/font arrows}{ - double distance/.store in={\tikzcdfontarrowsdoubledistance}, - declare head/.code n args={4}{\tikzcd@arrowsdeclare{#1}{#2}{#3}{#4}{\iftrue}}, - declare tail/.code n args={4}{\tikzcd@arrowsdeclare{#1}{#2}{#3}{#4}{\iffalse}}} - -% #1 = name -% #2 = command -% #3 = axis height -% #4 = width of clip box -% #5 = \iftrue for head, \iffalse for tail -\def\tikzcd@arrowsdeclare#1#2#3#4#5{% - \expandafter\def\csname tikzcd@arrows@cmd@#1\endcsname{#2}% - \expandafter\def\csname tikzcd@arrows@ifhead@#1\endcsname{#5}% - \expandafter\def\csname tikzcd@arrows@axheight@#1\endcsname{#3}% - \expandafter\def\csname tikzcd@arrows@length@#1\endcsname{#4}} - -% Select the pdfTeX or generic backend according to pgf's setting. -% -% The generic backend uses a rectangle to clip the font glyph, and the -% pdfTeX backend uses the font glyph as the clipping path for a big -% black box. The latter method seems to trick pdf viewers and -% printers to treat the resulting arrow tip as a graphic element -% instead of text, making the transition between line and arrow tip -% less noticeable. -\def\tikzcd@temp{pgfsys-pdftex.def} -\ifx\pgfsysdriver\tikzcd@temp - \def\tikzcd@arrowset{\tikzcd@arrowset@pdftex} -\else - \def\tikzcd@arrowset{\tikzcd@arrowset@generic} -\fi - -% #1 `start' or `end' -% #2 arrow name -\def\tikzcd@arrowset@pdftex#1#2{% - \expandafter\def\csname pgf@#1arrow\endcsname{% - \pgfinterruptpath% - \pgf@relevantforpicturesizefalse% - \pgftransformreset% - \pgfsys@beginscope% - \pgfmathsetlengthmacro\tikzcd@len{\csname tikzcd@arrows@length@#2\endcsname}% - \setbox\pgfutil@tempboxa=\hbox{\pgfinterruptpicture % - \csname tikzcd@arrows@cmd@#2\endcsname\endpgfinterruptpicture}% - \csname tikzcd@arrows@ifhead@#2\endcsname% - \pgftransformxshift{\tikzcd@len-\wd\pgfutil@tempboxa}% - \else% - \pgftransformrotate{180}% - \pgftransformxshift{-\tikzcd@len}% - \fi% - \pgftransformyshift{-\csname tikzcd@arrows@axheight@#2\endcsname}% - \pdfliteral{7 Tr}% - \pgflowlevelsynccm\copy\pgfutil@tempboxa% - \csname tikzcd@arrows@ifhead@#2\endcsname\else% - \pgftransformxshift{\tikzcd@len-\wd\pgfutil@tempboxa}% - \fi% - \pgfpathrectangle{\pgfpoint{0pt}{-1ex}}{\pgfpoint{-\tikzcd@len}{3ex}}% - \pgfusepathqfill% - \pgfsys@endscope% - \endpgfinterruptpath}% - \expandafter\def\csname pgf@shorten@#1\endcsname{% - \pgfmathsetlength\pgf@xa{\csname tikzcd@arrows@length@#2\endcsname}% - \advance\pgf@x by\pgf@xa}}% - -% #1 `start' or `end' -% #2 arrow name -\def\tikzcd@arrowset@generic#1#2{% - \expandafter\def\csname pgf@#1arrow\endcsname{% - \pgfinterruptpath% - \pgf@relevantforpicturesizefalse% - \pgftransformreset% - \pgfsys@beginscope% - \pgfmathsetlengthmacro\tikzcd@len{\csname tikzcd@arrows@length@#2\endcsname}% - \pgfpathrectangle{\pgfpoint{0pt}{-1.5ex}}{\pgfpoint{\tikzcd@len}{3ex}}% - \pgfusepathqclip% - \csname tikzcd@arrows@ifhead@#2\endcsname% - \pgftransformxshift{\tikzcd@len}% - \else% - \pgftransformrotate{180}% - \pgftransformxshift{-\tikzcd@len}% - \fi% - \pgftransformyshift{-\csname tikzcd@arrows@axheight@#2\endcsname}% - \pgftext[\csname tikzcd@arrows@ifhead@#2\endcsname right\else left\fi,base]% - {\csname tikzcd@arrows@cmd@#2\endcsname}% - \pgfsys@endscope% - \endpgfinterruptpath}% - \expandafter\def\csname pgf@shorten@#1\endcsname{% - \pgfmathsetlength\pgf@xa{\csname tikzcd@arrows@length@#2\endcsname}% - \advance\pgf@x by\pgf@xa}}% - -% The arguments for `declare head' and `declare tail' are 1. name of -% the arrow tip, 2. TeX command corresponding to an arrow, 3. distance -% from baseline to arrow stem, 4. width of the clip box, which should -% be big enough to contain the whole tip. -\pgfqkeys{/tikz/commutative diagrams/font arrows}{ - double distance={3.8\pgflinewidth}, - 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/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/dash pattern=on 0.8ex off 0.4ex}, - squiggly/.default={pre length=1ex,post length=1ex}}} +\ProvidesPackage{tikz-cd}[2014/02/28 v0.9 Commutative diagrams with tikz] +\RequirePackage{tikz}[2013/12/13] % pgf version 3.0.0 required +\usetikzlibrary{cd} \endinput diff --git a/Master/texmf-dist/tex/latex/tikz-cd/tikzlibrarycd.code.tex b/Master/texmf-dist/tex/latex/tikz-cd/tikzlibrarycd.code.tex new file mode 100644 index 00000000000..f14c162c5a9 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-cd/tikzlibrarycd.code.tex @@ -0,0 +1,683 @@ +% Copyright 2011, 2012, 2014 by FlorĂȘncio Neves +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. + +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. + +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. + +\ProvidesFile{tikzlibrarycd.code.tex}[2014/02/28 v0.9 Commutative diagrams with tikz] + +\usetikzlibrary{matrix,quotes} + +\newif\iftikzcd@mathmode + +\def\tikzcdset{\pgfqkeys{/tikz/commutative diagrams}} + +\def\tikzcd@x@addto@macro#1#2{% + \pgfutil@toks@\expandafter{#1}% + \xdef#1{\the\pgfutil@toks@#2}} + +\tikzcdset{ + arrows/.code={\tikzcdset{every arrow/.append style={#1}}}, + labels/.code={\tikzcdset{every label/.append style={#1}}}, + cells/.code={\tikzcdset{every cell/.append style={#1}}}, + diagrams/.code={\tikzcdset{every diagram/.append style={#1}}}, + to/.code={% + \pgfutil@ifundefined{pgf@sh@ns@\tikzcdmatrixname-#1} + {\def\tikzcd@ar@target{#1}} + {\def\tikzcd@ar@target{\tikzcdmatrixname-#1}}}, + from/.code={% + \pgfutil@ifundefined{pgf@sh@ns@\tikzcdmatrixname-#1} + {\def\tikzcd@ar@start{#1}} + {\def\tikzcd@ar@start{\tikzcdmatrixname-#1}}}, + description/.style={ + /tikz/anchor=center, + /tikz/fill=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}, + phantom/.style={ + /tikz/draw=none, + /tikz/commutative diagrams/labels={ + /tikz/font=, + /tikz/anchor=center}}, + crossing over/.style={ + /tikz/preaction={ + /tikz/draw=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, + /tikz/arrows=-, + /tikz/line width=\pgfkeysvalueof{/tikz/commutative diagrams/crossing over clearance}}}, + row sep/.code={\tikzcd@sep{row}{#1}}, + column sep/.code={\tikzcd@sep{column}{#1}}, + math mode/.is if=tikzcd@mathmode, + arrow style/.is choice} + +\def\tikzcd@sep#1#2{ + \pgfkeysifdefined{/tikz/commutative diagrams/#1 sep/#2}% + {\pgfkeysgetvalue{/tikz/commutative diagrams/#1 sep/#2}\tikzcd@temp% + \pgfkeysalso{/tikz/#1 sep/.expand once=\tikzcd@temp}}% + {\pgfkeysalso{/tikz/#1 sep={#2}}}} + +% The unknown key handler and direction argument parser +\tikzcdset{ + .unknown/.code={% + \ifpgfkeysaddeddefaultpath% + \c@pgf@counta=0% + \c@pgf@countb=0% + \let\tikzcd@temp=\tikzcd@parse% + \expandafter\tikzcd@temp\pgfkeyscurrentname\relax% + \ifx\tikzcd@temp\pgfutil@empty% true if it was a direction parameter + \advance\c@pgf@counta by\tikzcd@currentrow% + \advance\c@pgf@countb by\tikzcd@currentcolumn% + \edef\tikzcd@ar@target{\tikzcdmatrixname-\the\c@pgf@counta-\the\c@pgf@countb}% + \else% + \pgfqkeys{/tikz}{\pgfkeyscurrentname={#1}}% + \fi% + \else% + \def\pgfutilnext{\pgfkeysvalueof{/handlers/.unknown/.@cmd}#1\pgfeov}\pgfutilnext% + \fi}} + +\def\tikzcd@parse#1{% parser for arrow direction argument + \ifx#1r\advance\c@pgf@countb by1\else% + \ifx#1d\advance\c@pgf@counta by1\else% + \ifx#1l\advance\c@pgf@countb by-1\else% + \ifx#1u\advance\c@pgf@counta by-1\else% + \ifx#1\relax\let\tikzcd@temp\pgfutil@empty% + \else\let\tikzcd@temp\pgfutil@gobble@until@relax\fi\fi\fi\fi\fi% + \tikzcd@temp} + +% The `tikzcd' environment +\def\tikzcd{% + \pgfutil@ifnextchar&% + {\expandafter\tikzcd@@\expandafter\pgfmatrixnextcell\pgfutil@gobble}% + {\tikzcd@@}} + +\def\tikzcd@@{\pgfutil@ifnextchar[{\tikzcd@}{\tikzcd@[]}} + +\def\tikzcd@[#1]{% + \tikzpicture[/tikz/commutative diagrams/.cd,every diagram,#1]% + \def\arrow{\tikzcd@arrow}% + \def\ar{\tikzcd@arrow}% + \def\rar{\tikzcd@xar{r}}% + \def\lar{\tikzcd@xar{l}}% + \def\dar{\tikzcd@xar{d}}% + \def\uar{\tikzcd@xar{u}}% + \def\urar{\tikzcd@xar{ur}}% + \def\ular{\tikzcd@xar{ul}}% + \def\drar{\tikzcd@xar{dr}}% + \def\dlar{\tikzcd@xar{dl}}% + \global\let\tikzcd@savedpaths\pgfutil@empty% + \matrix[/tikz/matrix of \iftikzcd@mathmode math \fi nodes, + /tikz/every cell/.append code={\tikzcdset{every cell}}, + /tikz/commutative diagrams/.cd,every matrix]% + \bgroup} + +\def\endtikzcd{% + \pgfmatrixendrow\egroup% + \pgfextra{\global\let\tikzcdmatrixname\tikzlastnode};% + \tikzcdset{\the\pgfmatrixcurrentrow-row diagram/.try}% + \begingroup% + \tikzcd@enablequotes% + \tikzcd@patcherrmsg% + \tikzcd@savedpaths% + \endgroup% + \endtikzpicture} + +% The arrow commands +\def\tikzcd@arrow{% + \relax% + \tikzcd@x@addto@macro\tikzcd@savedpaths{% + \noexpand\def\noexpand\tikzcd@currentcolumn{\the\pgfmatrixcurrentcolumn}% + \noexpand\def\noexpand\tikzcd@currentrow{\the\pgfmatrixcurrentrow}% + \noexpand\def\noexpand\tikzcd@lineno{\the\inputlineno}}% + \pgfutil@ifnextchar[{\tikzcd@@arrow}{\tikzcd@ar@old[]}} + +\def\tikzcd@@arrow[#1]{\pgfutil@ifnextchar\bgroup{\tikzcd@ar@old[#1]}{\tikzcd@ar@new[#1]}} + +\def\tikzcd@ar@new[#1]{% new syntax + \pgfutil@g@addto@macro\tikzcd@savedpaths{% + \path[/tikz/commutative diagrams/.cd,every arrow,#1]% + (\tikzcd@ar@start\tikzcd@startanchor) to (\tikzcd@ar@target\tikzcd@endanchor); }} + +\def\tikzcd@ar@old[#1]#2{% old syntax + \pgfutil@g@addto@macro\tikzcd@savedpaths{% + \path[/tikz/commutative diagrams/.cd,every arrow,{#2},#1] (\tikzcd@ar@start\tikzcd@startanchor) to }% + \pgfutil@ifnextchar[{\tikzcd@ar@getlabel}{\pgfutil@ifnextchar\bgroup{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}}} + +\def\tikzcd@ar@getlabel[#1]#2{% + \pgfutil@g@addto@macro\tikzcd@savedpaths{% + node[/tikz/commutative diagrams/.cd,every label,#1]{\tikzcd@mathmaybe{#2}}}% + \pgfutil@ifnextchar[{\tikzcd@ar@getlabel}{\pgfutil@ifnextchar\bgroup{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}}} + +\def\tikzcd@ar@final{% + \pgfutil@g@addto@macro\tikzcd@savedpaths{(\tikzcd@ar@target\tikzcd@endanchor); }} + +\def\tikzcd@xar#1{\relax\pgfutil@ifnextchar[{\tikzcd@@xar{#1}}{\tikzcd@arrow[]{#1}}} + +\def\tikzcd@@xar#1[#2]{\tikzcd@arrow[#2]{#1}} + +\def\tikzcd@mathmaybe#1{\iftikzcd@mathmode$\relax #1$\else#1\fi} + +\def\tikzcd@ar@target{\tikzcdmatrixname-\tikzcd@currentrow-\tikzcd@currentcolumn} +\def\tikzcd@ar@start{\tikzcdmatrixname-\tikzcd@currentrow-\tikzcd@currentcolumn} + +% `quotes' library support +\def\tikzcd@passquotes#1{\tikzset{every to/.append style={#1}}} + +\def\tikzcd@enablequotes{% + \pgfkeys{ + /handlers/first char syntax/the character "/.initial=\tikzcd@passquotes, + /tikz/edge quotes mean={% + edge node={node [/tikz/commutative diagrams/.cd,every label,##2]{\tikzcd@mathmaybe{##1}}}}}} + +% Improve error messages +\def\tikzcd@patcherrmsg{% + \let\tikzcd@errmessage\errmessage% + \def\errmessage##1{\tikzcd@errmessage{##1^^J...^^Jl.\tikzcd@lineno\space% + I think the culprit is a tikzcd arrow in cell \tikzcd@currentrow-\tikzcd@currentcolumn}}} + +% `start anchor', `end anchor', and `shift' keys +\def\tikzcd@setanchor#1[#2]#3\relax{% + \ifx\relax#2\relax\else% + \tikzcdset{@#1transform/.append style={#2},@shiftabletopath}% + \fi% + \ifx\relax#3\relax% + \pgfutil@namelet{tikzcd@#1anchor}{pgfutil@empty}% + \else% + \pgfutil@namedef{tikzcd@#1anchor}{.#3}% + \fi} + +\tikzcdset{ + @shiftabletopath/.style={ + /tikz/execute at begin to={% + \begingroup% + \def\tikz@tonodes{coordinate[pos=0,commutative diagrams/@starttransform/.try](tikzcd@nodea) % + coordinate[pos=1,commutative diagrams/@endtransform/.try](tikzcd@nodeb)}% + \path (\tikztostart) \tikz@to@path;% + \endgroup% + \def\tikztostart{tikzcd@nodea}% + \def\tikztotarget{tikzcd@nodeb}% + \tikzset{insert path={(tikzcd@nodea)}}}, + /tikz/commutative diagrams/@shiftabletopath/.code={}}, + start anchor/.code={% + \pgfutil@ifnextchar[{\tikzcd@setanchor{start}}{\tikzcd@setanchor{start}[]}#1\relax},%] + end anchor/.code={% + \pgfutil@ifnextchar[{\tikzcd@setanchor{end}}{\tikzcd@setanchor{end}[]}#1\relax},%] + start anchor=, + end anchor=, + shift left/.style={ + /tikz/commutative diagrams/@shiftabletopath, + /tikz/execute at begin to={% + \pgfpointnormalised{% + \pgfpointdiff{\pgfpointanchor{tikzcd@nodeb}{center}}{\pgfpointanchor{tikzcd@nodea}{center}}}% + \pgfgetlastxy{\tikzcd@x}{\tikzcd@y}% + \pgfmathparse{#1}% + \ifpgfmathunitsdeclared\else + \pgfmathparse{\pgfmathresult*\pgfkeysvalueof{/tikz/commutative diagrams/shift left/.@def}} + \fi + \coordinate (tikzcd@nodea) at ([shift={(\pgfmathresult*\tikzcd@y,-\pgfmathresult*\tikzcd@x)}]tikzcd@nodea);% + \coordinate (tikzcd@nodeb) at ([shift={(\pgfmathresult*\tikzcd@y,-\pgfmathresult*\tikzcd@x)}]tikzcd@nodeb);% + \tikzset{insert path={(tikzcd@nodea)}}}}, + shift right/.style={ + /tikz/commutative diagrams/shift left={-(#1)}}, + transform nodes/.style={ + /tikz/commutative diagrams/@shiftabletopath, + /tikz/commutative diagrams/@starttransform/.append style={#1}, + /tikz/commutative diagrams/@endtransform/.append style={#1}}, + shift/.style={ + /tikz/shift={#1},% we need this for labels to receive a shift + /tikz/commutative diagrams/transform nodes={/tikz/shift={#1}}}, + xshift/.style={ + /tikz/xshift={#1}, + /tikz/commutative diagrams/transform nodes={/tikz/xshift={#1}}}, + yshift/.style={ + /tikz/yshift={#1}, + /tikz/commutative diagrams/transform nodes={/tikz/yshift={#1}}}} + +% pgfmath functions to obtain math fontdimens +\pgfutil@ifluatex + + \directlua{tex.enableprimitives('tikzcd@', {'Umathaxis', 'Umathfractionrule'})} + + \pgfmathdeclarefunction{axis_height}{0}{% + \begingroup% + $\relax$% update fontdimens + \pgfmathreturn\the\tikzcd@Umathaxis\textstyle% + \endgroup} + + \pgfmathdeclarefunction{rule_thickness}{0}{% + \begingroup% + $\relax$% + \pgfmathreturn\the\tikzcd@Umathfractionrule\textstyle% + \endgroup} + +\else% if using (pdf)tex + + \pgfmathdeclarefunction{axis_height}{0}{% + \begingroup% + $\relax$% update fontdimens + \pgfmathreturn\the\fontdimen22\textfont2% + \endgroup} + + \pgfmathdeclarefunction{rule_thickness}{0}{% + \begingroup% + $\relax$% + \pgfmathreturn\the\fontdimen8\textfont3% + \endgroup} + +\fi + +% The shape used inside matrices +\pgfdeclareshape{asymmetrical rectangle} { + \inheritsavedanchors[from={rectangle}] + \inheritanchor[from={rectangle}]{base} + \inheritanchor[from={rectangle}]{north} + \inheritanchor[from={rectangle}]{south} + \inheritanchor[from={rectangle}]{base west} + \inheritanchor[from={rectangle}]{north west} + \inheritanchor[from={rectangle}]{south west} + \inheritanchor[from={rectangle}]{base east} + \inheritanchor[from={rectangle}]{north east} + \inheritanchor[from={rectangle}]{south east} + \inheritanchor[from={rectangle}]{mid} + \inheritanchor[from={rectangle}]{mid west} + \inheritanchor[from={rectangle}]{mid east} + \inheritbackgroundpath[from={rectangle}] + \anchor{center}{\pgf@anchor@rectangle@center\pgfmathsetlength\pgf@y% + {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} + \anchor{west}{\pgf@anchor@rectangle@west\pgfmathsetlength\pgf@y% + {\pgfkeysvalueof{/tikz/commutative diagrams/center yshift}}} + \anchor{east}{\pgf@anchor@rectangle@east\pgfmathsetlength\pgf@y% + {\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 yshift}}% + \pgf@xb=\pgf@x% xb/yb is target + \pgf@yb=\pgf@y% + \southwest% + \pgf@xa=\pgf@x% xa/ya is se + \pgf@ya=\pgf@y% + \northeast% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \pgf@xc=.5\pgf@x% x/y is half width/height + \pgf@yc=.5\pgf@y% + \advance\pgf@xa by\pgf@xc% xa/ya becomes center + \advance\pgf@ya by\pgf@yc% + \ifdim\pgf@yb>0pt% + \northeast% + \pgf@yc=\pgf@y% + \advance\pgf@yc by-\pgfutil@tempdima% + \else% + \southwest% + \pgf@yc=-\pgf@y% + \advance\pgf@yc by\pgfutil@tempdima% + \fi + \edef\pgf@marshal{% + \noexpand\pgfpointborderrectangle + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}} + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + }% + \pgf@process{\pgf@marshal}% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgfutil@tempdima% + }% +}% + +% Computer modern arrow tips +\pgfdeclarearrow{ + name=cm to, + parameters={\ifpgfarrowharpoon h\fi}, + setup code={% + \pgfarrowssetbackend{-5.8\pgflinewidth}% + \pgfarrowssettipend{0.5\pgflinewidth}}, + drawing code={ + \pgfsetdash{}{+0pt}% + \pgfsetroundcap% + \pgfsetroundjoin% + \pgfpathmoveto{\pgfqpoint{-5.3\pgflinewidth}{6\pgflinewidth}}% + \pgfpathcurveto% + {\pgfqpoint{\ifpgfarrowharpoon-4\else-4.5\fi\pgflinewidth}{\ifpgfarrowharpoon3\else2.5\fi\pgflinewidth}}% + {\pgfqpoint{\ifpgfarrowharpoon-2\else-2.133\fi\pgflinewidth}{\ifpgfarrowharpoon1\else0.6\fi\pgflinewidth}}% + {\pgfpointorigin}% + \ifpgfarrowharpoon\else% + \pgfpathcurveto% + {\pgfqpoint{-2.133\pgflinewidth}{-0.6\pgflinewidth}}% + {\pgfqpoint{-4.5\pgflinewidth}{-2.5\pgflinewidth}}% + {\pgfqpoint{-5.3\pgflinewidth}{-6\pgflinewidth}}% + \fi% + \pgfusepathqstroke}} + +\pgfdeclarearrow{ + name=cm implies, + setup code={% + \pgfarrowssetbackend{\pgfinnerlinewidth\pgf@x=0.25\pgf@x\advance\pgf@x by-0.792\pgflinewidth}% + \pgfarrowssettipend{\pgfinnerlinewidth\pgf@x=-0.25\pgf@x\advance\pgf@x by1.094\pgflinewidth}}, + drawing code={% + \pgfutil@tempdima\pgflinewidth% + \pgfsetlinewidth{.5\pgflinewidth-.5*\pgfinnerlinewidth}% + \pgfsetdash{}{+0pt}% + \pgfsetroundcap% + \pgfsetroundjoin% + \pgfpathmoveto{\pgfqpoint{-0.542\pgfutil@tempdima}{1.1\pgfutil@tempdima}}% + \pgfpathcurveto% + {\pgfqpoint{-0.2\pgfutil@tempdima}{0.5\pgfutil@tempdima}}% + {\pgfqpoint{0.29\pgfutil@tempdima}{0.114\pgfutil@tempdima}}% + {\pgfqpoint{0.844\pgfutil@tempdima}{0pt}}% + \pgfpathcurveto% + {\pgfqpoint{0.29\pgfutil@tempdima}{-0.114\pgfutil@tempdima}}% + {\pgfqpoint{-0.2\pgfutil@tempdima}{-0.5\pgfutil@tempdima}}% + {\pgfqpoint{-0.542\pgfutil@tempdima}{-1.1\pgfutil@tempdima}}% + \pgfusepathqstroke}} + +\pgfdeclarearrow{ + name=cm bold to, + setup code={ + \pgfarrowssetbackend{-4.035\pgflinewidth} + \pgfarrowssettipend{0.5\pgflinewidth}}, + drawing code={% + \pgfutil@tempdima=0.667\pgflinewidth% + \pgfsetdash{}{+0pt} + \pgfsetroundcap + \pgfsetroundjoin + \pgfpathmoveto{\pgfqpoint{-5.3\pgfutil@tempdima}{6\pgfutil@tempdima}} + \pgfpathcurveto + {\pgfqpoint{-4.5\pgfutil@tempdima}{2.5\pgfutil@tempdima}} + {\pgfqpoint{-2.133\pgfutil@tempdima}{0.6\pgfutil@tempdima}} + {\pgfpointorigin} + \pgfpathcurveto + {\pgfqpoint{-2.133\pgfutil@tempdima}{-0.6\pgfutil@tempdima}} + {\pgfqpoint{-4.5\pgfutil@tempdima}{-2.5\pgfutil@tempdima}} + {\pgfqpoint{-5.3\pgfutil@tempdima}{-6\pgfutil@tempdima}} + \pgfusepathqstroke}} + +\pgfdeclarearrow{, + name=cm bar, + setup code={% + \pgfarrowssetbackend{-0.5\pgflinewidth}% + \pgfarrowssettipend{0.5\pgflinewidth}}, + drawing code={% + \pgfsetdash{}{+0pt}% + \pgfsetroundcap% + \pgfpathmoveto{\pgfqpoint{0pt}{-4.1\pgflinewidth}}% + \pgfpathlineto{\pgfqpoint{0pt}{4.1\pgflinewidth}}% + \pgfusepathqstroke}} + +\pgfdeclarearrow{ + name=cm left hook, + setup code={% + \pgfarrowssetbackend{-0.5\pgflinewidth}% + \pgfarrowssettipend{3.5\pgflinewidth}}, + drawing code={% + \pgfsetdash{}{+0pt}% + \pgfsetroundcap% + \pgfpathmoveto{\pgfqpoint{0pt}{4.8\pgflinewidth}}% + \pgfpathcurveto% + {\pgfqpoint{4\pgflinewidth}{4.8\pgflinewidth}}% + {\pgfqpoint{4\pgflinewidth}{0pt}}% + {\pgfpointorigin}% + \pgfusepathqstroke}} + +\pgfdeclarearrow{ + name=cm *, + parameters={\ifpgfarrowopen o\fi}, + setup code={ + \pgfarrowssetbackend{-.5\pgflinewidth} + \pgfarrowssettipend{7.167\pgflinewidth}}, + drawing code={ + \pgfpathcircle{\pgfqpoint{3.333\pgflinewidth}{0pt}}{3.333\pgflinewidth} + \ifpgfarrowopen\pgfusepathqstroke\else\pgfusepathqfillstroke\fi}} + +\pgfdeclarearrow{ + name=lm left hook, + setup code={ + \pgfarrowssetbackend{+-2\pgflinewidth}% + \pgfarrowssettipend{+3.5\pgflinewidth}}, + drawing code={ + \pgfsetdash{}{+0pt} + \pgfsetroundcap + \pgfpathmoveto{\pgfqpoint{+-1.5\pgflinewidth}{+7\pgflinewidth}} + \pgfpathcurveto + {\pgfqpoint{+4.3\pgflinewidth}{+7\pgflinewidth}} + {\pgfqpoint{+4.3\pgflinewidth}{+\pgflinewidth}} + {\pgfpointorigin} + \pgfusepathqstroke}} + +\pgfdeclarearrow{ + name=lm bar, + setup code={% + \pgfarrowssetbackend{+-0.5\pgflinewidth}% + \pgfarrowssettipend{+0.5\pgflinewidth}}, + drawing code={% + \pgfsetdash{}{+0pt}% + \pgfsetroundcap% + \pgfpathmoveto{\pgfqpoint{0pt}{-6\pgflinewidth}}% + \pgfpathlineto{\pgfqpoint{0pt}{6\pgflinewidth}}% + \pgfusepathqstroke}} + +\pgfkeys{ + cm left to/.tip={cm to[left]}, + cm right to/.tip={cm to[right]}, + cm right hook/.tip={cm left hook[swap]}, + cm double to/.tip={cm to[sep=0pt -2.8]cm to}, + cm to reversed/.tip={cm to[reversed]}, + cm o/.tip={cm *[open]}, + cm |/.tip={cm bar}}%| + +% The `Glyph' meta arrow tip +\pgfqkeys{/pgf/arrow keys}{ + glyph math command/.code={\pgfarrowsaddtooptions{\def\tikzcd@glyph{$\csname #1\endcsname$}}}, + glyph axis/.code={\pgfarrowsaddtooptions{\pgfmathsetlengthmacro\tikzcd@glyph@axis{#1}}}, + glyph length/.code={\pgfarrowsaddtooptions{\pgfmathsetlengthmacro\tikzcd@glyph@len{#1}}}, + glyph shorten/.code={\pgfarrowsaddtooptions{\pgfmathsetlengthmacro\tikzcd@glyph@shorten{#1}}}} + +\pgfdeclarearrow{ + name=Glyph, + cache=false, + bending mode=none, + parameters={\tikzcd@glyph@len,\tikzcd@glyph@shorten}, + setup code={ + \pgfarrowssettipend{\tikzcd@glyph@len\advance\pgf@x by\tikzcd@glyph@shorten}}, + defaults={ + glyph axis=axis_height, + glyph length=+0.9ex, + glyph shorten=+-0.1ex}, + drawing code={ + \pgfpathrectangle{\pgfpoint{+0pt}{+-1ex}}{\pgfpoint{+\tikzcd@glyph@len}{+2ex}}% + \pgfusepathqclip% + \pgftransformxshift{+\tikzcd@glyph@len}% + \pgftransformyshift{+-\tikzcd@glyph@axis}% + \pgftext[right,base]{\tikzcd@glyph}}} + +% ConTeXt-specific stuff +\pgfutil@IfUndefined{starttikzpicture}{}{% + \def\starttikzcd{\tikzcd}% + \def\stoptikzcd{\endtikzcd}} + +% Generic arrow tip selection styles +\tikzcdset{ + arrow style/.initialize/.style={ + double line/.code={\tikzset{double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}}, + squiggly/.default={}, + tikzcd to/.tip={>}, + tikzcd bar/.tip={cm bar}, + tikzcd left hook/.tip={cm left hook}, + tikzcd right hook/.tip={tikzcd left hook[swap]}, + tikzcd left to/.tip={tikzcd to[harpoon]}, + tikzcd right to/.tip={tikzcd left to[swap]}, + tikzcd double to/.tip={tikzcd to[]tikzcd to}, + tikzcd to reversed/.tip={tikzcd to[reversed]}, + tikzcd cap/.tip={}, + tikzcd implies cap/.tip={}, + tikzcd implies/.tip={cm implies}}, + no tail/.code={\pgfsetarrowsstart{tikzcd cap}}, + to head/.code={\pgfsetarrowsend{tikzcd to}}, + maps to/.code={\pgfsetarrowsstart{tikzcd bar}}, + hook/.code={\pgfsetarrowsstart{tikzcd right hook}}, + hook'/.code={\pgfsetarrowsstart{tikzcd left hook}}, + harpoon/.code={\pgfsetarrowsend{tikzcd left to}}, + harpoon'/.code={\pgfsetarrowsend{tikzcd right to}}, + two heads/.code={\pgfsetarrowsend{tikzcd double to}}, + tail/.code={\pgfsetarrowsstart{tikzcd to reversed}}, + rightarrow/.code={\pgfsetarrows{tikzcd cap-tikzcd to}}, + Rightarrow/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}}, + leftarrow/.code={\pgfsetarrows{tikzcd to-tikzcd cap}}, + Leftarrow/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies-tikzcd implies cap}}, + leftrightarrow/.code={\pgfsetarrows{tikzcd to-tikzcd to}}, + Leftrightarrow/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies-tikzcd implies}}, + mapsto/.code={\pgfsetarrows{tikzcd bar-tikzcd to}}, + mapsfrom/.code={\pgfsetarrows{tikzcd to-tikzcd bar}}, + hookrightarrow/.code={\pgfsetarrows{tikzcd right hook-tikzcd to}}, + hookleftarrow/.code={\pgfsetarrows{tikzcd to-tikzcd left hook}}, + rightharpoonup/.code={\pgfsetarrows{tikzcd cap-tikzcd left to}}, + rightharpoondown/.code={\pgfsetarrows{tikzcd cap-tikzcd right to}}, + leftharpoonup/.code={\pgfsetarrows{tikzcd right to-tikzcd cap}}, + leftharpoondown/.code={\pgfsetarrows{tikzcd left to-tikzcd cap}}, + rightarrowtail/.code={\pgfsetarrows{tikzcd to reversed-tikzcd to}}, + leftarrowtail/.code={\pgfsetarrows{tikzcd to-tikzcd to reversed}}, + twoheadrightarrow/.code={\pgfsetarrows{tikzcd cap-tikzcd double to}}, + twoheadleftarrow/.code={\pgfsetarrows{tikzcd double to-tikzcd cap}}, + no head/.code={\pgfsetarrowsend{tikzcd cap}}, + dash/.code={\pgfsetarrows{tikzcd cap-tikzcd cap}}, + dashrightarrow/.code={\tikzcdset{rightarrow,dashed}}, + dashleftarrow/.code={\tikzcdset{leftarrow,dashed}}, + equal/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies cap-tikzcd implies cap}}, + equals/.code={\tikzcdset{equal}}, + rightsquigarrow/.code={\tikzcdset{rightarrow,squiggly}}, + leftsquigarrow/.code={\tikzcdset{leftarrow,squiggly}}, + leftrightsquigarrow/.code={\tikzcdset{leftrightarrow,squiggly}}, + squiggly/.code={% + \pgfutil@ifundefined{tikz@library@decorations.pathmorphing@loaded}% + {\pgfutil@packageerror{tikz-cd}{You need to say % + \string\usetikzlibrary{decorations.pathmorphing} to use squiggly arrows}{}}{}% + \pgfkeysalso{ + /tikz/decorate, + /tikz/decoration={ + zigzag, + 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 +\pgfkeysdef{/tikz/commutative diagrams/arrow style/Computer Modern}{% + \tikzcdset{ + arrow style/.initialize, + double line/.append code={\tikzset{double distance=3.85\pgflinewidth}}, + tikzcd to/.tip={cm to}, + tikzcd double to/.tip={cm double to}, + dashed/.style={/tikz/dash pattern={on 7\pgflinewidth off 4\pgflinewidth}}}} + +% The `Latin Modern' arrow style +\pgfkeysdef{/tikz/commutative diagrams/arrow style/Latin Modern}{% + \tikzcdset{ + arrow style=Computer Modern, + tikzcd left hook/.tip={lm left hook}, + tikzcd bar/.tip={lm bar}}} + +% The `math font' arrow style +% +% The method used to guess the correct value of `double distance' +% inside the `double line' style is not robust at all. If it fails, +% set +% \tikzcdset{double line/.append style={double distance=2*rule_thickness}} +% and find the correct value for `double distance' by trial and error +% (or measure the distance between the \Rightarrow stems in a font +% editor). +\pgfkeysdef{/tikz/commutative diagrams/arrow style/math font}{% + \pgfutil@IfUndefined{mapsfrom} + {\def\tikzcd@mapsfrom{\pgfpicture\pgfsetbaseline{+0pt}\pgftransformxscale{-1}\pgftext[base]{$\mapsto$}\endpgfpicture}} + {\def\tikzcd@mapsfrom{\mapsfrom}} + \tikzcdset{ + arrow style/.initialize, + tikzcd to/.tip={Glyph[glyph math command=rightarrow]}, + tikzcd cap/.tip={Glyph[glyph math command=leftarrow]}, + tikzcd to reversed/.tip={Glyph[glyph math command=leftarrowtail]}, + tikzcd bar/.tip={Glyph[glyph math command=tikzcd@mapsfrom]}, + tikzcd left hook/.tip={Glyph[glyph math command=hookleftarrow]}, + tikzcd right hook/.tip={Glyph[glyph math command=hookleftarrow, swap]}, + tikzcd implies/.tip={Glyph[glyph math command=Rightarrow, glyph length=1.2ex]}, + tikzcd implies cap/.tip={Glyph[glyph math command=Leftarrow]}, + tikzcd double to/.tip={Glyph[glyph math command=twoheadrightarrow, glyph length=1.4ex]}, + tikzcd left to/.tip={Glyph[glyph math command=rightharpoonup]}, + tikzcd right to/.tip={Glyph[glyph math command=rightharpoonup,swap]}, + double line/.append code={\tikzset{double distance={2*(height("$=$")-axis_height-rule_thickness)}}}, + dashed/.code={\tikzset{dash pattern=on 0.8ex off 0.4ex, dash phase=0.8ex}}, + squiggly/.default={pre length=1ex, post length=1ex}}} + +% The `arrows.meta' arrow style +\pgfkeysdef{/tikz/commutative diagrams/arrow style/arrows.meta}{% + \pgfutil@ifundefined{tikz@library@arrows.meta@loaded}% + {\pgfutil@packageerror{tikz-cd}{You need to say % + \string\usetikzlibrary{arrows.meta} to use the `arrows.meta' arrow style}{}}{}% + \tikzcdset{ + arrow style/.initialize, + double line/.append style={/tikz/double equal sign distance}, + tikzcd bar/.tip={Bar}, + tikzcd left hook/.tip={Hooks[harpoon]}, + tikzcd implies/.tip={Implies}, + dashed/.style={/tikz/dashed}}} + +% The `tikz' arrow style +\pgfkeysdef{/tikz/commutative diagrams/arrow style/tikz}{% + \pgfutil@ifundefined{tikz@library@arrows@loaded}% + {\pgfutil@packageerror{tikz-cd}{You need to say % + \string\usetikzlibrary{arrows} to use the `tikz' arrow style}{}}{}% + \tikzcdset{ + arrow style/.initialize, + double line/.append style={/tikz/double equal sign distance}, + tikzcd bar/.tip={|},%| + tikzcd left hook/.tip={left hook}, + tikzcd left to/.tip={left to}, + tikzcd implies/.tip={implies}, + dashed/.style={/tikz/dashed}}} + +% Default settings +\tikzcdset{ + every arrow/.style={ + /tikz/draw, + /tikz/line width=rule_thickness, + /tikz/commutative diagrams/rightarrow}, + every label/.style={ + /tikz/auto, + /tikz/font=\everymath\expandafter{\the\everymath\scriptstyle}, + /tikz/inner sep=+0.5ex}, + every cell/.style={ + /tikz/shape={asymmetrical rectangle}, + /tikz/inner xsep=+1ex, + /tikz/inner ysep=+0.85ex}, + every matrix/.style={/tikz/inner sep=+0pt}, + every diagram/.style={ + /tikz/commutative diagrams/row sep=normal, + /tikz/commutative diagrams/column sep=normal, + /tikz/baseline=+0pt}, + arrow style=Computer Modern, + 1-row diagram/.style={/tikz/baseline=(\tikzcdmatrixname.base)}, + math mode=true, + center yshift/.initial=axis_height, + row sep/huge/.initial=+3.6em, + row sep/large/.initial=+2.7em, + row sep/normal/.initial=+1.8em, + row sep/scriptsize/.initial=+1.35em, + row sep/small/.initial=+0.9em, + row sep/tiny/.initial=+0.45em, + column sep/huge/.initial=+4.8em, + column sep/large/.initial=+3.6em, + column sep/normal/.initial=+2.4em, + column sep/scriptsize/.initial=+1.8em, + column sep/small/.initial=+1.2em, + column sep/tiny/.initial=+0.6em, + crossing over clearance/.initial=+1.5ex, + shift left/.default=+0.56ex, + shift right/.default=1, + background color/.initial=white} + +\endinput |