本图的标签

本图的标签

如何在下图的角落和箭头处添加标签?

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.markings,arrows.meta}
\usetikzlibrary{backgrounds}

\begin{document}

\begin{tikzpicture}
\end{tikzpicture}

\begin{tikzcd}[
sep=2cm,
cells={shape=coordinate},
]
  \ar[draw=none,r, "{\tikz\node[rotate=90,inner sep=0pt] {\tikz\draw[->](0,0) ;};  }" description]
  \ar[dash,r] 
& 
{} 
\\
  \ar[draw=none,r, "{\tikz\node[rotate=270,inner sep=0pt] {\tikz\draw[->](0,0) ;};  }" description] 
  \ar[draw=none,u, "{\tikz\node[inner sep=0pt] {\tikz\draw[->>](0,0) ;};  }" description] 
  \ar[draw=none,ur, "{\tikz\node[rotate=-45,inner sep=0pt] {\tikz\draw[->>>](0,0) ;};  }" description] 
  \ar[dash,r] 
  \ar[dash,u] 
  \ar[dash,ur] 
& 
{}
  \ar[draw=none,u, "{\tikz\node[inner sep=0pt] {\tikz\draw[->>](0,0) ;};  }" description]
    \ar[dash,u]  
\end{tikzcd}
\end{document}

结果图

该图源于这个问题 如何画克莱因瓶

答案1

不幸的是,您的代码嵌套了tikzpictures,这可能导致无法控制的结果。但是,您已经加载了decorations.markings,并且使用它可以让您避免嵌套。我添加了两种方法来回答您的问题,一种是使用tikz-cd,另一种是使用普通的 TiZ. 为了您的方便,我定义了样式->-->>-以及->>>-单箭头、双箭头和三箭头。(编辑:为了您的方便,我添加了反向箭头样式。)

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.markings}
\tikzset{> at/.style={postaction={decorate,decoration={markings,mark=at position
#1 with {\arrow{>};}}}},
->-/.style={> at=0.5},
->>-/.style={>
at/.list={0.5*\pgfdecoratedpathlength-1.5pt,0.5*\pgfdecoratedpathlength+1.5pt}},
->>>-/.style={>
at/.list={0.5*\pgfdecoratedpathlength-3pt,0.5,0.5*\pgfdecoratedpathlength+3pt}},
< at/.style={postaction={decorate,decoration={markings,mark=at position
#1 with {\arrowreversed{>};}}}},
-<-/.style={< at=0.5},
-<<-/.style={<
at/.list={0.5*\pgfdecoratedpathlength-1.5pt,0.5*\pgfdecoratedpathlength+1.5pt}},
-<<<-/.style={<
at/.list={0.5*\pgfdecoratedpathlength-3pt,0.5,0.5*\pgfdecoratedpathlength+3pt}}}
\begin{document}

\begin{tikzcd}[sep=2cm,cells={nodes={text height=1em,minimum width=0.8em}}]
a
& 
b\ar[dash,l,-<-,start anchor=south west,end anchor=south east,"\ell_1"']
\\
c \ar[dash,u,->>-,start anchor=north east,end anchor=south east,"\ell_2"]
\ar[dash,r,->-,start anchor=north east,end anchor=north west,"\ell_3"']
\ar[dash,ur,->>>-,start anchor=north east,end anchor=south west,"\ell_4"]
& 
d \ar[dash,u,->>-,start anchor=north west,end anchor=south west,"\ell_5"]
\end{tikzcd}

\begin{tikzpicture}
 \path (0,0) coordinate[label=above left:$a$] (a)
  (2,0) coordinate[label=above right:{$b$}](b) 
  (0,-2) coordinate[label=below left:$c$] (c)
  (2,-2) coordinate[label=below right:$d$] (d)
  (b) edge[->-,"$\ell_1$"'] (a)
  (c) edge[->>-,"$\ell_2$"] (a)
  (d) edge[->>-,"$\ell_5$"'] (b)
  (c) edge[->>-,"$\ell_3$"'] (d)
  (c) edge[->>>-,"$\ell_4$"] (b);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容