在另一条路径的装饰上开始一条路径

在另一条路径的装饰上开始一条路径

在下面的代码中,我想将加号连接到包含2 * 3 + 11 = 17。我有一个连接,但这不是我想要的。

我不希望小红线被绿色划掉,而是想要一条从加号开始的线。

我错过了什么?

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows, matrix}

\tikzset{ope/.style={circle,draw,fill=white,inner sep=1pt, outer sep=1pt},
block/.style={
  rectangle,
  draw=blue,
  thick,
  fill=blue!20,
  text width=5em,
  align=center,
  rounded corners,
  minimum height=2em},
blur/.style={opacity=0.3},
focus/.style={rectangle,
  thick,
  rounded corners,
  minimum height=2em,
  align=center,
  draw=red,
  text=magenta}}    

\begin{document}

% Source for decorated paths
%    * https://tex.stackexchange.com/a/507419/6880

\begin{tikzpicture}
  \matrix[matrix of nodes,
    row sep  = 1em,
    column sep = 1.5em
  ](mat){
                &  9665              &              && |[focus]| {$2 \times 3 + 11 = 17$}  \\
    |[block]| 2 &  |[blur]|488888887 & |[block]| 3                                         \\
                &  777               & |[block]| 11                                        \\
                &                    &  99                                                 \\
    };

  \draw[red] (mat-2-1) -- (mat-2-3) node[midway,draw,ope]{$\times$};

  \draw[red] (mat-2-3.east) -- ++ (1,0) -| ++ (0,-.5) coordinate[pos=0.5] (aux) |- (mat-3-3.east);

  \draw[red] (mat-3-3.east) -| (aux) node[pos=0.75,draw,ope]{$+$}  -| (mat-1-5.south);

  \draw[red,-triangle 60] (mat-1-5.west) -- ++ (-1,0); 
\end{tikzpicture}

\end{document}

答案1

如何用它positioning来定位新节点(而不是将其放入矩阵中)?

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows, matrix,positioning}

\tikzset{ope/.style={circle,draw,fill=white,inner sep=1pt, outer sep=1pt},
block/.style={
  rectangle,
  draw=blue,
  thick,
  fill=blue!20,
  text width=5em,
  align=center,
  rounded corners,
  minimum height=2em},
blur/.style={opacity=0.3},
focus/.style={rectangle,
  thick,
  rounded corners,
  minimum height=2em,
  align=center,
  draw=red,
  text=magenta}}


\begin{document}

% Source for decorated paths
%    * https://tex.stackexchange.com/a/507419/6880

\begin{tikzpicture}
  \matrix[matrix of nodes,
    row sep  = 1em,
    column sep = 1.5em
  ](mat){
                &  9665              &              \\
    |[block]| 2 &  |[blur]|488888887 & |[block]| 3                                         \\
                &  777               & |[block]| 11                                        \\
                &                    &  99                                                 \\
    };

  \draw[red] (mat-2-1) -- (mat-2-3) node[midway,draw,ope]{$\times$};

  \draw[red] (mat-2-3.east) -- ++ (1,0) |- (mat-3-3.east)
   node[pos=0.25,draw,ope](plus){$+$}
   node[above right=1cm and 1cm of plus,focus] (f){$2 \times 3 + 11 = 17$} ;    
  \draw[red,-triangle 60] (plus) -| (f) (f.west) --  ++(-1,0); 
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容