How to draw commutative diagrams?
Can anyone help me in giving commands for commutative diagrams in LaTeX ? It doesn't seem to appear properly in the LaTeX guides that I have. A command for a simple triangular diagram with arrows associated to maps would be good enough, or maybe some appropriate reference.
macros diagrams xy-pic tikz-cd
add a comment |
Can anyone help me in giving commands for commutative diagrams in LaTeX ? It doesn't seem to appear properly in the LaTeX guides that I have. A command for a simple triangular diagram with arrows associated to maps would be good enough, or maybe some appropriate reference.
macros diagrams xy-pic tikz-cd
2
sure, how about a quick google
– cmhughes
May 23 '13 at 15:28
2
Take a look at jmilne.org/not/CDGuide.html
– user13907
May 23 '13 at 15:29
One single authentic source onxy-picis at TUG and its userguide and crisp Introduction ppt. More in depth reference guide
– texenthusiast
May 23 '13 at 15:34
4
The most modern package istikz-cd. The documentation includes numerous examples.
– Gonzalo Medina
May 23 '13 at 15:38
add a comment |
Can anyone help me in giving commands for commutative diagrams in LaTeX ? It doesn't seem to appear properly in the LaTeX guides that I have. A command for a simple triangular diagram with arrows associated to maps would be good enough, or maybe some appropriate reference.
macros diagrams xy-pic tikz-cd
Can anyone help me in giving commands for commutative diagrams in LaTeX ? It doesn't seem to appear properly in the LaTeX guides that I have. A command for a simple triangular diagram with arrows associated to maps would be good enough, or maybe some appropriate reference.
macros diagrams xy-pic tikz-cd
macros diagrams xy-pic tikz-cd
edited 13 mins ago
Henri Menke
70.5k8157264
70.5k8157264
asked May 23 '13 at 15:26
smiley06smiley06
317138
317138
2
sure, how about a quick google
– cmhughes
May 23 '13 at 15:28
2
Take a look at jmilne.org/not/CDGuide.html
– user13907
May 23 '13 at 15:29
One single authentic source onxy-picis at TUG and its userguide and crisp Introduction ppt. More in depth reference guide
– texenthusiast
May 23 '13 at 15:34
4
The most modern package istikz-cd. The documentation includes numerous examples.
– Gonzalo Medina
May 23 '13 at 15:38
add a comment |
2
sure, how about a quick google
– cmhughes
May 23 '13 at 15:28
2
Take a look at jmilne.org/not/CDGuide.html
– user13907
May 23 '13 at 15:29
One single authentic source onxy-picis at TUG and its userguide and crisp Introduction ppt. More in depth reference guide
– texenthusiast
May 23 '13 at 15:34
4
The most modern package istikz-cd. The documentation includes numerous examples.
– Gonzalo Medina
May 23 '13 at 15:38
2
2
sure, how about a quick google
– cmhughes
May 23 '13 at 15:28
sure, how about a quick google
– cmhughes
May 23 '13 at 15:28
2
2
Take a look at jmilne.org/not/CDGuide.html
– user13907
May 23 '13 at 15:29
Take a look at jmilne.org/not/CDGuide.html
– user13907
May 23 '13 at 15:29
One single authentic source on
xy-pic is at TUG and its userguide and crisp Introduction ppt. More in depth reference guide– texenthusiast
May 23 '13 at 15:34
One single authentic source on
xy-pic is at TUG and its userguide and crisp Introduction ppt. More in depth reference guide– texenthusiast
May 23 '13 at 15:34
4
4
The most modern package is
tikz-cd. The documentation includes numerous examples.– Gonzalo Medina
May 23 '13 at 15:38
The most modern package is
tikz-cd. The documentation includes numerous examples.– Gonzalo Medina
May 23 '13 at 15:38
add a comment |
2 Answers
2
active
oldest
votes
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.
documentclass{article}
usepackage{tikz-cd}
begin{document}
[
begin{tikzcd}
A arrow{r}{f} arrow[swap]{dr}{gcirc f} & B arrow{d}{g} \
& C
end{tikzcd}
]
end{document}

