As egreg mentions in his comment
, tikz-cd
makes the arrows extend to fill the available space and (I agree with him) this is a desirable feature.
Regarding the second part of the question, you can use \tikzcdset
to pass options to the path /tikz/commutative diagrams
so they will affect all tikzcd
diagrams; in the case of your question, you can use shorten
:
\tikzcdset{
shorten >= 5pt,
shorten <= 5pt,
}
A complete example:
\documentclass[11pt]{amsart}
\usepackage{amscd}
\usepackage{tikz-cd}
\tikzcdset{
shorten >= 5pt,
shorten <= 5pt,
}
\begin{document}
\[\begin{CD}
\kappa(q)=B_{q}/qB_{q}@<<< B_{q}\\
@AAA @AAA\\
B\otimes \kappa(p)=B_{p}/pB_{p}@<<< B\otimes A_{p}\\
@AAA @AAA \\
\kappa(p)=A_{p}/pA_{p}@<<< A_{p}
\end{CD}\]
\[\begin{tikzcd}
\kappa(q)=B_{q}/qB_{q}& B_{q}\ar[l]\\
B\otimes \kappa(p)=B_{p}/pB_{p}\ar[u]& B\otimes A_{p}\ar[u]\ar[l]\\
\kappa(p)=A_{p}/pA_{p}\ar[u]&A_{p}\ar[u]\ar[l]
\end{tikzcd}\]
\end{document}
If you want to use this options locally, use them in the optional argument of tikzcd
:
\documentclass[11pt]{amsart}
\usepackage{amscd}
\usepackage{tikz-cd}
\begin{document}
\[\begin{CD}
\kappa(q)=B_{q}/qB_{q}@<<< B_{q}\\
@AAA @AAA\\
B\otimes \kappa(p)=B_{p}/pB_{p}@<<< B\otimes A_{p}\\
@AAA @AAA \\
\kappa(p)=A_{p}/pA_{p}@<<< A_{p}
\end{CD}\]
\[\begin{tikzcd}[ shorten >= 5pt,shorten <= 5pt]
\kappa(q)=B_{q}/qB_{q}& B_{q}\ar[l]\\
B\otimes \kappa(p)=B_{p}/pB_{p}\ar[u]& B\otimes A_{p}\ar[u]\ar[l]\\
\kappa(p)=A_{p}/pA_{p}\ar[u]&A_{p}\ar[u]\ar[l]
\end{tikzcd}\]
\end{document}
You can give a negative outer sep
to the labels. In the code below I've added a style to save some typing.
\documentclass{article}
\usepackage{tikz-cd}
\tikzset{close/.style={near start,outer sep=-2pt}}
\begin{document}
\[
\begin{tikzcd}[ampersand replacement = \&, column sep = tiny]
\& z_1 \ar[r, phantom, description, "\in"]
\& C \ar[dd, dashed, "\psi"]
\& z_2 \ar[l, phantom, description, "\ni"] \\
x_1 \ar[ur, mapsto] \ar[dr, mapsto] \ar[r, phantom, description, "\in"]
\& G_1 \ar[ur, close, "\eta_1"] \ar[dr,close, "\psi_1"']
\&
\& G_2 \ar[ul, close, "\eta_2"'] \ar[dl,close, "\psi_2"]
\& x_2 \ar[l, phantom, description, "\ni"] \ar[ul, mapsto] \ar[dl, mapsto] \\
\& y_1 \ar[r, phantom, description, "\in"]
\& H
\& y_2 \ar[l, phantom, description, "\ni"]
\end{tikzcd}
\]
\end{document}
Best Answer
For simple and complex diagrams, I'd recommend
tikz-cd
. If you are not comfortable with using the macros, there is also a web-based GUI editor at https://tikzcd.yichuanshen.de/. The following example can be viewed in the editor under this link (click).Let's see an easy triangular diagram.
An arrow takes as argument the "steps" where it has to go:
r
stands for "right",d
stands for "down"; alsou
stands for "up" andl
for "left".A similar syntax is available with Xy-pic.
Note how the labels are positioned:
^
means above the arrow,_
means below; above and below are with respect to the direction of the arrow: rotate it counterclockwise until it points from left to right.As you see, the results are pretty much alike. While I used to use Xy-pic, I'm now more convinced that
tikz-cd
can be better, as it relies on the powerful TikZ/PGF library.