我有一个在 tikz 中绘制的节点,如下所示:
\node[below, text width=5cm] (SomeName) at (0,0) {
\begin{itemize}
\item line 1
\item line 2
\item line 3
\item line 4
\item line 5
\end{itemize}
}
我想从第 2 行向侧面绘制一个箭头,指向我构建的另一个节点。我还想在第 4 行和第 5 行周围放置一个括号,然后绘制另一个箭头指向另一个节点。
这些项目并不是严格意义上的一行项目,所以我希望能够在文本中放置一些参考(如果可能的话)以便能够构造我的线,而不是将线定位在我的节点构建的框的某个部分。
对于完整的代码 spinet 来说,它将提供我正在寻找的图像:
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usepgflibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.text}
\usepackage{calc}
\usepackage{enumitem}
\begin{document}
\begin{tikzpicture}
\node[below, text width=5cm] (SomeName) at (0,0) {
\begin{itemize}
\item line 1
\item line 2
\item line 3
\item line 4
\item line 5
\end{itemize}
};
\node[below, text width=2cm] (Other) at (-5,0) {
Some text will go here.
};
\node[below, text width=2cm] (Another) at (-5,-4) {
Some text will go here.
};
\draw[decorate,decoration={brace,amplitude=7pt,mirror}](-2,-2) -- (-2,-3) node[midway,left] (A) {};% A node must have a (possibly empty) label text.
\draw[-stealth] (-2,-1.5) -- (Other.east);
\draw[-stealth] (A.west) -- (Another.east);
\end{tikzpicture}
\end{document}
我希望来自逐项列表的括号和箭头作为节点引用,而不是进行故障排除以将它们置于大致正确的位置。
答案1
该解决方案使用蒂克兹马克并涉及将itemize
环境转变为enumerate
使用label
选项枚举项。列表看上去完全一样,但是项目编号用于将项目符号转换为子节点,可在图片的后面引用。
\documentclass[tikz, border=10pt, multi]{standalone}
\usepackage{calc,enumitem}
\usetikzlibrary{arrows.meta,decorations.pathreplacing,decorations.text,tikzmark}
\begin{document}
\begin{tikzpicture}[remember picture]
\node[below, text width=5cm] (SomeName) at (0,0) {%
\begin{enumerate}[label={\subnode{it\arabic*}{\textbullet}}]
\item line 1
\item line 2
\item line 3
\item line 4
\item line 5
\end{enumerate}%
};
\node[below, text width=2cm] (Other) at (-5,0) {Some text will go here.};
\node[below, text width=2cm] (Another) at (-5,-4) {Some text will go here.};
\draw[decorate,decoration={brace,amplitude=7pt,mirror}] (it3.north west) -- (it4.south west) node[midway,left] (A) {};
\draw[-Stealth] (it2) -- (Other.east);
\draw[-Stealth] ([xshift=-2.5pt]A.west) -- (Another.east);
\end{tikzpicture}
\end{document}
答案2
我使用了sremember picture
选项来允许在不同中定义的 stikzpicture
之间的连接node
tikzpicture
(参见手动的)。我曾经minipage
安排了三个块,但其他解决方案也是可能的。为了克服node
包含$bullet$
我提到这个答案。
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usepgflibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.text}
\usepackage{calc}
\usepackage{enumitem}
\begin{document}
\begin{minipage}{3cm}
\begin{minipage}{3cm}
\tikz[remember picture]\node (n1) {Some text will go here};
\end{minipage}
\\[1cm]
\begin{minipage}{3cm}
\tikz[remember picture]\node (n2) {Some text will go here};
\end{minipage}
\end{minipage}
\hspace{10mm}
\begin{minipage}{.5\textwidth}
\begin{itemize}
\item line 1
\item[{\tikz[remember picture]\node[inner xsep=5pt,inner ysep=0] (t2) {$\bullet\hspace{-5pt}$};}] line 2
\item[{\tikz[remember picture]\node[inner sep=0] (t3) {$\bullet$};}] line 3
\item[{\tikz[remember picture]\node[inner sep=0] (t4) {$\bullet$};}] line 4
\item line 5
\end{itemize}
\end{minipage}
\begin{tikzpicture}[overlay,remember picture]
\path[->] (n1.east) edge [out=0 , in=180] (t2.west);
\draw[decorate,decoration={brace,raise=5pt},thick] (t4.south west) -- node[left,anchor=east,inner xsep=5pt] (t34) {} (t3.north west);
\path[->] (n2.east) edge [out=0 , in=180] (t34.west);
\end{tikzpicture}
\end{document}