Tikz \path[line]:从同一点开始绘制从一个节点到下面两个节点的路径。

Tikz \path[line]:从同一点开始绘制从一个节点到下面两个节点的路径。

我想从同一原点到另外两个节点绘制两条线。代码给了我两条线,但是这两条线的原点不同。

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

答案1

离题,但可能会有帮助:

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

如你看到的:

  • 使用最新的语法进行节点定位(\tikzstyle已弃用)
  • 用于节点定位的通用方法node distance
  • 删除了此图像所有不必要的样式定义(目的是获得最小的工作示例 - mwe)
  • 对于节点使用通用样式,带有用于确定text width节点的选项

在此处输入图片描述

答案2

让你的箭头从south锚点开始mono

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

在此处输入图片描述

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

相关内容