Posizionamento manuale delle celle in tikzcd

Aug 22 2020

Ho provato a far funzionare lo spostamento manuale delle celle in un diagramma tikz-cd nel mio caso, ma sto riscontrando alcuni problemi quando il mio diagramma diventa troppo grande.

Il mio diagramma desiderato è qualcosa di simile

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

Ma la freccia curva passa attraverso \circled{3}, che vorrei spostarla manualmente a sinistra per evitare la collisione con la freccia. EDIT: ora la freccia curva non si scontra, ma \circled{3}è più piccola delle altre.

Utilizzando la domanda collegata, posso fare qualcosa di simile

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

Che sembra funzionare, tranne quando aggiungo una riga in alto si interrompe:

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

Qualsiasi aiuto è apprezzato!

Risposte

3 AndréC Aug 22 2020 at 00:27

Come spiegato nei commenti, il problema è che \circled{3}viene inserito in una cella e quindi non può essere spostato. Basta posizionare un secondo nodo sulla freccia per posizionarlo 3nella posizione desiderata. Per fare questo circled 2viene creato uno stile .

Ho colorato in blu in modo che tu possa vedere i cambiamenti. Ho creato uno stile chiamato circled 2. Il codice viene commentato con%<--

\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 LuisTurcio Aug 22 2020 at 00:57

Credo che gli errori derivino da qualche extra '. Li ho cancellati e ho apportato piccole modifiche al tuo codice, puoi facilmente trovare le modifiche: alcune {name=...}, un file |[alias=is]|. Ho posizionato i numeri cerchiati usando il tasto phantom, puoi vederne l'uso con la nuova freccia da S(F)a I(F)e le due frecce alla fine.

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

I numeri cerchiati appaiono sempre centrati tra le etichette corrispondenti. Nota che non hai bisogno delle righe extra per posizionarle. Ho anche aggiunto swapalle frecce più a sinistra, credo che sia migliore se le frecce ide 0sono posizionate all'esterno dei triangoli.