引用文字方塊中的位置

引用文字方塊中的位置

我在 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的選項來允許不同 s 中定義的 stikzpicture之間的連接(請參閱 $17.13.1 中nodetikzpicture手動的)。我曾經minipage安排三個區塊,但其他解決方案也是可能的。node克服包含 I$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}

相關內容