4

I'm using tikz to draw a diagram, but I need some help with aligning some text. Here's my code:

\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}

This is the output:

enter image description here

What I would need to get, is that the arrow is center-aligned, and it always goes straight down. How can I do that?

Many thanks!

5

Don't use a tikzpicture inside a tikzpicture. Here you have an alternative solution.

Command

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

draws the line from (0,0) to (0,-4) and writes some other here 2mm to the left of central position of this line. (A node between -- and coordinate is equivalent to pos=0.5). After that, we can use this node as reference for upper or lower sentences.

\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}

enter image description here

1

May this helps you

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.