From 3096e54f272c662e1d3c9339395a1df3055e5b43 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 21 Dec 2012 00:14:00 +0000 Subject: tikz-cd (20dec12) git-svn-id: svn://tug.org/texlive/trunk@28588 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/tikz-cd/README | 17 +- .../texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf | Bin 186971 -> 193655 bytes .../texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex | 338 +++++++++++--------- Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty | 355 +++++++++++---------- 4 files changed, 373 insertions(+), 337 deletions(-) diff --git a/Master/texmf-dist/doc/latex/tikz-cd/README b/Master/texmf-dist/doc/latex/tikz-cd/README index 20641c6f4ac..0c3873a9930 100644 --- a/Master/texmf-dist/doc/latex/tikz-cd/README +++ b/Master/texmf-dist/doc/latex/tikz-cd/README @@ -1,9 +1,12 @@ -Package Name: tikz-cd +tikz-cd -- Commutative diagrams with tikz +========================================= -Author Name: Florêncio Neves +The general-purpose drawing package tikz can be used to typeset +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. -License: LaTeX Project Public License and/or GNU Public License. - -Description: This package provides a set of macros to create -commutative diagrams and other kinds of mathematical pictures using -tikz. +This software is distributed under the GNU General Public License, +version 3 or later. \ No newline at end of file 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 index 5452689516b..7a32f482baf 100644 Binary files a/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf and b/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf differ 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 ff1d644491e..89b0ecb769b 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,14 +1,29 @@ % Copyright 2011, 2012 by Florêncio Neves % -% This file may be distributed and/or modified -% -% 1. under the LaTeX Project Public License and/or -% 2. under the GNU Public License. +% 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 . % % 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 +% 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} @@ -1063,7 +1078,7 @@ vv \fi% \fi \begingroup - \catcode`|=0 + \catcode`|=0%| \catcode`[= 1 \catcode`]=2 \catcode`\{=12 @@ -1316,7 +1331,7 @@ vv \fi% inner ysep=0.5cm} } -\usepackage{iftex,tikz-cd} +\usepackage{iftex,tikz-cd,xr} \ifLuaTeX \usepackage{fontspec} \else @@ -1327,12 +1342,14 @@ vv \fi% pdftitle={The tikz-cd package}, pdfauthor={Florêncio Neves}, pdfkeywords={commutative diagrams, latex, tikz, pgf}, - colorlinks + colorlinks, } + +\externaldocument[pgfman-]{pgfmanual} \title{The \texttt{tikz-cd} package} -\author{\normalsize Florêncio Neves\footnote{\emph{E-mail:} \href{mailto:florencioneves@gmail.com}{\texttt{florencioneves@gmail.com}}}} -\date{\normalsize Version 0.3a, of August 15, 2012} +\author{Florêncio Neves\footnote{\emph{E-mail:} \href{mailto:florencioneves@gmail.com}{\texttt{florencioneves@gmail.com}}}} +\date{Version 0.3b, of December 19, 2012} \tikzset{commutative diagrams/background color=graphicbackground} @@ -1348,7 +1365,7 @@ vv \fi% 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}). This package facilitates the creation of such diagrams +\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. @@ -1368,6 +1385,11 @@ 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. +% 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. + \subsection{Inserting arrows} \label{sec:inserting-arrows} @@ -1384,7 +1406,7 @@ placed on an arrow by providing a second argument. \end{codeexample} You can control the appearance of the arrow by placing an argument -inside square braces before the direction parameter. It may contain +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 @@ -1392,9 +1414,9 @@ passed to \tikzname's |node| operator. \begin{codeexample}[] \begin{tikzcd} A \arrow{r}{\psi} \arrow[color=red]{d} - & B \arrow{d}[color=red]{\psi} \\ + & B \arrow{d}[color=red]{\psi} \\ C \arrow[color=red]{r}[color=blue]{\eta} - & D + & D \end{tikzcd} \end{codeexample} @@ -1424,13 +1446,12 @@ To save typing, the command |\ar| is provided as a shorthand to argument in square braces to modify the arrow, followed by label specifiers of the form |{|\meta{text}|}| or |[|\meta{options}|]{|\meta{text}|}|. -Thus, the diagram above can be rewritten as follows. \begin{codeexample}[] \begin{tikzcd} - A \drar \rar{\psi} \dar[color=red] - & B \dar[][color=red]{\psi} \\ - C \rar[color=red][color=blue]{\eta} - & D + 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} @@ -1443,8 +1464,10 @@ user's guide. \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} & Z + & X \times_Z Y \arrow{r}{p} \arrow{d}{q} + & X \arrow{d}{f} \\ + & Y \arrow{r}{g} + & Z \end{tikzcd} \end{codeexample} @@ -1508,7 +1531,7 @@ that they can be superimposed with other arrows. \end{tikzcd} \end{codeexample} -It is also possible to select arrow tips using the \tikzname{} |arrow| +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 @@ -1638,28 +1661,8 @@ too tall if the column or row separation were not set appropriately. \end{tikzcd} \end{codeexample} -The commands below are available only inside a |tikzcd| and are -intended to be used as arguments to |&| and |\\| when spacing -adjustments are necessary (see also \cite[\S17.3.2]{pgfman}). -\begin{command}{\colsep\marg{size}} - Returns the value - stored by the key |/tikz/commutative diagrams/column sep/|\meta{size}. -\end{command} -\begin{command}{\rowsep\marg{size}} - Returns the value - stored by the key |/tikz/commutative diagrams/row sep/|\meta{size}. -\end{command} - -In the following example, $X$ would appear too far from the square -without any spacing adjustment. -\begin{codeexample}[] -\begin{tikzcd} - X \ar[bend right]{rdd} \ar[bend left]{rrd} \ar[dashed]{dr} - &[\colsep{small}-\colsep{normal}] & \\[\rowsep{small}-\rowsep{normal}] - & A \ar{r}\ar{d} & B \ar{d} \\ - & C \ar{r} & D -\end{tikzcd} -\end{codeexample} +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)} @@ -1678,11 +1681,13 @@ without any spacing adjustment. \subsection{Options for arrows} \label{sec:options-arrows} -Besides the options and styles provided by this package, there are -several keys defined by \tikzname{} that 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{pgfman}. +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 @@ -1723,7 +1728,7 @@ some additional tasks, such as setting the line width. 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[\S23]{pgfman}), and adjusting |/tikz/line width| if necessary. +\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. @@ -1741,52 +1746,70 @@ instructive. \end{tikzcd} \end{codeexample} -\begin{key}{/tikz/commutative diagrams/start anchor=\meta{anchor}} - This key specifies at which anchor of the current node the arrow - should start. +The following set of options allow fine-tuning the placement of +arrows. + +\begin{key}{/tikz/commutative diagrams/shift={\ttfamily\char`\{}\meta{coordinate}{\ttfamily\char`\}}} + Shifts arrows by \meta{coordinate}. \end{key} -\begin{key}{/tikz/commutative diagrams/end anchor=\meta{anchor}} - This key specifies at which anchor of the target node the arrow - should arrive. +\begin{key}{/tikz/commutative diagrams/xshift=\meta{dimension}} + Shifts arrows right by \meta{dimension}. \end{key} -% % | As it stands this is not immensely useful, so it will be left -% % | undocumented while something better doesn't appear. -% % V +\begin{key}{/tikz/commutative diagrams/yshift=\meta{dimension}} + Shifts arrows up by \meta{dimension}. +\end{key} -% -% \begin{key}{/tikz/commutative diagrams/start anchor=\ooarg{coordinate transformations}\meta{anchor}} -% This key specifies at which anchor of the current node the arrow -% should start. Optionally, additional coordinate transformations can -% be supplied. An empty argument causes no anchor to be specified. -% \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} +\end{codeexample} -% \begin{key}{/tikz/commutative diagrams/end anchor=\ooarg{coordinate transformations}\meta{anchor}} -% This key works analogously, but refers to the target node of the arrow. -% \end{key} +\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. +\end{key} -% See the picture on \S\ref{sec:asymm-rect-shape} for some of the -% possible values for \meta{anchor}. The picture below shows how -% \texttt{end anchor} and \texttt{start anchor} can be used to fine-tune -% the placement of arrows. +\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. +\end{key} -% \begin{codeexample}[] -% \begin{tikzcd} -% X_0 -% \rar[to-, start anchor={[yshift=0.5ex]east}, end anchor={[yshift=0.5ex]west}] -% \rar[to-, start anchor={[yshift=-0.5ex]east}, end anchor={[yshift=-0.5ex]west}] & -% X_1 -% \rar[to-, start anchor={[yshift=1ex]east}, end anchor={[yshift=1ex]west}] -% \rar[to-] -% \rar[to-, start anchor={[yshift=-1ex]east}, end anchor={[yshift=-1ex]west}] & -% X_2 -% \rar[to-, start anchor={[yshift=1.5ex]east}, end anchor={[yshift=1.5ex]west}] -% \rar[draw=none][anchor=base,yshift=-1ex]{\vdots} -% \rar[to-, start anchor={[yshift=-1.5ex]east}, end anchor={[yshift=-1.5ex]west}] & -% \cdots -% \end{tikzcd} -% \end{codeexample} +\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} +\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 + should start. Optionally, additional coordinate transformations can + be supplied. An empty argument causes no anchor to be specified. +\end{key} + +\begin{key}{/tikz/commutative diagrams/end anchor=\opt{{\ttfamily\char`\{}\ooarg{coordinate transformations}}\meta{anchor}\opt{\ttfamily\char`\}}} + This key works analogously, but refers to the target node of the arrow. +\end{key} + +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, + start anchor={[xshift=-1ex]}, + end anchor={[yshift=2ex]north east}]{r} + & B +\end{tikzcd} +\end{codeexample} \begin{stylekey}{/tikz/commutative diagrams/crossing over} This style makes a thicker line, with color @@ -1804,14 +1827,18 @@ instructive. Note that, since arrows are drawn in the order they are read, some arrows may need to run ``backwards'' to achieve the desired result. -The following picture, adapted from \cite{lenders}, illustrates this. +%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}. \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} \\ + M \arrow{rr} & & N\arrow[crossing over, leftarrow]{uu}\\ \end{tikzcd} \end{codeexample} @@ -1830,7 +1857,8 @@ 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{pgfman}. + 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 @@ -1907,11 +1935,11 @@ 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 added to +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[commutative diagrams/every arrow, |\meta{path options}|]|\\ + | (| \meta{current node}|) to |\meta{labels}| (|\meta{target~node}|);| \end{quote} Here, \meta{current node} is the node corresponding to the matrix cell @@ -1937,75 +1965,60 @@ effect. \label{sec:tweaking-to-paths} Recall that the |to| path operation used in the paths created by -|\arrow| can take a number of options, as described in \S{}14.14 -and \S{}51 of the \pgfname{} manual~\cite{pgfman}. In particular, the +|\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 can be used to do all sorts of fiddling. \begin{codeexample}[] \begin{tikzcd} - A \arrow[dashed, to path=|- (\tikztotarget)]{dr} - \arrow[to path={..controls +(1.5,0.5) and +(-1,0.8).. (\tikztotarget)}]{dr} + A \arrow[controls={+(1.5,0.5) and +(-1,0.8)}]{dr} + \arrow[dashed, to path=|- (\tikztotarget)]{dr} & \\ & B \arrow[loop right]{} \end{tikzcd} \end{codeexample} -A common use case is to produce parallel arrows. - +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. \begin{codeexample}[] \begin{tikzcd} - X_0 - \rar[to-, - to path={ - ([yshift=0.5ex]\tikztostart.east) -- - ([yshift=0.5ex]\tikztotarget.west) \tikztonodes}]{d_0} - \rar[to-, - to path={ - ([yshift=-0.5ex]\tikztostart.east) -- - ([yshift=-0.5ex]\tikztotarget.west) \tikztonodes}][swap]{d_1} - & X_1 + 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} + & F \end{tikzcd} \end{codeexample} -Whenever one starts using long options repeatedly, it might be a good -idea to define a new style. In the example below, this is done with -the statement |shift up/.style={| \dots\ |}| inside |\tikzset|. -Styles can take one argument, which replaces all occurrences of |#1| in -its definition. - +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}[] -\tikzset{ - shift up/.style={ - to path={([yshift=#1]\tikztostart.east) -- ([yshift=#1]\tikztotarget.west) \tikztonodes} - } -} - \begin{tikzcd} - X_0 - \rar[to-, shift up=0.5ex] - \rar[to-, shift up=-0.5ex] & - X_1 - \rar[to-, shift up=1ex] - \rar[to-] - \rar[to-, shift up=-1ex] & - X_2 - \rar[to-, shift up=1.5ex] - \rar[draw=none][anchor=base,yshift=-1ex]{\vdots} - \rar[to-, shift up=-1.5ex] & - \cdots + 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} - -In the next example, empty labels are used to create nodes for later -reference, and in the third |\arrow| command the |to path| key is used -in a way that, in the terminology of the previous section, -\meta{current node} and \meta{target node} are completely ignored. \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)]{} + \arrow[bend right=50]{r}[name=D]{} + & B + \arrow[Rightarrow,to path=(U) -- (D)]{} \end{tikzcd} \end{codeexample} @@ -2049,6 +2062,19 @@ how this can be done (the second one is adapted from \cite{milne}). \end{tikzpicture} \end{codeexample} +\subsection{Issues with active ampersand} +\label{sec:issues-with-active-ampersand} + +By default, \tikzname{} makes the character |&| active inside +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| +with the option |ampersand replacement=\&|, and replace all +occurrences of |&| with |\&| in the diagram. + \section{Additional goodies} \label{sec:general-infra} @@ -2080,9 +2106,9 @@ the numerical anchors. The anchors \texttt{real center}, \texttt{real \node[name=s,shape=asymmetrical rectangle,shape example] {Asymmetrical rectangle\vrule width 1pt height 2cm}; \foreach \anchor/\placement in {north west/above left, north/above, north - east/above right, west/left, center/above, east/right, real - west/left, real center/above, real east/right, base west/left, - base/below, base east/right, south west/below left, south/below, + east/above right, west/left, center/right, east/right, real + west/left, real center/right, real east/right, base west/left, + base/right, base east/right, south west/below left, south/below, south east/below right, text/left, 10/right, 130/above, 230/below, -10/below} \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{\anchor}}; @@ -2121,13 +2147,13 @@ Returns the fraction rule thickness of the document's math font. The naming scheme of the Computer Modern-like arrow tips provided by this package parallels that of \pgfname's |arrows| library, documented -in \S{}23 of the \pgfname{} manual~\cite{pgfman}. To match the Computer Modern +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. 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 use the arrow tips listed in this section +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 @@ -2199,7 +2225,7 @@ Here are some samples: \begin{tikzpicture} \node[draw=gray,name=P]{ \begin{minipage}[t]{0.25\linewidth}\centering - \setmainfont{TG Pagella Math} + \setmainfont{texgyrepagella-math.otf} \tikzset{commutative diagrams/.cd, arrow style=math font, default arrow/.append style={line width=0.6pt}, @@ -2210,7 +2236,7 @@ Here are some samples: declare head={math double to}{↠}{2.5pt}{1.4ex}, } \begin{tikzcd}[math mode=false] - \ar[bend right]{rr}\rar[hook]% + \relax\ar[bend right]{rr}\rar[hook]% 𝐴\pgfmatrixnextcell 𝐵\rar[two heads]% \pgfmatrixnextcell 𝐶 \end{tikzcd}\\ @@ -2218,7 +2244,7 @@ Here are some samples: \end{minipage}}; \node[draw=gray,name=Q,right=5mm of P]{ \begin{minipage}[t]{0.25\linewidth}\centering - \setmainfont{XITS Math} + \setmainfont{STIXGeneral.otf} \tikzset{commutative diagrams/.cd, arrow style=math font, default arrow/.append style={line width=0.66pt}, @@ -2229,15 +2255,15 @@ Here are some samples: declare head={math double to}{↠}{2.5pt}{1.4ex}, } \begin{tikzcd}[math mode=false] - \ar[bend right]{rr}\rar[hook]% + \relax\ar[bend right]{rr}\rar[hook]% 𝐴\pgfmatrixnextcell 𝐵\rar[two heads]% \pgfmatrixnextcell 𝐶 \end{tikzcd}\\ - XITS Math + STIX \end{minipage}}; \node[draw=gray,name=R,right=5mm of Q]{ \begin{minipage}[t]{0.25\linewidth}\centering - \setmainfont{euler.otf} + \setmainfont{lmodern-math.otf} \tikzset{commutative diagrams/.cd, arrow style=math font, default arrow/.append style={line width=0.4pt}, @@ -2248,11 +2274,11 @@ Here are some samples: declare head={math double to}{↠}{2.5pt}{1.4ex}, } \begin{tikzcd}[math mode=false] - \ar[bend right]{rr}\rar[hook]% - A\pgfmatrixnextcell B\rar% - \pgfmatrixnextcell C + \relax\ar[bend right]{rr}\rar[hook]% + 𝐴\pgfmatrixnextcell 𝐵\rar[two heads]% + \pgfmatrixnextcell 𝐶 \end{tikzcd}\\ - Neo Euler + Latin Modern \end{minipage}}; \end{tikzpicture} \end{center} @@ -2306,7 +2332,7 @@ want to use double lines. \bibitem{pgfman} Till Tantau, \emph{The \tikzname{} and \pgfname{} packages: Manual for version 2.10}. - Available at \url{http://sourceforge.net/projects/pgf}. + Available at \url{http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}. \end{thebibliography} \end{document} 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 70839da0abb..e9879efa00b 100644 --- a/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty +++ b/Master/texmf-dist/tex/latex/tikz-cd/tikz-cd.sty @@ -1,21 +1,27 @@ % Copyright 2011, 2012 by Florêncio Neves % -% This file may be distributed and/or modified -% -% 1. under the LaTeX Project Public License and/or -% 2. under the GNU Public License. -% -\ProvidesPackage{tikz-cd}[2012/08/15 v0.3a Commutative diagrams with tikz.] -\RequirePackage{tikz}[2010/10/13] %pgf version 2.10 required +% 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 . + +\ProvidesPackage{tikz-cd}[2012/12/19 v0.3b Commutative diagrams with tikz.] +\RequirePackage{tikz}[2010/10/13] % pgf version 2.10 required \usetikzlibrary{matrix} \newif\iftikzcd@mathmode -\newcount\tikzcd@targetrow -\newcount\tikzcd@targetcol \pgfqkeys{/tikz/commutative diagrams}{ - /tikz/commutative diagrams/.search also={/tikz}, + .search also={/tikz}, arrows/.style={ /tikz/commutative diagrams/every arrow/.append style={#1}}, labels/.style={ @@ -29,8 +35,7 @@ /tikz/preaction={ /tikz/draw=\pgfkeysvalueof{/tikz/commutative diagrams/background color}, /tikz/arrows=-, - /tikz/line width=% - \pgfkeysvalueof{/tikz/commutative diagrams/crossing over clearance}}}, + /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, @@ -39,18 +44,11 @@ /tikz/nodes={ execute at begin node=\iftikzcd@mathmode$\fi, %$ execute at end node=\iftikzcd@mathmode$\fi}}, %$ - start anchor/.code={% - \tikzcd@threefold{\tikzcd@setanchor{start}}{}% - {\tikzcd@setanchor{start}[]}#1\relax},% - end anchor/.code={% - \tikzcd@threefold{\tikzcd@setanchor{end}}{}% - {\tikzcd@setanchor{end}[]}#1\relax},% arrow style/.is choice} % generic arrow tip selection styles -\pgfqkeys{/tikz/commutative diagrams}{ - arrow style/generic/.style={ - /tikz/commutative diagrams/.cd, +\pgfkeysdef{/tikz/commutative diagrams/arrow style/generic}{% + \pgfqkeys{/tikz/commutative diagrams}{ rightarrow/.style={/tikz/arrows=-#1 to}, Rightarrow/.style={ /tikz/arrows=-#1 implies, @@ -63,56 +61,61 @@ 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 |}, + 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-}, - dashrightarrow/.style={ - /tikz/arrows=-#1 to, - /tikz/commutative diagrams/dashed}, - dashleftarrow/.style={ - /tikz/arrows=#1 to-, - /tikz/commutative diagrams/dashed}, rightarrowtail/.style={/tikz/arrows=#1 to reversed-#1 to}, leftarrowtail/.style={/tikz/arrows=#1 to-#1 to reversed}, twoheadrightarrow/.style={/tikz/arrows=-#1 double to}, twoheadleftarrow/.style={/tikz/arrows=#1 double to-}, - dash/.style={/tikz/arrows=-}, - equal/.style={ - /tikz/arrows=-, - /tikz/commutative diagrams/double line}, - maps to/.code={\pgfsetarrowsstart{#1 |}}, + maps to/.code={\pgfsetarrowsstart{#1 |}},%| hook/.code={\pgfsetarrowsstart{#1 right hook}}, two heads/.code={\pgfsetarrowsend{#1 double to}}, - tail/.code={\pgfsetarrowsstart{#1 to reversed}}}, + 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/.cd,rightarrow,squiggly}, - leftsquigarrow/.style={/tikz/commutative diagrams/.cd,leftarrow,squiggly}, + /tikz/commutative diagrams/rightarrow, + /tikz/commutative diagrams/squiggly}, + leftsquigarrow/.style={ + /tikz/commutative diagrams/leftarrow, + /tikz/commutative diagrams/squiggly}, leftrightsquigarrow/.style={ - /tikz/commutative diagrams/.cd,leftrightarrow,squiggly}, + /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}, - squiggly/.append style={ - decorate, - decoration={ - zigzag, - segment length=9.25\pgflinewidth, - amplitude=1.9\pgflinewidth, - post=lineto, post length=6\pgflinewidth, - pre=lineto, pre length=6\pgflinewidth, - #1}}} + \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 -\pgfqkeys{/tikz/commutative diagrams/arrow style}{ - computer modern/.style={ - /tikz/commutative diagrams/.cd, +\pgfkeysdef{/tikz/commutative diagrams/arrow style/computer modern}{% + \pgfqkeys{/tikz/commutative diagrams}{ arrow style/generic={cm}, default arrow/.style={ /tikz/line join=round, @@ -124,50 +127,26 @@ dashed/.style={/tikz/dash pattern={on 7\pgflinewidth off 4\pgflinewidth}}}} % The tikz arrow style -\pgfqkeys{/tikz/commutative diagrams/arrow style}{ - tikz/.code={% - \expandafter\ifx\csname tikz@library@arrows@loaded\endcsname\pgfutil@empty% - \else\PackageError{tikz-cd}{You need to say \string\usetikzlibrary{arrows} % - to use the `tikz' arrow style}{}\fi}, - tikz/.append style={ - /tikz/commutative diagrams/.cd, - default arrow/.style={/tikz/arrows=->}, +\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=->}, - Rightarrow/.style={ - /tikz/arrows=-implies, - /tikz/commutative diagrams/double line}, leftarrow/.style={/tikz/arrows=<-}, - Leftarrow/.style={ - /tikz/arrows=implies-, - /tikz/commutative diagrams/double line}, leftrightarrow/.style={/tikz/arrows=<->}, - Leftrightarrow/.style={ - /tikz/arrows=implies-implies, - /tikz/commutative diagrams/double line}, - mapsto/.style={/tikz/arrows=|->}, - mapsfrom/.style={/tikz/arrows=<-|}, + mapsto/.style={/tikz/arrows=|->},%| + mapsfrom/.style={/tikz/arrows=<-|},%| hookrightarrow/.style={/tikz/arrows=right hook->}, hookleftarrow/.style={/tikz/arrows=<-left hook}, - rightharpoonup/.style={/tikz/arrows=-left to}, - rightharpoondown/.style={/tikz/arrows=-right to}, - leftharpoonup/.style={/tikz/arrows=right to-}, - leftharpoondown/.style={/tikz/arrows=left to-}, - dashrightarrow/.style={/tikz/arrows=->,/tikz/commutative diagrams/dashed}, - dashleftarrow/.style={/tikz/arrows=<-,/tikz/commutative diagrams/dashed}, rightarrowtail/.style={/tikz/arrows=>->}, leftarrowtail/.style={/tikz/arrows=<-<}, twoheadrightarrow/.style={/tikz/arrows=->>}, twoheadleftarrow/.style={/tikz/arrows=<<-}, %>> - dash/.style={/tikz/arrows=-}, - equal/.style={ - /tikz/arrows=-, - /tikz/commutative diagrams/double line}, - maps to/.code={\pgfsetarrowsstart{|}}, - hook/.code={\pgfsetarrowsstart{right hook}}, - two heads/.code={ - \pgfsetarrowsend{\csname tikz@special@arrow@end>>\endcsname}}, - tail/.code={ - \pgfsetarrowsstart{\csname tikz@special@arrow@start>\endcsname}}, + 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, @@ -176,16 +155,14 @@ % Default settings \pgfqkeys{/tikz/commutative diagrams}{ every arrow/.style={ - /handlers/first char syntax/the character "/.initial=\tikzcd@passquotes, - /tikz/edge quotes mean/.try={edge node={node [/tikz/commutative diagrams/every label,##2]{\tikzcd@mathmaybe{##1}}}}, /tikz/commutative diagrams/.cd, + @enablequotes, /tikz/draw, - /tikz/commutative diagrams/default arrow}, + default arrow}, every label/.style={ /tikz/commutative diagrams/.cd, /tikz/auto, /tikz/font=\everymath\expandafter{\the\everymath\scriptstyle}, - % replace by \everymath{\scriptstyle} for plain TeX /tikz/inner sep=0.5ex}, every diagram/.style={ /tikz/commutative diagrams/.cd, @@ -193,9 +170,9 @@ row sep=normal, column sep=normal, /tikz/baseline=0pt}, + 1-row diagram/.style={/tikz/baseline=(#1.base)}, math mode=true, center yshift/.initial=tikzcdaxis, - center shift/.style={/tikz/commutative diagrams/center yshift=#1}, % this has been renamed row sep/huge/.initial=10ex, row sep/large/.initial=7.5ex, row sep/normal/.initial=5ex, @@ -209,8 +186,6 @@ column sep/small/.initial=3ex, column sep/tiny/.initial=1.5ex, arrow style=computer modern, - description clearance/.code={% - \PackageWarning{tikz-cd}{The `description clearance' key has been deprecated}{}}, crossing over clearance/.initial=1.5ex, background color/.initial=white} @@ -293,67 +268,61 @@ }% }% -% Branch depending on whether the next character is [, { or none of those. -\def\tikzcd@threefold#1#2#3{% - \def\tikzcd@tempa{#1}% - \def\tikzcd@tempb{#2}% - \def\tikzcd@tempc{#3}% - \futurelet\next\tikzcd@@threefold} - -\def\tikzcd@@threefold{% - \ifx[\next\let\tikzcd@tempc\tikzcd@tempa% - \else\ifx\bgroup\next\let\tikzcd@tempc\tikzcd@tempb\fi\fi% - \tikzcd@tempc} - -%The arrow commands -\def\tikzcd@arrow{\tikzcd@threefold{\tikzcd@ar@getdir}{\tikzcd@ar@getdir[]}{}} +% The arrow commands +\def\tikzcd@arrow{% + \begingroup% + \pgfutil@ifnextchar[{\tikzcd@ar@getdir}{\tikzcd@ar@getdir[]}} \def\tikzcd@ar@getdir[#1]#2{% - \tikzcd@targetrow\pgfmatrixcurrentrow% - \tikzcd@targetcol\pgfmatrixcurrentcolumn% + \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 }% - \tikzcd@threefold{\tikzcd@ar@getlabel}{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}} + \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}}}% - \tikzcd@threefold{\tikzcd@ar@getlabel}{\tikzcd@ar@getlabel[]}{\tikzcd@ar@final}} + \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\tikzcd@targetrow-\the\tikzcd@targetcol% - \noexpand\tikzcd@endanchor); }} + (\tikzmatrixname-\the\c@pgf@counta-\the\c@pgf@countb\noexpand\tikzcd@endanchor); }% + \endgroup}% restore pgf counters -\def\tikzcd@xar#1{\tikzcd@threefold{\tikzcd@@xar{#1}}{\tikzcd@arrow[]{#1}}{\tikzcd@arrow[]{#1}}} +\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@tempa{\tikzcd@parse}% - \ifx#1r\advance\tikzcd@targetcol by1\else% - \ifx#1d\advance\tikzcd@targetrow by1\else% - \ifx#1l\advance\tikzcd@targetcol by-1\else% - \ifx#1u\advance\tikzcd@targetrow by-1\else% - \ifx#1\relax\let\tikzcd@tempa\empty% + \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 l, r, u or d}{}\fi\fi\fi\fi\fi% - \tikzcd@tempa} + only the characters u, d, l, r}{}\fi\fi\fi\fi\fi% + \tikzcd@temp} -% `quotes' library support (see also `every arrow' style) +% `quotes' library support \def\tikzcd@passquotes#1{\tikzset{every to/.append style={#1}}} -% start anchor, end anchor keys +\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{% - \pgfkeysdef{/tikz/tikzcd@#1transform}{\tikzset{#2}}% \ifx\relax#2\relax\else% - \tikzset{to path={([tikzcd@starttransform]\tikztostart) % - -- ([tikzcd@endtransform]\tikztotarget) \tikztonodes}}% + \pgfqkeys{/tikz/commutative diagrams}{@#1transform/.append style={#2},@shiftabletopath}% \fi% \ifx\relax#3\relax% \expandafter\let\csname tikzcd@#1anchor\endcsname\empty% @@ -361,22 +330,56 @@ \expandafter\def\csname tikzcd@#1anchor\endcsname{.#3}% \fi} -\pgfqkeys{/tikz/commutative diagrams}{start anchor=,end anchor=} - -% The tikzcd environment -\def\tikzcd{\tikzcd@threefold{\tikzcd@}{\tikzcd@[]}{\tikzcd@[]}} +\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]% - \tikzcd@initialize% - \matrix[/tikz/commutative diagrams/matrix of math nodes maybe]\bgroup} - -\def\endtikzcd{% - \pgfmatrixendrow\egroup;% - \tikzcd@finalize% - \endtikzpicture} - -\def\tikzcd@initialize{% \def\arrow{\tikzcd@arrow}% \def\ar{\tikzcd@arrow}% \def\rar{\tikzcd@xar{r}}% @@ -387,20 +390,26 @@ \def\ular{\tikzcd@xar{ul}}% \def\drar{\tikzcd@xar{dr}}% \def\dlar{\tikzcd@xar{dl}}% - \def\rowsep##1{\pgfkeysvalueof{/tikz/commutative diagrams/row sep/##1}}% - \def\colsep##1{\pgfkeysvalueof{/tikz/commutative diagrams/column sep/##1}}% - \global\let\tikzcd@savedpaths\empty} + \global\let\tikzcd@savedpaths\empty + \matrix[/tikz/commutative diagrams/matrix of math nodes maybe]\bgroup} -\def\tikzcd@finalize{\tikzcd@savedpaths} +\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}% - {\tikzset{#1 sep=\pgfkeysvalueof{/tikz/commutative diagrams/#1 sep/#2}}}% - {\tikzset{#1 sep=#2}}} + {\pgfkeysalso{/tikz/#1 sep=\pgfkeysvalueof{/tikz/commutative diagrams/#1 sep/#2}}}% + {\pgfkeysalso{/tikz/#1 sep=#2}}} -%Computer modern arrow tips +% Computer modern arrow tips \pgfarrowsdeclare{cm to}{cm to} { \pgfarrowsleftextend{-5.833\pgflinewidth} @@ -611,28 +620,26 @@ \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) - -\tikzset{ - /tikz/commutative diagrams/enable font arrows/.code={% - % 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}}}% - }{}}, - /tikz/commutative diagrams/font arrows/.cd, +% 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}}, -} + declare tail/.code n args={4}{\tikzcd@arrowsdeclare{#1}{#2}{#3}{#4}{\iffalse}}} % #1 = name % #2 = command @@ -653,8 +660,8 @@ % 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@tempa{pgfsys-pdftex.def} -\ifx\pgfsysdriver\tikzcd@tempa +\def\tikzcd@temp{pgfsys-pdftex.def} +\ifx\pgfsysdriver\tikzcd@temp \def\tikzcd@arrowset{\tikzcd@arrowset@pdftex} \else \def\tikzcd@arrowset{\tikzcd@arrowset@generic} @@ -721,12 +728,12 @@ % 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. -\tikzset{/tikz/commutative diagrams/font arrows/.cd, +\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 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}, -- cgit v1.2.3