summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex')
-rw-r--r--Master/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.tex641
1 files changed, 388 insertions, 253 deletions
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 c90e94e132d..8df598bc957 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,4 +1,4 @@
-% Copyright 2011, 2012 by Florêncio Neves
+% Copyright 2011, 2012 by Florêncio Neves
%
% This file may be distributed and/or modified
%
@@ -102,7 +102,6 @@
\usepackage{xxcolor}
\usepackage{pifont}
\usepackage{makeidx}
- \usepackage[latin1]{inputenc}
\usepackage{amsmath}
\graphicspath{{../../images/}} % TODOsp: under windows this would go up 2 directories, but the file is only one directory up
@@ -1317,24 +1316,31 @@ vv \fi%
inner ysep=0.5cm}
}
-\usepackage{tikz-cd}
-\usepackage{multicol,longtable}
+\usepackage{iftex,tikz-cd}
+\ifLuaTeX
+ \usepackage{fontspec}
+\else
+ \usepackage[utf8]{inputenc}
+\fi
-\hypersetup{pdftitle={The tikz-cd package},
- pdfauthor={Florêncio Neves},
+\hypersetup{unicode,
+ pdftitle={The tikz-cd package},
+ pdfauthor={Florêncio Neves},
pdfkeywords={commutative diagrams, latex, tikz, pgf},
colorlinks
}
\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.2c, of July 17, 2012}
+\author{\normalsize Florêncio Neves\footnote{\emph{E-mail:} \href{mailto:florencioneves@gmail.com}{\texttt{florencioneves@gmail.com}}}}
+\date{\normalsize Version 0.3, of August 10, 2012}
\tikzset{commutative diagrams/background color=graphicbackground}
-\newcommand{\displayarrow}[2][]{\texttt{#2} & yelds \tikz[baseline=-2.5pt] \draw[#2-#2, line width=0.0929ex, #1] (0,0) -- (1,0);}
-\newcommand{\displayarrowstyle}[2][]{\texttt{#2} #1 & yelds
- \tikz[baseline=-\tikzcdaxisheight, line width=\tikzcdrulethickness] \draw[commutative diagrams/.cd, #2] (0,0) -- (0.6,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);}
+
+\usepackage{microtype,ellipsis}
\begin{document}
\maketitle
@@ -1344,14 +1350,11 @@ 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
by providing a convenient set of macros and reasonable default
-settings. Familiarity with Ti\emph{k}Z is helpful, but not necessary,
-as the examples contained here cover the most often encountered
-situations.
-
-This package also includes an arrow tip library that match closely the
-arrows present in the Computer Modern typeface.
+settings. Familiarity with Ti\emph{k}Z is helpful but not necessary,
+since the examples contained here cover the most common situations.
-\textsc{pgf} version 2.10 is required.
+This package also includes an arrow tip library closely matching the
+Computer Modern arrow tips.
\tableofcontents
@@ -1359,11 +1362,11 @@ arrows present in the Computer Modern typeface.
\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 an
-|equation| environment or inside |\[| \dots |\]|, so that the diagram is
-placed on a new line and centered.
+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.
\subsection{Inserting arrows}
\label{sec:inserting-arrows}
@@ -1405,10 +1408,19 @@ specified by juxtaposing |{|\meta{text}|}| or
\end{tikzcd}
\end{codeexample}
-To save some typing, the command |\ar| is provided as a shorthand to
+% 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{ur}|, and so forth. They can take an optional
+|\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}|}|.
@@ -1439,7 +1451,7 @@ user's guide.
\subsection{Changing arrow tips}
\label{sec:changing-arrow-tips}
-For each arrow-producing command present in \AmS-\LaTeX, there is a
+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.
@@ -1452,26 +1464,21 @@ corresponding option (without a ``|\|'') that can be passed to
\end{tikzcd}
\end{codeexample}
-Of course, a similar effect could be achieved by directly using
-\tikzname{} options (e.g., using the option
-|right hook->|). However, the method 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 probably also
-better from the mnemonic standpoint.
-
The following list shows all available arrows.
{\tikzset{commutative diagrams/.cd, background color=white}
\begin{quote}
\begin{tabular}{ll}
\displayarrowstyle{rightarrow}\\
- \displayarrowstyle{Rightarrow}\\
\displayarrowstyle{leftarrow}\\
- \displayarrowstyle{Leftarrow}\\
\displayarrowstyle{leftrightarrow}\\
+ \displayarrowstyle{dash}\\
+ \displayarrowstyle{Rightarrow}\\
+ \displayarrowstyle{Leftarrow}\\
\displayarrowstyle{Leftrightarrow}\\
- \displayarrowstyle{equals}\\
+ \displayarrowstyle{equal}\\
\displayarrowstyle[(or \texttt{maps to})]{mapsto}\\
+ \displayarrowstyle{mapsfrom}\\
\displayarrowstyle[(or \texttt{hook})]{hookrightarrow}\\
\displayarrowstyle{hookleftarrow}\\
\displayarrowstyle{rightharpoonup}\\
@@ -1491,9 +1498,9 @@ The following list shows all available arrows.
\end{quote}
}
-Some of the styles above have two names. In these cases, the second
-one behaves a little differently from the first, in that it can be
-superimposed with other arrow styles.
+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.
\begin{codeexample}[]
\begin{tikzcd}
@@ -1501,6 +1508,12 @@ superimposed with other arrow styles.
\end{tikzcd}
\end{codeexample}
+It is also possible to select arrow tips using the \tikzname{} |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.
\section{Controlling the appearance of diagrams}
\label{sec:chang-appe-diagr}
@@ -1511,35 +1524,32 @@ Options can be made take effect in different scopes:
\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 the current diagram, by placing options in the optional
+\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}). Thus you can,
- for instance, use the |execute at end picuture| option in this
- situation to have arbitrary \tikzname{} code executed after a
- diagram is drawn.
-\item For the current arrow or label, by placing options in one of the
- optional arguments of |\arrow|.
+ 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. For example,
-setting |row sep=1cm| globally with |\tikzset| will have no effect on
-diagrams, since the |row sep| option is re-set at the beginning of
-each diagram. To make all diagrams have |row sep| set to 1\,cm, you
-can use
-\begin{quote}
- |\tikzset{commutative diagrams/row sep/normal=1cm}|,
-\end{quote}
-as detailed below.
+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
+|/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
\begin{quote}
|\tikzset{commutative diagrams/.cd, |\meta{options}|}|.
\end{quote}
+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|.
+
\subsection{General options}
\label{sec:general-options}
@@ -1549,9 +1559,9 @@ using method 1, it is convenient to change the default search path by using
\begin{quote}\ttfamily{}
/tikz/commutative diagrams/.cd,\\
|/tikz/cells={nodes={shape={asymmetrical rectangle}}}|,\\
+/tikz/baseline=0pt,\\
row sep=normal,\\
-column sep=normal,\\
-/tikz/baseline=0pt
+column sep=normal
\end{quote}
\end{stylekey}
@@ -1585,16 +1595,18 @@ stores a
\end{center}
\end{key}
- To change, say, the |normal| size (which is applied by default) to 1\,cm, you
- can use the code
+Notice that setting, say, |row sep=1cm| globally with |\tikzset| 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}|.
\end{quote}
- You can also create new sizes, but |pgfkeys| requires new keys to be
- explicitly initialized. For example, to create a size |my size|, meaning
- 1\,cm, you should use
+You can also create new sizes, but \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=1cm}|.
+|\tikzset{commutative diagrams/row sep/my size/.initial=1ex}|.
\end{quote}
\begin{key}{/tikz/commutative diagrams/column sep=\meta{size} (initially normal)}
@@ -1613,36 +1625,36 @@ 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} & \\
+ & B \arrow{dd} \\
+ A \arrow{ur}\arrow{dr} & \\
& C
\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.
+adjustments are necessary (see also \cite[\S17.3.2]{pgfman}).
\begin{command}{\colsep\marg{size}}
Returns the value
- stored in by the key |/tikz/commutative diagrams/column sep/|\meta{size}.
+ stored by the key |/tikz/commutative diagrams/column sep/|\meta{size}.
\end{command}
\begin{command}{\rowsep\marg{size}}
Returns the value
- stored in by the key |/tikz/commutative diagrams/row sep/|\meta{size}.
+ 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}
+ X \ar[bend right]{rdd} \ar[bend left]{rrd} \ar[dashrightarrow]{dr}
&[\colsep{small}-\colsep{normal}] & \\[\rowsep{small}-\rowsep{normal}]
& A \ar{r}\ar{d} & B \ar{d} \\
& C \ar{r} & D
@@ -1651,9 +1663,9 @@ without any spacing adjustment.
\begin{key}{/tikz/commutative diagrams/math mode=\meta{boolean}
(initially true)}
- This keys determines whether the contents of a diagram is typeset in
+ 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 affect
+ the diagram entries and arrow labels. If used with |\arrow|, it affects
only its labels.
\end{key}
@@ -1667,7 +1679,7 @@ without any spacing adjustment.
\label{sec:options-arrows}
Besides the options and styles provided by this package, there are
-several options defined by \tikzname{} that are useful for arrows, such
+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}.
@@ -1678,12 +1690,12 @@ as |dashed|, |dotted|, and its relatives, |line width=|\meta{dimension}, |color=
\begin{quote}\ttfamily{}
/tikz/commutative diagrams/.cd,\\
/tikz/draw,\\
-/tikz/commutative diagrams/default arrow
+default arrow
\end{quote}
\end{stylekey}
-The style |default arrow| is similar to |rightarrow|, but performs some
-additional initialization, such as setting the line width.
+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
@@ -1693,24 +1705,27 @@ additional initialization, such as setting the line width.
\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 (re)defined. In
- particular, it makes the style
- |/tikz/commutative diagrams/default arrow|,
- which is automatically applied to every arrow, to be defined.
- Currently, \meta{style} can be one of |computer modern| or |tikz|. The |tikz| style uses the arrow tips defined in \tikzname's |arrows|
- library, and it honors the option |/tikz/>|.
-
- The |computer modern| style sets the parameter |/tikz/line width| in
- accordance to the current font size. The |tikz| arrow style,
- however, does not change it, allowing you to directly control the
- thickness of arrows.
+ 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{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.
+ \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, and adjusting |/tikz/line width|
-if necessary. The following example, if not particularly elegant,
-should be instructive.
+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.
+The following example, if not particularly elegant, should be
+instructive.
\begin{codeexample}[]
\usetikzlibrary{arrows}
@@ -1718,7 +1733,7 @@ should be instructive.
\tikzset{
commutative diagrams/.cd,
arrow style=tikz,
- diagrams={>=open triangle 45, line width=\tikzcdrulethickness}}
+ diagrams={>=open triangle 45, line width=tikzcdrule}}
\begin{tikzcd}
A \arrow{r} \arrow{d} & B \arrow{d}\\
@@ -1726,30 +1741,52 @@ should be instructive.
\end{tikzcd}
\end{codeexample}
-\begin{key}{/tikz/commutative diagrams/start anchor=\meta{anchor}
- (default \normalfont empty)}
- This style specifies at which anchor of the current node an arrow
- should start. The default behavior is not to specify an anchor,
- causing the arrow to start at the point in the boundary of the
- current node closest to its target.
+\begin{key}{/tikz/commutative diagrams/start anchor=\meta{anchor}}
+ This key specifies at which anchor of the current node the arrow
+ should start.
\end{key}
-\begin{key}{/tikz/commutative diagrams/end anchor=\meta{anchor}
- (default \normalfont empty)}
- This style works analogously, but refers to the target node of the arrow.
+\begin{key}{/tikz/commutative diagrams/end anchor=\meta{anchor}}
+ This key specifies at which anchor of the target node the arrow
+ should arrive.
\end{key}
-See the picture on \S\ref{sec:asymm-rect-shape} for some of the
-possible values for \meta{anchor}. The picture below illustrates the
-use of \texttt{end anchor} and \texttt{start anchor}.
+% % | As it stands this is not immensely useful, so it will be left
+% % | undocumented while something better doesn't appear.
+% % V
-\begin{codeexample}[]
-\begin{tikzcd}
- A \rar[start anchor=north east, end anchor=north west]{\psi}
- \rar[start anchor=south east, end anchor=south west, swap]{\phi}
- & B
-\end{tikzcd}
-\end{codeexample}
+%
+% \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{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}
+
+% 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{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{stylekey}{/tikz/commutative diagrams/crossing over}
This style makes a thicker line, with color
@@ -1779,16 +1816,11 @@ The following picture, adapted from \cite{lenders}, illustrates this.
\end{codeexample}
\begin{key}{/tikz/commutative diagram/crossing over clearance=\meta{dimension}
- (initially 6pt)}
+ (initially 1.5ex)}
This key specifies the width of the background-colored line drawn
under a |crossing over| arrow.
\end{key}
-\begin{command}{\tikzcdrulethickness}
- This macro returns the value (in ex) of the math font default rule
- thickness.
-\end{command}
-
\subsection{Options for labels}
\label{sec:options-labels}
@@ -1802,20 +1834,22 @@ to the default), |sloped|, |pos=|\meta{fraction}, |near start|,
\begin{stylekey}{/tikz/commutative diagrams/every label}
This style is applied to every label produced with |\arrow|. It is initially set
- to the following:
+ to
\begin{quote}\ttfamily{}
/tikz/commutative diagrams/.cd,\\
/tikz/auto,\\
-/tikz/font=|\scriptsize|,\\
+/tikz/font=\meta{\rmfamily 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 style |auto| makes the label be placed to the left of the
+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 dimension |inner sep| controls the distance between an
-arrow and its labels.
+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
@@ -1823,8 +1857,9 @@ arrow and its labels.
\end{key}
\begin{stylekey}{/tikz/commutative diagrams/description}
- This style causes the label to be placed on the arrow, with the
- background filled.
+ This style causes the label to be placed over the arrow, with the
+ background filled. The clearance around the label is determined by
+ \texttt{/tikz/inner sep}.
\begin{codeexample}[]
\begin{tikzcd}
@@ -1833,19 +1868,12 @@ arrow and its labels.
\end{codeexample}
\end{stylekey}
-\begin{key}{/tikz/commutative diagrams/description
- clearance=\meta{dimension} (initially 1.5pt)}
- This key determines the size of the border around a label when the
- |description| style above is applied. Its value is used to set the
- key |/tikz/inner sep|.
-\end{key}
-
-\section{Further topics}
-\label{sec:further}
+\section{Advanced usage}
+\label{sec:advanced-usage}
-This sections provides further details on the functioning of
-this package, with the aim of showing how a more or less arbitrary use of
-\tikzname{} features can be made inside it.
+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.
\subsection{Internals of \texttt{tikzcd} and the arrow commands}
\label{sec:intern-arrow-comm}
@@ -1867,14 +1895,15 @@ with roughly the following:
|\end{tikzpicture}|
\end{quote}
-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}. Also, not shown above
-are a number of initialization procedures, such as defining the
-commands |\arrow|, |\ar|, |\rar|, |\lar|, |\dar|, |\uar|, |\urar|,
-|\ular|, |\drar|, |\dlar|.
+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
@@ -1887,9 +1916,7 @@ point it is inserted, and causes the following code to be added to
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}. The
-abbreviated commands |\rar|, |\dar|, etc., generate the same kind of
-code.
+\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
@@ -1903,15 +1930,8 @@ to be appended to \meta{labels}. Dollars signs surround \meta{label
text} depending on the setting \texttt{commutative diagrams/math
mode}.
-For the abbreviated form |\rar| (and similarly for |\dar|,
-|\lar|, etc.), the following are valid usages:
-\begin{quote}
- |\rar{|\meta{label text}|}|\meta{more labels},\\
- |\rar[|\meta{path options}|]{|\meta{label text}|}|\meta{more labels}, or\\
- |\rar[|\meta{path options}|][|\meta{label options}|]{|\meta{label
- text}|}|\meta{more labels}.
-\end{quote}
-Their effect is entirely analogous to the above.
+The abbreviated forms |\rar|, |\dar|, \dots, have entirely analogous
+effect.
\subsection{Tweaking \texttt{to} paths}
\label{sec:tweaking-to-paths}
@@ -1919,7 +1939,7 @@ Their effect is entirely analogous to the above.
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
-option |/tikz/to path| determines the path that is actually drawn, and
+key |/tikz/to path| determines the path that is actually drawn, and
can be used to do all sorts of fiddling.
\begin{codeexample}[]
@@ -1931,6 +1951,52 @@ can be used to do all sorts of fiddling.
\end{tikzcd}
\end{codeexample}
+A common use case is to produce parallel arrows.
+
+\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
+\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.
+
+\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
+\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,
@@ -1943,53 +2009,6 @@ in a way that, in the terminology of the previous section,
\end{tikzcd}
\end{codeexample}
-\subsection{The \texttt{asymmetrical rectangle} shape}
-\label{sec:asymm-rect-shape}
-
-The \texttt{asymmetrical rectangle} shape, defined by this package, is
-very similar to the \texttt{rectangle} shape, except that its
-\texttt{center} anchor is not located at the geometric center of the
-shape, but rather right above the \texttt{base} anchor, at a distance
-that can be specified by the following key, which is initially set to
-|\tikzcdaxisheight|.
-
-\begin{key}{/tikz/commutative diagrams/center shift=\meta{dimension}}
-\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}.
-
-\begin{center}\Huge
- \begin{tikzpicture}
- \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,
- 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}};
- \end{tikzpicture}
-\end{center}
-
-This shape is used in the matrix cells inside the \texttt{tikzcd}
-environment 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 these 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.
-
-\begin{command}{\tikzcdaxisheight}
- This macro returns the value (in ex) of the math font axis height.
-\end{command}
-
\subsection{Drawing diagrams directly with Ti\emph{k}Z}
\label{sec:draw-diagr-directly}
@@ -2030,14 +2049,81 @@ how this can be done (the second one is adapted from \cite{milne}).
\end{tikzpicture}
\end{codeexample}
-\section{Computer Modern arrow tips}
+\section{Additional goodies}
+\label{sec:general-infra}
+
+This package provides some general \pgfname\ infrastructure to meet its ends,
+as described 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.
+
+\begin{key}{/tikz/commutative diagrams/center yshift=\meta{dimension}
+ (initially tikzcdaxis)}
+\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}.
+
+\begin{center}\Huge
+ \begin{tikzpicture}
+ \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,
+ 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}};
+ \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}.
+
+\subsection{Reading font parameters}
+\label{sec:read-font-param}
+
+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.
+\end{math-function}
+
+\begin{math-function}{tikzcdrule}
+Returns the fraction rule thickness 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{}23 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 macro |\tikzcdrulethickness|.
+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
@@ -2057,7 +2143,7 @@ to get matching arrows in formulas and diagrams.
\displayarrow{cm to}\\
\displayarrow{cm to reversed}\\
\displayarrow[line width=0.66pt]{cm bold to} (with a line 50\% thicker)\\
- \texttt{cm \char`\|} & yelds \tikz[baseline=-2.5pt] \draw[cm |-cm |, line width=0.0929ex] (0,0) -- (1,0);\\
+ \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}\\
@@ -2090,47 +2176,112 @@ to get matching arrows in formulas and diagrams.
\end{tabular}
\end{description}
-\section{Font arrow tips}
+\subsection{Font 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, and it may conflict with
- future versions of \pgfname.}
+{\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 in pictures, this feature produces
+matching arrow tips in text and pictures, this feature produces
arrow tips that consist of (pieces of) characters carefully placed at
-the endpoints of a path. To activate it in |tikzcd| diagrams, use
-\begin{center}
+the endpoints of the path. To activate it in |tikzcd| diagrams, say
+\begin{quote}
|\tikzset{commutative diagrams/arrow style=math font}|.
-\end{center}
+\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:
-The above option 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
-currently selected font size, so you will probably want to set
-\texttt{line width=}|\tikzcdrulethickness| 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!)
+\begin{center}
+ \begin{tikzpicture}
+ \node[draw=gray,name=P]{
+ \begin{minipage}[t]{0.25\linewidth}\centering
+ \setmainfont{TG Pagella Math}
+ \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]
+ \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{XITS Math}
+ \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]
+ \ar[bend right]{rr}\rar[hook]%
+ ð´\pgfmatrixnextcell ðµ\rar[two heads]%
+ \pgfmatrixnextcell ð¶
+ \end{tikzcd}\\
+ XITS Math
+ \end{minipage}};
+ \node[draw=gray,name=R,right=5mm of Q]{
+ \begin{minipage}[t]{0.25\linewidth}\centering
+ \setmainfont{euler.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]
+ \ar[bend right]{rr}\rar[hook]%
+ A\pgfmatrixnextcell B\rar%
+ \pgfmatrixnextcell C
+ \end{tikzcd}\\
+ Neo Euler
+ \end{minipage}};
+\end{tikzpicture}
+\end{center}
+\fi
+
+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=-\tikzcdaxisheight]
- \draw[math cap-math to, line width=\tikzcdrulethickness] (0,0) -- (1,0);
+ \pdf\TeX{} \tikz[baseline=-tikzcdaxis]
+ \draw[math cap-math to, line width=tikzcdrule] (0,0) -- (1,0);
\hspace{1cm}
Other \TeX{} engines
\makeatletter\def\tikzcd@arrowset{\tikzcd@arrowset@generic}\makeatother
- \tikz[baseline=-\tikzcdaxisheight]
- \draw[math cap-math to,line width=\tikzcdrulethickness] (0,0) -- (1,0);
+ \tikz[baseline=-tikzcdaxis]
+ \draw[math cap-math to,line width=tikzcdrule] (0,0) -- (1,0);
\end{center}
I don't know of any automatic way of determining the distance between
@@ -2139,22 +2290,6 @@ 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.
-\section{Change history}
-\label{sec:change-history}
-
-\begin{description}
-\item[Version 0.2c] (July 2012) Added |\tikzcdrulethickness|,
- |\tikzcdaxisheight|, |\colsep|, |\rowsep|. Added experimental font arrows.
-\item[Version 0.2b] (March 2012) Added \texttt{asymetrical rectangle} shape.
-\item[Version 0.2a] (December 2011)
- Option |/tikz/commutative diagrams/path operation| removed
- in favor of direct use of |/tikz/to path|.
- Double lines with |tikz| arrow style now use \texttt{double
- equal sign distance}.
-\item[Version 0.2] (October 2011) Several changes.
-\item[Version 0.1] (September 2011) Preliminary release.
-\end{description}
-
\begin{thebibliography}{9}
\bibitem{knuth}
Donald Knuth,
@@ -2162,7 +2297,7 @@ want to use double lines.
Available at \url{http://www-cs-staff.stanford.edu/~uno/cm.html}
\bibitem{lenders}
Felix Lenders,
- \emph{Commutative diagrams using TikZ}.
+ \emph{Commutative diagrams using \tikzname}.
Available at \url{http://www.felixl.de/commu.pdf}.
\bibitem{milne}
James Milne,