如何在 tikz-cd 而不是 tikz 中繪製曲線?

如何在 tikz-cd 而不是 tikz 中繪製曲線?

我正在做一個項目,並試圖給 Tikz-cd 一個機會,但我在從一端到另一端添加一個彎曲的箭頭時遇到了麻煩。

在使用 tikz 之前,我在兩個節點之間做了類似的事情,但由於使用 tikz-cd 時節點不一定以相同的方式定義,我不確定應該如何返回並添加該行。我包含了常規的tikz 範例來展示我之前是如何完成的,而我的新圖表與它應該顯示的完全一樣,除了另一條從0 到0 的曲線。執行此操作嗎?此外,新箭頭不一定是\mapsto箭頭,但理想情況下應該是。

姆韋:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage{graphicx,tikz,tikz-cd}
\usepackage[margin=2.25cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Tikz vs. Tikz-cd}
\cfoot{}
\begin{document}
I have done this using just Tikz in the past.
\[\begin{tikzpicture}[node distance=2cm]
    \node (Q1){$0$};
    \node[right of=Q1] (Q2){$L$};
    \node[right of=Q2] (Q3){$M$};
    \node[right of=Q3] (Q4){$N$};
    \node[right of=Q4] (Q5){$0$};
    \draw[->,thick] (Q1) -- (Q2);
    \draw[->,thick] (Q2) -- node[pos=.5,above]{$\psi$}(Q3);
    \draw[->,thick] (Q3) -- node[pos=.5,above]{$\varphi$}(Q4);
    \draw[->,thick] (Q4) --(Q5);
    \draw [bend left,->,dashed] (Q4) to node[pos=.5,below]{$\alpha$}(Q3);
    \draw [bend left,->,dashed] (Q3) to node[pos=.5,below left]{$\beta$}(Q2);
\end{tikzpicture}\]

Now I am trying to switch to using Tikz-cd, and I would like to add a curved under arrow from the zero on one end to the other. I have been able to solve the rest of it but I am not very fluent with the tikz-cd syntax yet.

\[\begin{tikzcd}[node distance=2cm]
   0 \arrow[mapsto]{r}{\varphi^{(1)}_{1}}
& 24 \arrow[mapsto]{r}{\varphi^{(1)}_{1}}
& 17 \arrow[mapsto]{r}{\varphi^{(1)}_{1}}
& 18 \arrow[mapsto]{r}{\varphi^{(1)}_{1}}
& 0
\end{tikzcd}\]

\結束{文件}

好的,我可以加入這一行:

& 0 \arrow[mapsto, bend left]{l}

這給了我一條曲線,但如果有幫助的話,只回傳一個節點而不是 4 個節點。

答案1

tikz-cd基本上就是一個節點矩陣,或者換句話說,一個表。因此,如果你寫\arrow[mapsto, bend left]{l}它,它只會向左 ( l) 移動一個節點,因為你只指示一個單元格。

將其替換為\arrow[mapsto, bend left]{llll}.

在此輸入影像描述

答案2

這可以是另一種方法tikz-cd在此輸入影像描述

\documentclass[a4paper,12pt]{article}

\usepackage{tikz-cd,amsmath,amssymb}

\begin{document}
\begin{tikzcd}
0 \arrow[r, "\varphi^{(1)}_{1}", maps to] & 24 \arrow[r, "\varphi^{(1)}_{1}", maps to] & 17 \arrow[r, "\varphi^{(1)}_{1}", maps to] & 18 \arrow[r, "\varphi^{(1)}_{1}", maps to] & 0 \arrow[llll, maps to, bend left]
\end{tikzcd}
\end{document}

相關內容