我有一张小“图表”,我想在上面添加标题,在下面添加简短描述。我该怎么做?

我有一张小“图表”,我想在上面添加标题,在下面添加简短描述。我该怎么做?
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usetikzlibrary{shapes.misc,shapes.geometric,arrows,positioning}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm, thick,main node/.style={circle,fill=gray!20,draw,font=\sffamily\Large\bfseries}]

  \node[main node, ellipse] (1) {{\scriptsize {Reputation1}}};
  \node[main node, ellipse] (2) [below= 30pt of 1] {{\scriptsize { Reputation2}}};
  \node[main node, ellipse] (3) [shift=(60:2) of 1] {{\scriptsize { Reuse small CRA}}};
  \node[main node, ellipse] (4) [shift=(10:5) of 1] {{\scriptsize { Behavior Intention small CRA}}};
  \node[main node, ellipse] (5) [shift=(-10:5) of 1] {{\scriptsize { Brand Preference}}};
  \node[main node, ellipse] (6) [below= 80pt of 4] {{\scriptsize { Behavior Intention large CRA}}};
  \node[main node, ellipse] (7) [below= 130pt of 3] {{\scriptsize { Reuse large CRA}}};
  \path[every node/.style={font=\sffamily\small}]
  (1) edge node [left] {{\tiny H1.1b}} (2)
  (1) edge [right] node [left] {\begin{tiny} H3.1a\end{tiny}} (3)
  (1) edge node [below] {{\tiny H3.2a}} (4)
  (1) edge node [below] {{\tiny \ H3.3a}} (5)
  (2) edge [right] node [above] {\begin{tiny} H3.3b\end{tiny}} (5)
  (2) edge node [above] {{\tiny H3.2b}} (6)
  (2) edge node [left] {{\tiny H3.1b}} (7);
\end{tikzpicture}
\end{document}

答案1

如果您希望将其作为 的一部分tikzpicture,只需在适当的位置添加两个节点。例如,您可以使用预定义节点的north和锚点,如下例所示。southcurrent bounding box

我还擅自修改了您的代码。例如,\Large您的样式中有一个字体大小设置 ( ) main node,但随后您将其添加\scriptsize到使用该样式的每个节点。选项也一样ellipse。只需修改main node样式就更简洁了。

同样地,对于边缘,您拥有相同\scriptsize的样式every node,但可以在任何地方添加\tiny

还要注意,在 中shift=(theta:r) at 1at 1部分什么也不做,shift与另一个坐标无关,例如below等。在这种情况下,您可以获得所需的结果,因为默认坐标是(0,0),所以节点134位于,5后三个的 s 将它们移动到不同的坐标。(0,0)shift

您没有为标题/描述指定任何格式请求,因此除了text width描述节点外,没有添加任何内容。

代码输出

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usetikzlibrary{shapes.misc,shapes.geometric,arrows,positioning}

\begin{document}
\begin{tikzpicture}[
  ->,>=stealth',
  shorten >=1pt,
  auto,
  node distance=3cm,
  thick,
  main node/.style={ellipse,fill=gray!20,draw,font=\sffamily\scriptsize\bfseries}
]

  \node[main node] (1) {Reputation1};
  \node[main node] (2) [below= 30pt of 1] {Reputation2};
  \node[main node] (3) [shift=(60:2)] {Reuse small CRA};
  \node[main node] (4) [shift=(10:5)] {Behavior Intention small CRA};
  \node[main node] (5) [shift=(-10:5)] {Brand Preference};
  \node[main node] (6) [below= 80pt of 4] {Behavior Intention large CRA};
  \node[main node] (7) [below= 130pt of 3] {Reuse large CRA};
  \path[every node/.style={font=\sffamily\tiny}]
  (1) edge node [left] {H1.1b} (2)
  (1) edge [right] node [left] {H3.1a} (3)
  (1) edge node [below] {H3.2a} (4)
  (1) edge node [below] {H3.3a} (5)
  (2) edge [right] node [above] {H3.3b} (5)
  (2) edge node [above] {H3.2b} (6)
  (2) edge node [left] {H3.1b} (7);

\node [above=2mm] at (current bounding box.north) {Some title};
\node [below=3mm,text width=6cm] at (current bounding box.south) {Lorem ipsum dolor sit amet consectetur etc. Foo bar baz and all that jazz.};
\end{tikzpicture}
\end{document}

相关内容