手动

手动

我根据这个例子创建了一个思维导图:http://www.texample.net/tikz/examples/computer-science-mindmap/

有时分支包含的信息太多,导致地图看起来很丑陋,如下例所示:

在此处输入图片描述

这是我使用的代码:

\documentclass[landscape]{article}

\usepackage{tikz}
\usetikzlibrary{mindmap,trees}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {Main Topic}
    [clockwise from=0]
    child[concept color=green!50!black] {
      node[concept] {definition}
      child { node[concept] {this is a very long sentence ... very long sentence ... and it is even longer ...} }
      child { node[concept] {this is a very long sentence ... very long sentence ... and it is even longer ...} }
    }  
    child[concept color=blue] { node[concept] {Subtopic 1} }
    child[concept color=red] { node[concept] {Subtopic 2} }
    child[concept color=orange] { node[concept] {Subtopic 3} }
    child[concept color=purple] { node[concept] {Subtopic 4} }
    child[concept color=brown] { node[concept] {Subtopic 5} };
\end{tikzpicture}
\end{document}

是否有可能创建不显示为圆圈而是仅显示为线的分支,就像本例中那样,根本不使用图片?

在此处输入图片描述

答案1

手动

一种相当手动的方式是使用“定义”来命名节点,例如(def),并使用位于右侧的普通节点def

我为这些所谓的“非概念”创建了一种风格:

  • rectangle(默认),
  • text width=12em
  • execute at begin node=\footnotesize而不是font=\footnotesize(不能完美地与结合text width

此外,我为从到那些非概念的cncc east路径创建了一种风格。 它包括def

  • out=0in=180,和
  • A to path

    to由于声明中的使用to path失败,我回到了较低的版本\tikz@to@curve@path,它计算来自的路径

    • tikztostart
    • tikztotarget

    .east它们先前分别设置为和.south west锚点。

    另外,.south east目标节点的角用于确定线以下节点。

代码

\documentclass[tikz, border=2pt]{standalone}
\usetikzlibrary{mindmap,trees,positioning}
\makeatletter
\tikzset{
    non-concept/.style={
        rectangle,
        execute at begin node=\footnotesize,
        text width=12em,
    },
    cncc east/.style={% concept-non-concept-connection
                      % where the non-concept is east of the concept
        out=0,
        in=180,
        to path={
            \pgfextra{
                \edef\tikztostart{\tikztostart.east}
                \edef\tikztotargetB{\tikztotarget.south east}
                \edef\tikztotarget{\tikztotarget.south west}
            }
            \tikz@to@curve@path% needs \makeatletter and \makeatother
            -- (\tikztotargetB)
        }
    }
}
\makeatother
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
  \path[mindmap, concept color=black, text=white]
    node[concept] {Main Topic}[clockwise from=0]% named \___/ node
    child[concept color=green!50!black] { node[concept] (def) {definition} }
    child[concept color=blue]           { node[concept]       {Subtopic 1} }
    child[concept color=red]            { node[concept]       {Subtopic 2} }
    child[concept color=orange]         { node[concept]       {Subtopic 3} }
    child[concept color=purple]         { node[concept]       {Subtopic 4} }
    child[concept color=brown]          { node[concept]       {Subtopic 5} };

  \tikzset{
    every node/.style=non-concept,
    node distance=1ex,
  }
  \node[right=1cm of def, anchor=south west] (know)
    {What does each person know and not know about my topic?};
  \node[below=of know]                       (react)
    {How will each person react?
                      What concerns will I need to overcome?};
  \node[above=of know]                       (audi)
    {Who exactly is my audience?
      What is each listener's role and reason for attending?};

  \draw[
    line width=.8pt,
    shorten <=.06em,
    ]
        (def) edge[cncc east] (know)
              edge[cncc east] (react)
              edge[cncc east] (audi);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

(有点)自动

我更喜欢上面描述的手动方式。

设置edge of parent path不是一个大问题,甚至更容易。

但是在正确的级别分配正确的样式非常烦人,而且必须编写自定义的growth function

代码

\documentclass[tikz, border=2pt]{standalone}
\usetikzlibrary{mindmap,trees,positioning}
\makeatletter
\tikzset{
    non-concept/.style={
        rectangle,
        text width=12em,
        text=black,
        align=left,
    },
    cncc east/.style={
        edge from parent path={
            (\tikzparentnode.east) to[out=0, in=180] (\tikzchildnode.south west)
            -- (\tikzchildnode.south east)
        }
    }
}
\makeatother
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
  \path[mindmap, concept color=black, text=white]
    node[concept] {Main Topic}[clockwise from=0]% named \___/ node
    child[concept color=green!50!black] {
        node[concept] (def) {definition}
        [
            grow=right,
            sibling distance=14ex,
        ]
            child[level distance=5cm] { node[non-concept] {What does each person know and not know about my topic?}                            edge from parent[cncc east] }
            child[level distance=5cm] { node[non-concept] {How will each person react? What concerns will I need to overcome?}                 edge from parent[cncc east] }
            child[level distance=5cm] { node[non-concept] {Who exactly is my audience? What is each listener's role and reason for attending?} edge from parent[cncc east] }
        }
    child[concept color=blue]           { node[concept]       {Subtopic 1} }
    child[concept color=red]            { node[concept]       {Subtopic 2} }
    child[concept color=orange]         { node[concept]       {Subtopic 3} }
    child[concept color=purple]         { node[concept]       {Subtopic 4} }
    child[concept color=brown]          { node[concept]       {Subtopic 5} };
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容