3

I have been trying to make manual cell shifting in a tikz-cd diagram work in my case, but I am running into some issues when my diagram gets too big.

My desired diagram is something like

\documentclass[a41empaperpt]{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\begin{document}
\begin{equation}
    \begin{tikzcd}
    & S(F) \arrow[ddddl, "\operatorname{id}"']\arrow[dd, "\operatorname{pr}^*"] \arrow{rr} & &  F \arrow[dd, "\operatorname{pr}^*"]\rar{R} & Z(F) \arrow[ddddddl, bend left = 75, dotted, "\beta"]\arrow[dd, "\operatorname{pr}^*"] \\
    & & \circled{2} & & \\
    & IS(F) \arrow[ddl, "\partial_0^*", "\simeq"' ] \arrow[dddd, bend left = 90, "0", "\circled{3}"'] \arrow[dd, "\operatorname{id}"]\arrow[rr] & & I(F) \arrow[dddd, bend left = 30, "\partial_1^*-\partial_0^*"] \rar{R} & IZ(F) \arrow[ddddl, bend left = 45, dotted, "\alpha"]\\
    \\
    S(F) \arrow[ddr,  "0"']\arrow[r, "\operatorname{pr}^*", "\simeq"'] &[-10pt] IS(F) \arrow[dd, "\operatorname{\partial_1^*-\partial_0^*}"] &  & \circled{1} \\
    \\
    & S(F)\arrow[rr]  & & F
    \end{tikzcd}
\end{equation}
\end{document}

But the bendy arrow goes through \circled{3}, which I would like to manually move it to the left to avoid collision with the arrow. EDIT: Now the bendy arrow does not collide, but the \circled{3} is smaller than the other ones.

Using the linked question, I can do something like

\begin{equation}
\begin{tikzcd}
    & IS(F) \arrow[rrr] \arrow[d, "\operatorname{id}"]\arrow[dd, bend left = 75, "0"]&[-30pt] & & I(F)\\
    S(F) & IS(F) \arrow[d, "\partial_1^*-\partial_0^*"]&\circled{3}& \circled{1}& \\
    & S(F) &&& F \\
    \end{tikzcd} 
\end{equtation}

Which seems to work, except when I add a top row it breaks:

\begin{equation}
\begin{tikzcd}
    & S(F) & F \\
    & IS(F) \arrow[rrr] \arrow[d, "\operatorname{id}"]\arrow[dd, bend left = 75, "0"]&[-30pt] & & I(F)\\
    S(F) & IS(F) \arrow[d, "\partial_1^*-\partial_0^*"]&\circled{3}& \circled{1}& \\
    & S(F) &&& F \\
    \end{tikzcd}
\end{equation}

Any help is appreciated!

19
  • Please, give a fully compilable code.
    – AndréC
    Aug 21, 2020 at 15:48
  • @AndréC Sorry, what part doesn't work?
    – ThePuix
    Aug 21, 2020 at 15:49
  • \circled is not defined and the class of the document is missing.
    – AndréC
    Aug 21, 2020 at 15:50
  • 1
    I got these error ! Missing $ inserted.
    – AndréC
    Aug 21, 2020 at 15:53
  • 1
    tikzcd is not ended correctly. Please always make sure that yuour example actually compiles.
    – daleif
    Aug 21, 2020 at 15:56

2 Answers 2

3

screenshot

As explained in the comments, the problem is that \circled{3} is placed in a cell and therefore cannot be moved. Just place a second node at the arrow to place this 3 at the desired location. To do this a style circled 2 is created.

I colored in blue so that you can see the changes. I created a style called circled 2. The code is commented with %<--

\documentclass[a41empaperpt]{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\tikzset{circled 2/.style={draw,circle,font=\normalsize,inner sep=2pt}}     %<-- new style circled 2
            
\begin{document}
\begin{equation}
    \begin{tikzcd}
    & S(F) \arrow[ddddl, "\operatorname{id}"']\arrow[dd, "\operatorname{pr}^*"] \arrow{rr} & &  F \arrow[dd, "\operatorname{pr}^*"]\rar{R} & Z(F) \arrow[ddddddl, bend left = 75, dotted, "\beta"]\arrow[dd, "\operatorname{pr}^*"] \\
    & & \circled{2} & & \\
    & IS(F) \arrow[ddl, "\partial_0^*", "\simeq"' ] \arrow[dddd,blue, bend left = 90, "0", "3"{circled 2,swap,xshift=-2pt}] \arrow[dd, "\operatorname{id}"]\arrow[rr] & & I(F) \arrow[dddd, bend left = 30, "\partial_1^*-\partial_0^*"] \rar{R} & IZ(F) \arrow[ddddl, bend left = 45, dotted, "\alpha"]\\
    \\
    S(F) \arrow[ddr,  "0"']\arrow[r, "\operatorname{pr}^*", "\simeq"'] &[-10pt] IS(F) \arrow[dd, "\operatorname{\partial_1^*-\partial_0^*}"] &  & \circled{1} \\
    \\
    & S(F)\arrow[rr]  & & F
    \end{tikzcd}
\end{equation}

\end{document}
3
  • Beautiful, thank you so much for your help! If you don't mind, can you explain how the ` &[-10pt] ` works, I couldn't get it to bend to my will :). I also need similar things for other diagrams, can I ping you if I run into trouble there (though it should be easier than this one).
    – ThePuix
    Aug 21, 2020 at 17:31
  • 1
    @ThePuix The &[-10pt] reduces the column sep (created by this &) by 10pt. Its documentation can be seen from pgfmanual, sec. 20.3.2 Setting and Adjusting Column and Row Spacing, option row sep. Aug 21, 2020 at 17:58
  • 1
    @ThePuix Yes, you can send me a message whenever you want. As for the rest, muzimuzhiZ has answered your question.
    – AndréC
    Aug 21, 2020 at 18:42
3

I believe the errors come from some extra '. I deleted them and made a little changes in your code, you can easily find the changes: some {name=...}, an |[alias=is]|. I placed the circled numbers using the key phantom, you can see its use with the new arrow from S(F) to I(F) and the two arrows at the end.

\documentclass[a41empaperpt]{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
            
\begin{document}
\begin{equation}
\begin{tikzcd}[row sep=5em]
  & S(F)\arrow[rr] \arrow[d,"\operatorname{pr}^*"]
             \arrow[ddl,"\operatorname{id}"swap]
             \arrow[rrd,phantom,"\circled{2}"]
  && F\arrow[r,"R"]\arrow[d,"\operatorname{pr}^*"] 
  & Z(F)\arrow[d,"\operatorname{pr}^*"]
            \arrow[dddl, bend left = 75, dotted, "\beta"] \\ 
  &IS(F)\arrow[rr] \arrow[d,"\operatorname{id}"] 
             \arrow[dl,"\partial_0^*", "\simeq"swap]
             \arrow[dd,bend left = 90, "0"{name=0},""{name=o,left}]
  && I(F)\arrow[r,"R"]
       \arrow[dd,bend left = 30, "\partial_1^*-\partial_0^*",""{name=p,left}]
  & IZ(F)\arrow[ddl, bend left = 45, dotted, "\alpha"]\\
  S(F)\arrow[r,"\operatorname{pr}^*", "\simeq"swap] \arrow[dr,"0"swap]
  & |[alias=is]| IS(F)\arrow[d,"\operatorname{\partial_1^*-\partial_0^*}"]\\
  & S(F)\arrow[rr]
  && F
  \arrow[Rightarrow,from=0,to=p,phantom,"\circled{1}"]
  \arrow[Rightarrow,from=is,to=o,phantom,"\circled{3}"]
\end{tikzcd}
\end{equation}
\end{document}

The circled numbers appear always centered between the corresponding labels. Note that you don't need the extra rows to place them. I also added swap to the leftmost arrows, I believe it looks better if the id and 0 arrows are placed outside the triangles. enter image description here

2
  • This is a very nice solution as well, thank you so much!
    – ThePuix
    Aug 21, 2020 at 18:00
  • 1
    I’m glad that you can use it :) Aug 21, 2020 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .