5

I've just started using TikZ and need to create a simple triangle commutative diagram like this one. enter image description here

The closest I've been able to get is this. enter image description here

How do I get the h arrow to go from A2 to A3? Everything I've tried just causes errors.

Here's my current code:

\begin{tikzcd}[column sep=small]
A \arrow{r}{i}  \arrow{rd}{g} 
  & A3 \arrow{d}{h} \\
    & A2
\end{tikzcd}
7

The basic idea for triangular diagrams is to consider more columns, in this case three; you may want to play with column sep or row sep in order to get better distances, as shown.

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}
 & A \arrow{dr}{g} \\
B \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd}
\]
\[
\begin{tikzcd}[row sep=2.5em]
 & A \arrow{dr}{g} \\
B \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd}
\]
\[
\begin{tikzcd}[column sep=1.5em]
 & A \arrow{dr}{g} \\
B \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd}
\]
\end{document}

enter image description here

If you want to try this with QTikZ, you need a suitable template; create the text file tikz-cd-template.pgs with

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
<>
\end{document}

Choose the template and then paste the part of the above code which is between \begin{document} and \end{document} in the input window for QTikZ. Here's a picture of the result.

If you have an old version of tikz-cd (which might be the case on Ubuntu or other GNU/Linux boxes) it may be necessary to start the diagram with {}:

\[
\begin{tikzcd}
{} & A \arrow{dr}{g} \\
B \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd}
\]

enter image description here

  • For some reason, your code doesn't work on my system (TeXLive running on Ubuntu 14.04 and using QTikZ for graphics editing and preview). Here's the error I'm getting: Missing character: There is no A in font nullfont! [LaTeX] Line 2: Package pgfbasematrix Error: Single ampersand used with wrong catcode. [LaTeX] Line 2: See the pgfbasematrix package documentation for explanation. ... l.-5 &A \arrow{dr}{g} \\ [LaTeX] Line 2: ==> Fatal error occurred, no output PDF f – jaia Jul 14 '14 at 20:51
  • @jaia Hmm, are you using that inside the argument to a command? What TeX distribution are you using? – egreg Jul 14 '14 at 20:54
  • I'm using the latest version of TeX Live. Not sure what you mean by "inside the argument to a command". (I'm mostly a LyX user and rarely deal with straight LaTeX.) I just pasted everything between the \begin{tikzcd} and \end{tikz} tags between those same tags in QTikZ. – jaia Jul 14 '14 at 21:02
  • Also, could you please point me to a good explanation of the column thing and how that works? – jaia Jul 14 '14 at 21:04
  • 2
    @jaia I don't know what to say; what latest version of TeX Live are you running? If you're on Ubuntu, it's not the latest version, I'm afraid. Anyway, try with {} before the first & – egreg Jul 14 '14 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.