1

I have the following MWE.

I would like to draw a border without including the $y_3$ (or s3 in the .tex file) -- so it would be a rectangle with its left upper corner changed so that it bypasses s3. Is there a way to create such a border, basically, a rectangular polygon, surrounding a set of nodes?

(EDIT: I was trying to do it using the last command in the tikz file.)

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{fit,chains}

\begin{document}

\begin{tikzpicture}[node distance=2cm]

  \node(s1) {$y_1$};
  \node(s2) [right of = s1] {$y_2$};
  \node(s3) [right of = s2]{$y_{3}$};
  \node(s4) [right of = s3]{$y_4$};
  \node(s5) [right of = s4]{$y_5$};

\draw [->] (s1) -- (s2) ;
\draw [->] (s2) -- (s3) ;
\draw [->] (s3) -- (s4) ;
\draw [->] (s4) -- (s5) ;


  \node(x1) [below of = s1]{$x_1$};
  \node(x2) [right of = x1] {$X_2$};
  \node(x3) [right of = x2] {$X_3$};
  \node(x4) [right of = x3] {$X_4$};
  \node(x5) [right of = x4] {$X_5$};

\draw [->] (s1) -- (x1) ;
\draw [->] (s2) -- (x2) ;
\draw [->] (s3) -- (x3) ;
\draw [->] (s4) -- (x4) ;
\draw [->] (s5) -- (x5) ;

\node[rectangle,draw=red, fit=(x3) (x4) (x5) (s4) (s5),inner sep=3mm,line width=1mm](rect2) {};

\end{tikzpicture}
\end{document}
3

If instead of a node you accept a non automatically drawn line ...

\documnentclass{article}

\usepackage{tikz}

\usetikzlibrary{fit,chains, calc}

\begin{document}

\begin{tikzpicture}[node distance=2cm]

  \node(s1) {$y_1$};
  \node(s2) [right of = s1] {$y_2$};
  \node(s3) [right of = s2]{$y_{3}$};
  \node(s4) [right of = s3]{$y_4$};
  \node(s5) [right of = s4]{$y_5$};

\draw [->] (s1) -- (s2) ;
\draw [->] (s2) -- (s3) ;
\draw [->] (s3) -- (s4) ;
\draw [->] (s4) -- (s5) ;


  \node(x1) [below of = s1]{$x_1$};
  \node(x2) [right of = x1] {$X_2$};
  \node(x3) [right of = x2] {$X_3$};
  \node(x4) [right of = x3] {$X_4$};
  \node(x5) [right of = x4] {$X_5$};

\draw [->] (s1) -- (x1) ;
\draw [->] (s2) -- (x2) ;
\draw [->] (s3) -- (x3) ;
\draw [->] (s4) -- (x4) ;
\draw [->] (s5) -- (x5) ;

\node[rectangle,draw=red, fit=(x3) (x4) (x5) (s4) (s5),inner sep=3mm,line width=1mm](rect2) {};

\draw[blue, line width=1mm] (x3.south west)-|(s5.north east) --($(s3.north)!0.5!(s4.north)$)|-($(s3.west)!0.5!(x3.west)$)--cycle;
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.