tikz 中的时间轴。防止节点重叠

tikz 中的时间轴。防止节点重叠

我正在尝试创建如下所示的时间线模板:

例子

看起来还不错,但是当我添加bignodes 时,所有内容都开始重叠(bignodes 是位于相应 squarenodes 右侧的文本节点)

\begin{tikzpicture}[
squarenode/.style={rectangle, draw=blue!60, fill=blue!5, ultra thick, minimum size=10mm},
roundnode/.style={circle, draw=blue!60, fill=blue!5, ultra thick, minimum size=1mm},
bignode/.style={rectangle, text width=20em, draw=blue!10, fill=blue!0, ultra thick, minimum size=60mm},
]
%Nodes

\node[roundnode]        (t1)        {};
\node[roundnode]        (t2)   [right=of t1]     {};
\node[roundnode]        (t3)   [right=of t2]     {};
\node[roundnode]        (t4)   [right=of t3]     {};
\node[roundnode]        (t5)   [right=of t4]     {};

\node[squarenode]       (t1u)   [above=of t1]   {1};
\node[squarenode]       (t3u)   [above=of t3]   {3};
\node[squarenode]       (t5u)   [above=of t5]   {5};

\node[squarenode]       (t2d)   [below=of t2]   {2};
\node[squarenode]       (t4d)   [below=of t4]   {4};


\node[bignode]          (t1b)   [right=of t1u]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius};
\node[bignode]          (t2b)   [right=of t2d]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius};
\node[bignode]          (t3b)   [right=of t3u]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eiusx};
\node[bignode]          (t4b)   [right=of t4d]  {Nemo enim ipsam};
\node[bignode]          (t5b)   [right=of t5u]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius};




%Lines
\draw[-] (t1.east) -- (t2.west);
\draw[-] (t2.east) -- (t3.west);
\draw[-] (t3.east) -- (t4.west);
\draw[-] (t4.east) -- (t5.west);

\draw[-] (t1.north) -- (t1u.south);
\draw[-] (t3.north) -- (t3u.south);
\draw[-] (t5.north) -- (t5u.south);

\draw[-] (t2.south) -- (t2d.north);
\draw[-] (t4.south) -- (t4d.north);
\end{tikzpicture}\\
xxx\\
\begin{tikzpicture}


\end{tikzpicture}

答案1

我想您已经快到了。我只是添加了一些距离和锚点。

\documentclass[border=3.14mm,tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
squarenode/.style={rectangle, draw=blue!60, fill=blue!5, ultra thick, minimum size=10mm},
roundnode/.style={circle, draw=blue!60, fill=blue!5, ultra thick, minimum size=1mm},
bignode/.style={rectangle, text width=20em, draw=blue!10, fill=blue!0, ultra thick, minimum size=60mm},
]
%Nodes

\node[roundnode]        (t1)        {};
\node[roundnode]        (t2)   [right=12em of t1]     {};
\node[roundnode]        (t3)   [right=12em of t2]     {};
\node[roundnode]        (t4)   [right=12em of t3]     {};
\node[roundnode]        (t5)   [right=12em of t4]     {};
\node[bignode]          (t1b)   [above right=5mm of t1,anchor=south west]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius};
\node[bignode]          (t2b)   [below right=5mm of t2,anchor=north west]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius};
\node[bignode]          (t3b)   [above right=5mm of t3,anchor=south west]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eiusx};
\node[bignode]          (t4b)   [below right=5mm of t4,anchor=north west]  {Nemo enim ipsam};
\node[bignode]          (t5b)   [above right=5mm of t5,anchor=south west]  {Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius};

\node[squarenode]       (t1u)   [above=53 mm of t1]   {1};
\node[squarenode]       (t3u)   [above=53 mm of t3]   {3};
\node[squarenode]       (t5u)   [above=53 mm of t5]   {5};

\node[squarenode]       (t2d)   [below=53 mm of t2]   {2};
\node[squarenode]       (t4d)   [below=53 mm of t4]   {4};

%Lines
\foreach \X [evaluate=\X as \Y using int(\X+1)] in {1,...,4}
{\draw[-] (t\X.east) -- (t\Y.west);}
\foreach \X in {1,...,5}
{
\ifodd\X
\draw[-] (t\X.north) -- (t\X u.south);
\else
\draw[-] (t\X.south) -- (t\X d.north);
\fi
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容