2

How do I create the dotted box? For the rest of the diagram I used a matrix, but I'm having trouble creating that box. Here's the code I used.

\begin{center}
$\begin{matrix}
$ x(n)$\rightarrow \boxed{T} \rightarrow \boxed{[ \hspace{0.25 cm}]^2} \rightarrow &\bigoplus& \rightarrow T[x(n)]$ $\\
$$&\uparrow&$ $\\
$$& 7&$
$ \end{matrix} $
\end{center}

2

Two approaches:

enter image description here

  1. The first one uses your code (slightly modified) and the tikzmark library from TikZ to place some marks in the diagram; those marks are then used to draw the dashed box (the document needs to be processed twice to stabilize).

  2. The whole diagram is drawn using TikZ; I used a chain, but other approaches are possible, of course. Then the fit library was used to draw the dashed box.

The code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{tikzmark,chains,fit,positioning}

\begin{document}

\[
\begin{matrix}
 x(n)\rightarrow\tikzmark{start}\boxed{T} \rightarrow \boxed{[ \hspace{0.25 cm}]^2} \rightarrow & \bigotimes\tikzmark{end} & \rightarrow T[x(n)] \\
&\uparrow& \\
& 7&
\end{matrix}
\]

\begin{tikzpicture}[remember picture,overlay]
\draw[dashed]
  ([shift={(-8pt,-1cm)}]pic cs:start) 
    rectangle
  ([shift={(15pt,0.7cm)}]pic cs:end); 
\end{tikzpicture}

\[
\begin{tikzpicture}[
  start chain,
  every join/.style={->},
  shorten >= 5pt,
  shorten <= 5pt,
  node distance=0.8cm and 0.8cm
]
\node[on chain,join] {$x(n)$};
\node[draw,on chain,join] (T) {$T$};
\node[draw,on chain,join] {$[\hspace{0.25 cm}]^2$}; 
\node[draw,circle,on chain,join] (otimes) {$\times$};
\node[on chain,join] {$T[x(n)]$};
\node[below=of otimes] (seven) {$7$};
\draw[->] (seven) -- (otimes); 
\node[draw,inner xsep=12pt,dashed,fit={(T) (otimes) (seven)}] {};
\end{tikzpicture}
\]

\end{document}
|improve this answer|||||
2

TiKZ, of course, is a better solution:

enter image description here

Here I use a simple approach with positioning library to automatically place your figure elements. To create the dashed box, fit library again is the best choice.

\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{fit,positioning,arrows}
\begin{document}

\begin{tikzpicture}[>=latex',node distance=.7cm]
\node(xn) {$x(n)$};
\node(bt) [right=of xn,draw]{$T$};
\node(sq) [right=of bt,draw]{$[\hspace{0.25cm}]^2$};
\node(ot) [circle,draw,right=of sq,inner sep=0pt]{$\times$};
\node(tx) [right=of ot]{$T[x(n)]$};
\node(sv) [below=of ot,outer sep=0pt]{7};
\node[draw,inner sep=7pt,dashed,fit={(bt) (ot) (sv)}] {};
\path[->](xn)edge(bt)
         (bt)edge(sq)
         (sq)edge(ot)
         (ot)edge(tx)
         (sv)edge(ot);
\end{tikzpicture}

\end{document}
|improve this answer|||||

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.