An arrow takes as argument the "steps" where it has to go: r stands for "right", d stands for "down"; also u stands for "up" and l for "left".
A similar syntax is available with Xy-pic.
documentclass{article}
usepackage[all,cmtip]{xy}
begin{document}
[
xymatrix{
A ar[r]^{f} ar[dr]_{gcirc f} & B ar[d]^{g} \
& C
}
]
end{document}
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.
tikz-cdis significantly better. It is more flexible and powerful, and just compare the hooked arrows with those ofxy-pic.
– Gaussler
Feb 18 '16 at 17:05
1
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, buttikz-cdis much more powerful and intuitive. You won't find a single hook arrow in my older diagrams.;-)
– egreg
Feb 18 '16 at 17:09
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C(you may have to adjust thecolumn sep)
– egreg
Feb 15 '17 at 21:50
add a comment |
Another way is to use the psmatrix environment, from pst-node. The objects are first described as nodes in a matrix, then the arrows are described. In this description, nodes can be given a name, or are described by their pair of indices i, j in the matrix. See documentation of pst-node for details on how to connect nodes or more generally how to fine-tune the look of a diagram.
You can compile with pdflatex if you use the --shell-escape switch (TeX Live, MacTeX) or --enable-write18 (MiKTeX), and use the pdf option for the document class: this loads the auto-pst-pdf package. Alternatively, you can load the latter package, after pstricks and its family.
Here is a simple example:
documentclass[pdf]{article}
usepackage{pst-node}
begin{document}
[ psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
begin{psmatrix}
(X, d) & (X_1 ,d_1 )\%
& (X_2 ,d_2)
%%%
ncline{1,1}{1,2}naput{T_1} ncline{1,1}{2,2}nbput{T_2 }
ncline{1,2}{2,2}naput[npos=0.45]{T}
end{psmatrix}
]
end{document}

add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f115783%2fhow-to-draw-commutative-diagrams%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
documentclass{article}
usepackage{tikz-cd}
begin{document}
[
begin{tikzcd}
A arrow{r}{f} arrow[swap]{dr}{gcirc f} & B arrow{d}{g} \
& C
end{tikzcd}
]
end{document}

An arrow takes as argument the "steps" where it has to go: r stands for "right", d stands for "down"; also u stands for "up" and l for "left".
A similar syntax is available with Xy-pic.
documentclass{article}
usepackage[all,cmtip]{xy}
begin{document}
[
xymatrix{
A ar[r]^{f} ar[dr]_{gcirc f} & B ar[d]^{g} \
& C
}
]
end{document}
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.
tikz-cdis significantly better. It is more flexible and powerful, and just compare the hooked arrows with those ofxy-pic.
– Gaussler
Feb 18 '16 at 17:05
1
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, buttikz-cdis much more powerful and intuitive. You won't find a single hook arrow in my older diagrams.;-)
– egreg
Feb 18 '16 at 17:09
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C(you may have to adjust thecolumn sep)
– egreg
Feb 15 '17 at 21:50
add a comment |
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.
documentclass{article}
usepackage{tikz-cd}
begin{document}
[
begin{tikzcd}
A arrow{r}{f} arrow[swap]{dr}{gcirc f} & B arrow{d}{g} \
& C
end{tikzcd}
]
end{document}

An arrow takes as argument the "steps" where it has to go: r stands for "right", d stands for "down"; also u stands for "up" and l for "left".
A similar syntax is available with Xy-pic.
documentclass{article}
usepackage[all,cmtip]{xy}
begin{document}
[
xymatrix{
A ar[r]^{f} ar[dr]_{gcirc f} & B ar[d]^{g} \
& C
}
]
end{document}
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.
tikz-cdis significantly better. It is more flexible and powerful, and just compare the hooked arrows with those ofxy-pic.
– Gaussler
Feb 18 '16 at 17:05
1
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, buttikz-cdis much more powerful and intuitive. You won't find a single hook arrow in my older diagrams.;-)
– egreg
Feb 18 '16 at 17:09
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C(you may have to adjust thecolumn sep)
– egreg
Feb 15 '17 at 21:50
add a comment |
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.
documentclass{article}
usepackage{tikz-cd}
begin{document}
[
begin{tikzcd}
A arrow{r}{f} arrow[swap]{dr}{gcirc f} & B arrow{d}{g} \
& C
end{tikzcd}
]
end{document}

