2

I wanna draw two lines starting from the same origin to other two nodes. The code gives me two lines but the origin of the two lines are different.

\begin{figure}[H]
\centering
%\begin{adjustbox}{width=\textwidth}

\begin{tikzpicture}

\tikzstyle{monolithic}  = [rectangle, thick,draw, fill=white!20,  text width=10em,align=center ,  minimum height=1.5em]
\tikzstyle{decompose} =  = [rectangle, thick,draw, fill=white!20,  text width=5em,align=center ,  minimum height=1.5em]
\tikzstyle{elements} =  = [rectangle, thick,draw, fill=white!20,  text width=5em,align=center ,  minimum height=1.5em]



\tikzstyle{line} = [-stealth, thick, draw]
\tikzstyle{cloud} = [draw, ellipse,fill=green!20, node distance=8cm, minimum height=2em]
\tikzstyle{blank} = [node distance=0cm]
\tikzstyle{arrow} = [thick,->,>=stealth]
 % Place nodes

\node [monolithic] (mono) {Structure-Electric Interaction};
\node [blank, below =of mono] (blank_node) {};
\node [decompose, below =of mono, node distance=2cm, yshift=0.2cm,xshift=-2.50cm] (left) {Structural field};
\node [decompose, below  = of mono,node distance=2cm, yshift=0.2cm,xshift=2.50cm] (right) {Electrical field};


\path [line]  (mono)--(left);
\path [line]  (mono)--(right);


%\path [line]  (blank_node)--(left);
%\path [line]  (blank_node)--(right);
\end{tikzpicture}
%\end{adjustbox}
\caption{Nonlinear dynamic piezoelectric analysis: Approach 1 and Approach 2} \label{field_decomposition}
%\end{figure*}
\end{figure}

2 Answers 2

5

off-topic, but can be helpful:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}

    \begin{tikzpicture}[
    node distance = 12mm and 6mm,
 box/.style = {rectangle, draw, thick, fill=white!20,
               text width=#1,
               align=center,  minimum height=1.5em},
line/.style = {-stealth, thick, draw}
                        ]
 % Place nodes
\node [box=10em] (mono) {Structure-Electric Interaction};
\node [box= 5em, below  left=of mono.south] (left) {Structural field};
\node [box= 5em, below right=of mono.south] (right) {Electrical field};
%
\draw [line]  (mono.south) -- (left);
\path [line]  (mono.south) -- (right);
    \end{tikzpicture}
\end{document}

as you can see:

  • used is recent syntax for nodes positioning (\tikzstyle is deprecated)
  • for node positioning is used common node distance
  • removed are for this image all unnecessary styles definitions (with goal to obtain minimal working example -- mwe)
  • for nodes is used common style with options for determining the text width of the nodes

enter image description here

2
  • 1
    I wish you a merry Christmas and a happy new year! Thank for making this world a bit better every time you remove vertical lines from tables :) Commented Dec 24, 2017 at 15:58
  • @samcarter, thank you very much for your wishes. i wish you happy holidays and prosper new year too!
    – Zarko
    Commented Dec 24, 2017 at 23:25
7

Make your arrows start from the south anchor of mono:

\path [line]  (mono.south)--(left);
\path [line]  (mono.south)--(right);

enter image description here

\documentclass{report}

\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{positioning}


\begin{document}
\begin{figure}[H]
    \centering
    %\begin{adjustbox}{width=\textwidth}

    \begin{tikzpicture}[monolithic/.style={rectangle, thick,draw, fill=white!20,  text width=10em,align=center ,  minimum height=1.5em},
        decompose/.style={rectangle, thick,draw, fill=white!20,  text width=5em,align=center ,  minimum height=1.5em},
        elements/.style={rectangle, thick,draw, fill=white!20,  text width=5em,align=center ,  minimum height=1.5em},
        line/.style={-stealth, thick, draw},
        cloud/.style={draw, ellipse,fill=green!20, node distance=8cm, minimum height=2em},
        blank/.style={node distance=0cm},
        arrow/.style={thick,->,>=stealth}]

    % Place nodes

    \node [monolithic] (mono) {Structure-Electric Interaction};
    \node [blank, below =of mono] (blank_node) {};
    \node [decompose, below =of mono, node distance=2cm, yshift=0.2cm,xshift=-2.50cm] (left) {Structural field};
    \node [decompose, below  = of mono,node distance=2cm, yshift=0.2cm,xshift=2.50cm] (right) {Electrical field};


    \path [line]  (mono.south)--(left);
    \path [line]  (mono.south)--(right);


    %\path [line]  (blank_node)--(left);
    %\path [line]  (blank_node)--(right);
    \end{tikzpicture}
    %\end{adjustbox}
    \caption{Nonlinear dynamic piezoelectric analysis: Approach 1 and Approach 2} \label{field_decomposition}
    %\end{figure*}
\end{figure}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .