如何在路径的顶部和底部添加文本?下面的交换图已完成 90%。不过,我希望text={${gKer({\varphi}){\mapsto}{\varphi(G)}}$}
遵循箭头下方的路径并\cong
遵循同一箭头上方的路径。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\node (A) {$G$};
\node (B) [right of=A] {$G'$};
\node (C) [below of=A] {$G/Ker(\varphi)$};
\draw[->>] (A) --(B) node[above,midway] {$\varphi$};
\draw[->,postaction={decorate,decoration={text along path,text align=center,text={${\pi}{\;}$}}}] (A) to node[swap] {} (C);
\draw[->,postaction={decorate,decoration={text along path,text align = center,text={${gKer({\varphi}){\mapsto}{\varphi(G)}}$}}}] (C) to node[swap] {} (B);
\end{tikzpicture}
\end{document}
答案1
我建议你使用tikz-cd
为您的交换图提供包;此外,由于有问题的标签实际上不是地图的名称,而是它的动作,我还建议您在图表之外描述地图(否则,图表可能会过于拥挤):
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\DeclareMathOperator{\Ker}{Ker}
\begin{document}
\[
\begin{tikzcd}
G\arrow[twoheadrightarrow]{r}{\varphi}\arrow{d}{\pi} & G' \\
G/\Ker(\varphi)\arrow[sloped,swap]{ur}[near start]{\tau}[swap]{\cong}
\end{tikzcd}
\]
where $\tau:G/\Ker(\varphi)\rightarrow G'$ is defined by $g\Ker({\varphi}){\mapsto}{\varphi(G)}$.
\end{document}
当然,您可以用最初请求的标签绘制图表,也许可以增加节点之间的距离:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\DeclareMathOperator{\Ker}{Ker}
\begin{document}
\[
\begin{tikzcd}[row sep=60pt,column sep=huge]
G\arrow[twoheadrightarrow]{r}{\varphi}\arrow{d}{\pi} & G' \\
G/\Ker(\varphi)\arrow[sloped,swap]{ur}[pos=0.15]{g\Ker({\varphi}){\mapsto}{\varphi(G)}}[swap]{\cong}
\end{tikzcd}
\]
\end{document}
注意使用
\DeclareMathOperator{\Ker}{Ker}
(需要amsmath
包)来产生正确的形状Ker
操作员生成正确的形状;(我最初忽略了这一点,但是 伊桑·博尔克在评论中指出了这一点)。