网站结构的简单树?

网站结构的简单树?

我会创建一个小型网站结构的简单图片,我发现这些很好的例子http://www.texample.net/tikz/examples/family-tree/

但我想改变一些事情,但我不知道是否有可能。

  • 是否有可能在 Jim 和下一条线路之间建立一条直线?
  • 并且是否也可以从 Alfred 直接联系到第二步,然后从第二步联系到第三步?

我也不知道,为什么台阶的盒子会比另一个大。

如果有人能回答我,我会很高兴。谢谢你的帮助。

亲切的问候

以下是示例:

    % A family tree
% or: an organisational chart
% Author: Stefan Kottwitz , http://texblog.net
\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{comment}
:Title: A family tree
:Tags: Styles; Trees; Charts
:Author: Stefan Kottwitz
:Slug: family-tree

Posted for discussing and improving on http://tex.stackexchange.com/q/39696/213
\end{comment}

\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[
  man/.style={rectangle,draw,fill=blue!20},
  woman/.style={rectangle,draw,fill=red!20,rounded corners=.8ex},
  grandchild/.style={grow=down,xshift=1em,anchor=west,
    edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}},
  first/.style={level distance=6ex},
  second/.style={level distance=12ex},
  third/.style={level distance=18ex},
  level 1/.style={sibling distance=7em}]

    % Parents
    \coordinate
    child[grow=left] {node[man,anchor=east]{Jim}}
    child[grow=down,level distance=0ex]
    [edge from parent fork down]

    % Children and grandchildren
    child{node[man] {Alfred}
        child[grandchild,first] {node[man]{Step Two}
            child[grandchild,first] {node[man]{Step Three}
                child[grandchild,first] {node[man]{Step Four}
                }
            }
        }
    }
    child{node[man] {Berta}
    child[grandchild,first] {node[man]{Howard}}}
    child {node[man] {Charles}}
    child {node[man]{Doris}
    child[grandchild,first] {node[man]{Nick}}
    child[grandchild,second] {node[man]{Liz}}};
\end{tikzpicture}
\end{document}

答案1

我不确定这是否是你想要的:

\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\usetikzlibrary{trees}

\begin{document}
\begin{tikzpicture}[
  every node/.style={text width=2cm,align=center},
  man/.style={rectangle,draw,fill=blue!20},
  woman/.style={rectangle,draw,fill=red!20,rounded corners=.8ex},
  grandchild/.style={grow=down,xshift=1em,anchor=west,
    edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}},
  first/.style={level distance=6ex},
  second/.style={level distance=12ex},
  third/.style={level distance=18ex},
  level 1/.style={sibling distance=7em}]

    % Parents
    \node[man]{Jim}
    [edge from parent fork down]

    % Children and grandchildren
    child{node[man] {Alfred}
        child[first] {node[man]{Step Two}
            child[first] {node[man]{Step Three}
                child[first] {node[man]{Step Four}
                }
            }
        }
    }
    child{node[man] {Berta}
    child[grandchild,first] {node[man]{Howard}}}
    child {node[man] {Charles}}
    child {node[man]{Doris}
    child[grandchild,first] {node[man]{Nick}}
    child[grandchild,second] {node[man]{Liz}}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

第一个节点原本是子节点,我将其改为树的根节点。我删除了“第二步”、“第三步”和“第四步”节点的选项(这会引入水平移位)。默认情况下,每个节点的宽度将是其内容的自然宽度(加上一些填充),为了改变这种情况,我使用样式的键grandchild为节点声明了一个固定的通用宽度。text widthevery node

关于树木的详细信息可以在PGF manual。 这tikz-qtree包也可能引起人们的兴趣。

相关内容