tikz 图中直箭头

tikz 图中直箭头

我正在使用tikz它来绘制图表,但我需要一些帮助来对齐一些文本。这是我的代码:

\documentclass[12pt]{amsart}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw[black] (0, 2) -- (0, 0) node [pos=.5, sloped, above] (TextNode) {\itshape A};
    \filldraw[black] (0, 0) circle (2pt) node[anchor=west]{\scshape B};
\draw[gray] (0, 0) -- (2, -4) node[anchor=west]{C};
\draw[black] (0,0) -- (0, -4) node [pos=.5, anchor=east] (TextNode) {

        \begin{tikzpicture}
            \node at (0, 1) (nodeLin) {\small \itshape some text here};
            \node at (0, 0) (nodeVI) {\small \itshape some other here};
            \node at (0, -1) (nodeR) {\small \itshape some here};

            \draw[->] (nodeLin) -- (nodeVI);
            \draw[->] (nodeVI) -- (nodeR);      

        \end{tikzpicture} } node[anchor=north]{D};

\end{tikzpicture}

\end{document}

这是输出:

在此处输入图片描述

我需要的是让箭头居中对齐,并且始终垂直向下。我该怎么做呢?

非常感谢!

答案1

不要tikzpicture在 a 内使用 a tikzpicture。这里有一个替代解决方案。

命令

\draw[black] (0,0) -- node[left=2mm] (nodeVI) {\small \itshape some other here} (0, -4) 
      node[below]{D};

(0,0)从到画一条线(0,-4),并some other here在该线的中心位置左侧写上 2mm。(--和 坐标之间的节点相当于pos=0.5)。之后,我们可以用这个节点作为上句或下句的参考。

\documentclass[12pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\draw[black] (0, 2) -- (0, 0) node [pos=.5, sloped, above] (TextNode) {\itshape A};
\filldraw[black] (0, 0) circle (2pt) node[anchor=west]{\scshape B};
\draw[gray] (0, 0) -- (2, -4) node[right]{C};
\draw[black] (0,0) -- node[left=2mm] (nodeVI) {\small \itshape some other here}
 (0, -4) node[below]{D};
\node[above= 5mm of nodeVI] (nodeLin) {\small \itshape some text here};
\node[below=5mm of nodeVI] (nodeR) {\small \itshape some here};
\draw[->] (nodeLin) -- (nodeVI);
\draw[->] (nodeVI) -- (nodeR);
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

希望这对你有帮助

\documentclass[12pt]{amsart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[black] (0, 2) -- (0, 0) node [pos=.5, sloped, above] (TextNode) {\itshape A};
    \filldraw[black] (0, 0) circle (2pt) node[anchor=west]{\scshape B};
\draw[gray] (0, 0) -- (2, -4) node[anchor=west]{C};
\draw[black] (0,0) -- (0, -4) node [pos=.5, anchor=east] (TextNode) {

        \begin{tikzpicture}
            \node [align=right] at (0, 1) (nodeLin) {\small \itshape some text here};
            \node [align=right]  at (0, 0) (nodeVI) {\small \itshape some other here};
            \node [align=left]  at (0, -1) (nodeR) {\small \itshape some here};
            \draw [->] (nodeLin) -- (nodeLin |- nodeVI.north);
            \draw[->](nodeVI) -- (nodeVI |- nodeR.north);      
        \end{tikzpicture} } node[anchor=north]{D};
\end{tikzpicture}
\end{document}

相关内容