![我有一张小“图表”,我想在上面添加标题,在下面添加简短描述。我该怎么做?](https://linux22.com/image/362845/%E6%88%91%E6%9C%89%E4%B8%80%E5%BC%A0%E5%B0%8F%E2%80%9C%E5%9B%BE%E8%A1%A8%E2%80%9D%EF%BC%8C%E6%88%91%E6%83%B3%E5%9C%A8%E4%B8%8A%E9%9D%A2%E6%B7%BB%E5%8A%A0%E6%A0%87%E9%A2%98%EF%BC%8C%E5%9C%A8%E4%B8%8B%E9%9D%A2%E6%B7%BB%E5%8A%A0%E7%AE%80%E7%9F%AD%E6%8F%8F%E8%BF%B0%E3%80%82%E6%88%91%E8%AF%A5%E6%80%8E%E4%B9%88%E5%81%9A%EF%BC%9F.png)
\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
和锚点,如下例所示。south
current bounding box
我还擅自修改了您的代码。例如,\Large
您的样式中有一个字体大小设置 ( ) main node
,但随后您将其添加\scriptsize
到使用该样式的每个节点。选项也一样ellipse
。只需修改main node
样式就更简洁了。
同样地,对于边缘,您拥有相同\scriptsize
的样式every node
,但可以在任何地方添加\tiny
。
还要注意,在 中shift=(theta:r) at 1
,at 1
部分什么也不做,shift
与另一个坐标无关,例如below
等。在这种情况下,您可以获得所需的结果,因为默认坐标是(0,0)
,所以节点1
、3
和4
位于,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}