如何在节点的文本区域{}中使用 \pic?

如何在节点的文本区域{}中使用 \pic?

我如何才能让 \pic“闪电”出现在节点的文本区域中?我无法在那里使用它,所以我把它注释掉了。我知道或认为这是一个完全不同的“环境”(节点的文本区域),但我发现可以在那里放置相当复杂的东西,例如。tikz 节点内单词之间的小 tikz 装饰箭头 还有其他方法吗?希望我已经解决了这个问题。

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows,arrows.meta,calc}


\begin{document}

\tikzset{%
pics/lightning/.style 2 args={code={%
   \draw[ arrows={-Stealth[scale=2]}] (#1) --
      ($(#1)!.4!(#2) + (.1,-.1)$) --
      ($(#1)!.4!(#2) + (-.1,.1)$) --
      (#2);
      }},
information text/.style={rounded corners,fill=red!10,inner sep=1em}%
}%end tikzset

\begin{tikzpicture}%
[%
 every node/.style={%
    inner sep=0pt},%
]%
   %\draw[help lines, use as bounding box] (-7,-3) grid (7,3);
\begin{scope}[ text height=1.0em, text depth=.25em,]

   \node (advbo)                       {\textit{Adverbiale Bestimmung}};
   \node (so)    [left =.9mm of advbo] {\textit{Substantiv}};
   \node (ao)    [left =.9mm of so]    {\textit{Artikel}};
   \node (ko)    [left =.9mm of ao]    {\textit{Komparativ}};

   \node (l)     [below= of ko]        {Lieber};
   \node (e1)    [below= of ao]        {einen};
   \node (s)     [below= of so]        {Spatz};
   \node (i)     [below= of advbo]     {in der Hand,};

   \node (a)     [below=.3mm of l]     {als};
   \node (e2)    [below=.3mm of e1]    {eine};
   \node (t)     [below=.3mm of s]     {Taube};
   \node (ad)    [below=.3mm of i]     {auf dem Dach.};

   \node (ku)    [below= of a]         {\textit{Konjunktion}};
   \node (au)    [below= of e2]        {\textit{Artikel}};
   \node (su)    [below= of t]         {\textit{Substantiv}};
   \node (advbu) [below= of ad]        {\textit{Adverbiale Bestimmung}};
\end{scope}

   \pic [red] {lightning={ko}{l}};
   \pic [red, rotate=180]{lightning={ku}{a}};

   \draw[->,>=stealth', very thick, red, opacity=.5] (ao)    to (e1);
   \draw[->,>=stealth', very thick, red, opacity=.5] (au)    to (e2);

   \draw[->,>=stealth', very thick, red, opacity=.5] (so)    to (s);
   \draw[->,>=stealth', very thick, red, opacity=.5] (su)    to (t);

   \draw[->,>=stealth', very thick, red, opacity=.5] (advbo) to (i);
   \draw[->,>=stealth', very thick, red, opacity=.5] (advbu) to (ad);

   \draw[xshift=2.75cm,yshift=-1.8cm]
      node[right,text width=4cm,information text]
      {
         Parallelismus, der nicht ganz konsequent durchgestaltet ist, denn hier
         %\pic [red] {lightning={ao}{t}}%HELP APPRECIATED HERE
         stimmen die Wortarten nicht "uberein.
      };
   \pic [red] {lightning={ao}{ad}};%IT WORKS BUT NOT ABOVE?!
\end{tikzpicture}
\end{document}

答案1

展示比解释要容易得多。

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows,arrows.meta,calc}

\newsavebox{\tempbox}

\begin{document}

\tikzset{%
pics/lightning/.style 2 args={code={%
   \draw[ arrows={-Stealth[scale=2]}] (#1) --
      ($(#1)!.4!(#2) + (.1,-.1)$) --
      ($(#1)!.4!(#2) + (-.1,.1)$) --
      (#2);
      }},
information text/.style={rounded corners,fill=red!10,inner sep=1em}%
}%end tikzset

\savebox{\tempbox}{\tikz{\coordinate (a) at (0,0);
  \coordinate (b) at (4cm,-1cm);
  \pic [red] {lightning={a}{b}};}}

\begin{tikzpicture}%
[%
 every node/.style={%
    inner sep=0pt},%
]%
   %\draw[help lines, use as bounding box] (-7,-3) grid (7,3);
\begin{scope}[ text height=1.0em, text depth=.25em,]

   \node (advbo)                       {\textit{Adverbiale Bestimmung}};
   \node (so)    [left =.9mm of advbo] {\textit{Substantiv}};
   \node (ao)    [left =.9mm of so]    {\textit{Artikel}};
   \node (ko)    [left =.9mm of ao]    {\textit{Komparativ}};

   \node (l)     [below= of ko]        {Lieber};
   \node (e1)    [below= of ao]        {einen};
   \node (s)     [below= of so]        {Spatz};
   \node (i)     [below= of advbo]     {in der Hand,};

   \node (a)     [below=.3mm of l]     {als};
   \node (e2)    [below=.3mm of e1]    {eine};
   \node (t)     [below=.3mm of s]     {Taube};
   \node (ad)    [below=.3mm of i]     {auf dem Dach.};

   \node (ku)    [below= of a]         {\textit{Konjunktion}};
   \node (au)    [below= of e2]        {\textit{Artikel}};
   \node (su)    [below= of t]         {\textit{Substantiv}};
   \node (advbu) [below= of ad]        {\textit{Adverbiale Bestimmung}};
\end{scope}

   \pic [red] {lightning={ko}{l}};
   \pic [red, rotate=180]{lightning={ku}{a}};

   \draw[->,>=stealth', very thick, red, opacity=.5] (ao)    to (e1);
   \draw[->,>=stealth', very thick, red, opacity=.5] (au)    to (e2);

   \draw[->,>=stealth', very thick, red, opacity=.5] (so)    to (s);
   \draw[->,>=stealth', very thick, red, opacity=.5] (su)    to (t);

   \draw[->,>=stealth', very thick, red, opacity=.5] (advbo) to (i);
   \draw[->,>=stealth', very thick, red, opacity=.5] (advbu) to (ad);


   \draw[xshift=2.75cm,yshift=-1.8cm]
      node[right,text width=4cm,information text]
      {
         Parallelismus, der nicht ganz konsequent durchgestaltet ist, denn hier
         \usebox{\tempbox}
         stimmen die Wortarten nicht "uberein.
      };
   \pic [red] {lightning={ao}{ad}};%IT WORKS BUT NOT ABOVE?!
\end{tikzpicture}
\end{document}

相关内容