画一个带箭头的简单图形

画一个带箭头的简单图形

我一直在尝试得到这个数字:

在此处输入图片描述

您能否指导我如何修正代码,以及如何将箭头置于线条的中心?谢谢。

这是我的代码:

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,backgrounds,decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[thick]
\draw[draw=blue!30,-latex] (0,0) node{$(x_{0},y_{0})$} -- (45:3) node {$K^{-}_{k+1}$};
\draw[draw=blue!30,dashed,-latex] (0,0) -- (0:2);
\draw[draw=blue!30,dashed,latex-] (2,0) node {$K_{k+1}$} -- (2,2) ;
\draw[draw=blue!30,dashed,-latex] (2,0) -- (4,0);
\draw[draw=blue!30,-latex] (2,0) node{$(x_{0},y_{0})$} -- (45:4) node {$K^{-}_{k+2}$};
\end{tikzpicture}

\end{document}

答案1

在此处输入图片描述

通过使用decorations.markingsTikZ 库:

\documentclass[border=3pt,tikz]{standalone}
    \usetikzlibrary{decorations.markings}

    \begin{document}
\begin{tikzpicture}[> = latex,
     decoration = {markings,mark=at position .75 
                            with {\arrow[very thick]{latex}}},
    arrow/.style = {draw=blue!30,thick},
dasharrow/.style = {arrow,densely dashed}
                    ]
\draw[arrow,postaction={decorate}]        
                    (0,0) node[below]{$(x_{0},y_{0})$}
                          -- (45:3) node[above] {$K^{-}_{k+1}$};
\draw[dasharrow,->] (0,0) -- (2,0)  node[below] {$K_{k+1}$};
\draw[dasharrow,postaction={decorate}] (45:3) -- (2,0);
\draw[dasharrow,->] (2,0) -- (4,0)     node[below] {$K_{k+2}$};
\draw[arrow,postaction={decorate}]        
                    (2,0) -- ++ (45:3) node[above] {$K^{-}_{k+2}$};
\draw[dasharrow,postaction={decorate}] 
                    (2,0) + (45:3) -- (4,0);
\end{tikzpicture}
        \end{document}

注意:水平线和垂直线之间的角度不是 90 度。如果您想要这样,您需要重新定义水平箭头的坐标。

编辑:哎呀,太匆忙了,我没有上传最后一张图片也没有 MWE 代码……现在已经更正了。

相关内容