手动将单元格放置在 tikzcd 中

手动将单元格放置在 tikzcd 中

我一直在努力在 tikz-cd 图中手动移动单元格在我的情况下有效,但是当我的图表变得太大时,我遇到了一些问题。

我想要的图表是这样的

\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}

但是弯曲的箭头穿过了\circled{3},我想手动将其向左移动以避免与箭头发生碰撞。 编辑:现在弯曲的箭头不会发生碰撞,但是\circled{3}比其他箭头小。

使用链接的问题,我可以做类似的事情

\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}

这似乎有效,但当我添加顶行时它会中断:

\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}

任何帮助都将不胜感激!

答案1

截屏

正如评论中所述,问题在于它\circled{3}被放置在单元格中,因此无法移动。只需在箭头处放置第二个节点即可将其放置3在所需位置。为此,circled 2创建了一个样式。

我用蓝色标注,以便您可以看到变化。我创建了一个名为的样式circled 2。代码注释为%<--

\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}

答案2

我相信错误来自一些额外的'。我删除了它们并在您的代码中做了一些更改,您可以轻松找到更改:一些{name=...},一个|[alias=is]|。我使用键放置了带圆圈的数字,您可以通过从到的phantom新箭头和末尾的两个箭头看到它的用途。S(F)I(F)

\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}

带圆圈的数字始终位于相应标签之间的中心。请注意,您不需要额外的行来放置它们。我还添加了swap最左边的箭头,我相信如果将id0箭头放在三角形之外会看起来更好。 在此处输入图片描述

相关内容