An arrow takes as argument the "steps" where it has to go: r stands for "right", d stands for "down"; also u stands for "up" and l for "left".
A similar syntax is available with Xy-pic.
documentclass{article}
usepackage[all,cmtip]{xy}
begin{document}
[
xymatrix{
A ar[r]^{f} ar[dr]_{gcirc f} & B ar[d]^{g} \
& C
}
]
end{document}
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.
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.
documentclass{article}
usepackage{tikz-cd}
begin{document}
[
begin{tikzcd}
A arrow{r}{f} arrow[swap]{dr}{gcirc f} & B arrow{d}{g} \
& C
end{tikzcd}
]
end{document}

An arrow takes as argument the "steps" where it has to go: r stands for "right", d stands for "down"; also u stands for "up" and l for "left".
A similar syntax is available with Xy-pic.
documentclass{article}
usepackage[all,cmtip]{xy}
begin{document}
[
xymatrix{
A ar[r]^{f} ar[dr]_{gcirc f} & B ar[d]^{g} \
& C
}
]
end{document}
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.
edited 10 mins ago
Henri Menke
70.5k8157264
70.5k8157264
answered May 23 '13 at 20:37
egregegreg
711k8618913174
711k8618913174
tikz-cdis significantly better. It is more flexible and powerful, and just compare the hooked arrows with those ofxy-pic.
– Gaussler
Feb 18 '16 at 17:05
1
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, buttikz-cdis much more powerful and intuitive. You won't find a single hook arrow in my older diagrams.;-)
– egreg
Feb 18 '16 at 17:09
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C(you may have to adjust thecolumn sep)
– egreg
Feb 15 '17 at 21:50
add a comment |
tikz-cdis significantly better. It is more flexible and powerful, and just compare the hooked arrows with those ofxy-pic.
– Gaussler
Feb 18 '16 at 17:05
1
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, buttikz-cdis much more powerful and intuitive. You won't find a single hook arrow in my older diagrams.;-)
– egreg
Feb 18 '16 at 17:09
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C(you may have to adjust thecolumn sep)
– egreg
Feb 15 '17 at 21:50
tikz-cd is significantly better. It is more flexible and powerful, and just compare the hooked arrows with those of xy-pic.– Gaussler
Feb 18 '16 at 17:05
tikz-cd is significantly better. It is more flexible and powerful, and just compare the hooked arrows with those of xy-pic.– Gaussler
Feb 18 '16 at 17:05
1
1
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, but
tikz-cd is much more powerful and intuitive. You won't find a single hook arrow in my older diagrams. ;-)– egreg
Feb 18 '16 at 17:09
@Gaussler I fully agree! I have used Xy-pic quite extensively, with good results, but
tikz-cd is much more powerful and intuitive. You won't find a single hook arrow in my older diagrams. ;-)– egreg
Feb 18 '16 at 17:09
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
How can I arrange for the triangle to be equilateral? In other words, how do I centralize $C$ above?
– Eduardo Longa
Feb 15 '17 at 20:12
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C (you may have to adjust the column sep)– egreg
Feb 15 '17 at 21:50
A arrow{rr}{f} arrow[swap]{dr}{gcirc f} && B arrow{dl}{g} \ & C (you may have to adjust the column sep)– egreg
Feb 15 '17 at 21:50
add a comment |
Another way is to use the psmatrix environment, from pst-node. The objects are first described as nodes in a matrix, then the arrows are described. In this description, nodes can be given a name, or are described by their pair of indices i, j in the matrix. See documentation of pst-node for details on how to connect nodes or more generally how to fine-tune the look of a diagram.
You can compile with pdflatex if you use the --shell-escape switch (TeX Live, MacTeX) or --enable-write18 (MiKTeX), and use the pdf option for the document class: this loads the auto-pst-pdf package. Alternatively, you can load the latter package, after pstricks and its family.
Here is a simple example:
documentclass[pdf]{article}
usepackage{pst-node}
begin{document}
[ psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
begin{psmatrix}
(X, d) & (X_1 ,d_1 )\%
& (X_2 ,d_2)
%%%
ncline{1,1}{1,2}naput{T_1} ncline{1,1}{2,2}nbput{T_2 }
ncline{1,2}{2,2}naput[npos=0.45]{T}
end{psmatrix}
]
end{document}

add a comment |
Another way is to use the psmatrix environment, from pst-node. The objects are first described as nodes in a matrix, then the arrows are described. In this description, nodes can be given a name, or are described by their pair of indices i, j in the matrix. See documentation of pst-node for details on how to connect nodes or more generally how to fine-tune the look of a diagram.
You can compile with pdflatex if you use the --shell-escape switch (TeX Live, MacTeX) or --enable-write18 (MiKTeX), and use the pdf option for the document class: this loads the auto-pst-pdf package. Alternatively, you can load the latter package, after pstricks and its family.
Here is a simple example:
documentclass[pdf]{article}
usepackage{pst-node}
begin{document}
[ psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
begin{psmatrix}
(X, d) & (X_1 ,d_1 )\%
& (X_2 ,d_2)
%%%
ncline{1,1}{1,2}naput{T_1} ncline{1,1}{2,2}nbput{T_2 }
ncline{1,2}{2,2}naput[npos=0.45]{T}
end{psmatrix}
]
end{document}

add a comment |
Another way is to use the psmatrix environment, from pst-node. The objects are first described as nodes in a matrix, then the arrows are described. In this description, nodes can be given a name, or are described by their pair of indices i, j in the matrix. See documentation of pst-node for details on how to connect nodes or more generally how to fine-tune the look of a diagram.
You can compile with pdflatex if you use the --shell-escape switch (TeX Live, MacTeX) or --enable-write18 (MiKTeX), and use the pdf option for the document class: this loads the auto-pst-pdf package. Alternatively, you can load the latter package, after pstricks and its family.
Here is a simple example:
documentclass[pdf]{article}
usepackage{pst-node}
begin{document}
[ psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
begin{psmatrix}
(X, d) & (X_1 ,d_1 )\%
& (X_2 ,d_2)
%%%
ncline{1,1}{1,2}naput{T_1} ncline{1,1}{2,2}nbput{T_2 }
ncline{1,2}{2,2}naput[npos=0.45]{T}
end{psmatrix}
]
end{document}

Another way is to use the psmatrix environment, from pst-node. The objects are first described as nodes in a matrix, then the arrows are described. In this description, nodes can be given a name, or are described by their pair of indices i, j in the matrix. See documentation of pst-node for details on how to connect nodes or more generally how to fine-tune the look of a diagram.
You can compile with pdflatex if you use the --shell-escape switch (TeX Live, MacTeX) or --enable-write18 (MiKTeX), and use the pdf option for the document class: this loads the auto-pst-pdf package. Alternatively, you can load the latter package, after pstricks and its family.
Here is a simple example:
documentclass[pdf]{article}
usepackage{pst-node}
begin{document}
[ psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
begin{psmatrix}
(X, d) & (X_1 ,d_1 )\%
& (X_2 ,d_2)
%%%
ncline{1,1}{1,2}naput{T_1} ncline{1,1}{2,2}nbput{T_2 }
ncline{1,2}{2,2}naput[npos=0.45]{T}
end{psmatrix}
]
end{document}

edited Feb 1 '17 at 9:40
answered Oct 20 '14 at 8:14
BernardBernard
167k769194
167k769194
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f115783%2fhow-to-draw-commutative-diagrams%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
sure, how about a quick google
– cmhughes
May 23 '13 at 15:28
2
Take a look at jmilne.org/not/CDGuide.html
– user13907
May 23 '13 at 15:29
One single authentic source on
xy-picis at TUG and its userguide and crisp Introduction ppt. More in depth reference guide– texenthusiast
May 23 '13 at 15:34
4
The most modern package is
tikz-cd. The documentation includes numerous examples.– Gonzalo Medina
May 23 '13 at 15:38