9

I would like to draw a commutative triangle with tikzcd where the entries have different sizes.

 \[
  \begin{tikzcd}[column sep=15pt]
  \mathcal{C} \ar{rr}  \ar{dr} & & S(\tau) \ar{dl} \\
   & \mathsf{Set} &
  \end{tikzcd}
 \]

This produces a slight asymmetry (the arrow on the right is more slanted, and the middle entry is not in the middle):

enter image description here

One solution is to use the following tikzcd-option:

 cells={nodes={align=center,text width=\widthof{$S(\tau)$}}}

The output looks as follows:

enter image description here

But now the arrow doesn't start at the left entry. How to make this happen?

1
  • Off topic: in xy it is @! or @!0. – Symbol 1 Mar 20 '15 at 1:43
14

Update

This feature is mentioned in the TikZ manual, namely III.20.3.2.

\begin{tikzcd}[column sep={1cm,between origins}]
    \mathcal{C}\ar{rr}\ar{dr} && S(\tau,..............)\ar{dl} \\
    & \mathsf{Set}
\end{tikzcd}

Old Answer

The column-separating symbol & accepts an optional argument. Just like \\[6pt] does, &[6] adds the current col sep by 6...pt by default.

\documentclass[tikz,border=9]{standalone}
\usepackage{tikz-cd}
\begin{document}
    \begin{tikzcd}[column sep=15pt]
        \mathcal{C}\ar{rr}\ar{dr} &[6]& S(\tau)\ar{dl} \\
        & \mathsf{Set}
    \end{tikzcd}
\end{document}
5
  • 1
    Thank you! It works, but I don't understand why. Could you explain what you mean by "adds the current col sep by default" and why it gives the desired result? – Martin Brandenburg Mar 20 '15 at 7:28
  • @MartinBrandenburg Symbol 1 just changed the separation in between the columns for the two left columns. 6pt instead of the 15pt which are your default. The wider triangle looks more symmetric, but it isn't. – LaRiFaRi Mar 20 '15 at 7:32
  • @LaRiFaRi I thought it is 6+15pt just like \\[6pt] add additional spaces. Any way, @Martin Brandenburg you can check out the matrix library of TikZ, on which tikz-cd bases. – Symbol 1 Mar 20 '15 at 7:49
  • @Symbol1 You are right. It does. Btw.: Thanks for that cool feature. I have seen a lot of posts here, where the answer was "change globally or use many many &&& in order to get different column seps in your graph". Is that feature new? First time I am seeing it. – LaRiFaRi Mar 20 '15 at 8:06
  • 1
    @LaRiFaRi Not sure. Maybe I saw this feature from something about pgfplotstable. – Symbol 1 Mar 20 '15 at 9:03
5

You can add [start anchor={[xshift=-5pt]}] to shift the starting point of your arrow.

MWE

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
 \[
  \begin{tikzcd}[column sep=15pt,cells={nodes={align=center,text width=\widthof{$S(\tau)$}}}]
  \mathcal{C} \ar[start anchor={[xshift=-5pt]}]{rr}  \ar{dr} & & S(\tau) \ar{dl} \\
   & \mathsf{Set} &
  \end{tikzcd}
 \]
\end{document} 

enter image description here

1
  • I've added that possibility here, too... – karlkoeller Mar 20 '15 at 9:29
2

For a real symmetry speaking of the arrows, you will have to increase the width and the hight of the upper left node.

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}

\begin{document}
\[
\begin{tikzcd}[column sep=15pt]
      \phantom{S(\tau)}\mathllap{\mathcal{C}}\ar{rr}\ar{dr} & & S(\tau)\ar{dl} \\
    & \textsf{Set}
\end{tikzcd}
\]
\end{document}

As you can see, the diagonal arrows are starting and ending in the very same place (but mirrored).

enter image description here

0

I propose a solution with the psmatrix environment:

\documentclass[pdf]{article}
\usepackage{pst-node}

\begin{document}

\[ \psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=2pt, rowsep=0.9cm, colsep=0.7cm}
\begin{psmatrix}
  \ \mathcal C & & S(\tau) \\%
   & \mathsf {Set}
%%%
 \ncline[nodesepB=1.5pt]{1,1}{1,3} \ncline{1,1}{2,2}
 \ncline[nodesepA=1pt]{1,3}{2,2}
\end{psmatrix}
\]
\end{document} 

enter image description here

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.