tikz 中的重叠节点

tikz 中的重叠节点

我曾经在 tikz 中制作过链式图,如手动的p. 59 ff,但与手册相反,我的节点重叠了。我尝试使用“节点距离”选项,但似乎不起作用。以下是最低限度的工作示例(writeLatex.com)

\documentclass[12pt]{scrartcl}

\usepackage{tikz}

\begin{document}

\begin{figure}[tb]
    \begin{center}
    \begin{tikzpicture}[
            % copy to preamble to use it everywhere \tikzset{node/.style...}
            node/.style={
                % shape
                rectangle,
                rounded corners=1mm,
                minimum size=6mm,
                %border
                thick,
                draw,
            },
            dummy/.style={
                % shape
                rectangle,
                rounded corners=1mm,
                minimum size=6mm,
                %border
                thick,
            },
            node distance=10mm
            ]
            \node(wadl)[node]{WADL-Datei};
            \node(xsd1)[node,below left of=wadl]{XSD-Datei};
            \node(...)[dummy,below of=wadl]{\ldots};
            \node(xsd3)[node,below right of=wadl]{XSD-Datei};
            \node(test)[node,right of=wadl]{test};

            \path(wadl) edge[->] (test);
        \end{tikzpicture}   
    \end{center}
    \caption{Codegeneratorsystem}
    \label{fig:codegeneratorsystem}
\end{figure}

\end{document}

在此处输入图片描述

答案1

为了使节点相对于其他节点正确定位,您必须包含positioningtikz 库。并将相对定位的语法从 更改为below of=nodebelow = of node即等号位于of关键字之前。

这边走:

\usetikzlibrary{positioning}

\begin{figure}[tb]
    \begin{center}
    \begin{tikzpicture}[
            % copy to preamble to use it everywhere \tikzset{node/.style...}
            node/.style={
                % shape
                rectangle,
                rounded corners=1mm,
                minimum size=6mm,
                %border
                thick,
                draw,
            },
            dummy/.style={
                % shape
                rectangle,
                rounded corners=1mm,
                minimum size=6mm,
                %border
                thick,
            },
            node distance=10mm
            ]
            \node(wadl)[node]{WADL-Datei};
            \node(xsd1)[node,below left=of wadl]{XSD-Datei};
            \node(...)[dummy,below= of wadl]{\ldots};
            \node(xsd3)[node,below right=of wadl]{XSD-Datei};
            \node(test)[node,right=of wadl]{test};

            \path(wadl) edge[->] (test);
        \end{tikzpicture}   
    \end{center}
    \caption{Codegeneratorsystem}
    \label{fig:codegeneratorsystem}
\end{figure}

其结果如下:

结果

答案2

只需添加

\usetikzlibrary{positioning}

到你的序言并将你的定位用法更改为:

\node(wadl)[node]{WADL-Datei};
\node(xsd1)[node,below left = of wadl]{XSD-Datei};
\node(...)[dummy,below = of wadl]{\ldots};
\node(xsd3)[node,below right = of wadl]{XSD-Datei};
\node(test)[node,right = of wadl]{test};

答案3

另外一个选择

    \node(wadl)[node]{WADL-Datei};
    \node(xsd1)[node,below left=10pt and 10pt of wadl ]{XSD-Datei};
    \node(...)[dummy,below of=wadl]{\ldots};
    \node(xsd3)[node,below right=10pt and 10pt of wadl]{XSD-Datei};
    \node(test)[node,right=10pt of wadl]{test};
    \path(wadl) edge[->] (test);

在此处输入图片描述

相关内容