Hello graphic tex lovers 🙂
I'm trying to draw a diagram in TikZ as close as possible to this one:
I'm using the dsp TikZ library and I think my attempt is going in the right direction; however there are a few things I didn't manage to set up properly, as you can see from the MWE
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{dsp,chains}
\begin{document}
\begin{tikzpicture}
% Blocks and nodes
\node[dspnodeopen,dsp/label=below] (ns) {$v(t)$};
\node[dspmultiplier,left=of ns,fill=gray] (mic) {};
\node[dspadder,left=of mic,left=1.5cm] (add) {};
\node[coordinate,left=of add,left=2.35cm] (fp1) {};
\node[dspfilter,above=of fp1,above=1.5cm] (gain) {$G$};
\node[coordinate,above=of gain,above=1.5cm] (fp2) {};
\node[dspnodefull,right=of fp2,right=2.55cm] (adnode) {$u(t)$};
\node[dspfilter,right=of gain,right=1.15cm] (adfilt) {$\hat{F}$};
\node[dspsquare,right=of fp2,right=4cm] (ls) {};
\node[dspfilter,right=of gain,right=4cm] (feedback) {F};
\node[dspnodefull,left=of add] (afupd1) {};
\node[coordinate,above=of afupd1,above=1cm] (afupd2) {};
\node[coordinate,right=of adfilt,above=3.5cm,right=0.5cm] (afupd3) {};
% Connections
\draw[dspconn] (ns) -- (mic);
\draw[dspline] (mic) -- node[midway,below=0.09cm] {$y(t)$} (add);
\draw[dspline] (add) -- node[midway,below] {$d[t,\hat{\mathbf{f}}(t)]$} (fp1);
\draw[dspline,dashed] (afupd1) -- (afupd2);
\draw[dspconn,dashed] (afupd2) -- (afupd3);
\draw[dspconn] (fp1) -- (gain);
\draw[dspline] (gain) -- (fp2);
\draw[dspline] (fp2) -- (adnode);
\draw[dspline] (adnode) -- (ls);
\draw[dspconn] (adnode) -- (adfilt);
\draw[dspconn] (adfilt) -- node[midway,right] {$\hat{y}[t |\hat{\mathbf{f}}(t)]$} (add);
\draw[dspconn] (ls) -- (feedback);
\draw[dspconn] (feedback) -- (mic);
\end{tikzpicture}
\end{document}
This is what my MWE looks like:
Namely, the things I couldn't properly recreate are:
- the microphone and loudspeaker symbols (those gray blocks)
- the vertical alignment of the filter blocks
- the right positioning of the dashed olique line (it should cut the block with \hat{F} right in the middle)
- curved lines to and from the filter block with F
- plus and minus signs in the adder.
Is anybody willing to help this poor TikZ user?
Thanks 😉
Best Answer
One possibility:
The answers to specific questions:
Use standard TikZ shapes. The speaker, for example, is simply a rotated
trapezium
from theshapes.geometric
library.No need for additional tweaks. You can use the standard
minimum height
key for thedspfilter
nodes.I placed an auxiliary coordinate at
adfilt.center
(slightly shifted downwards to preven the line from overlapping the "F") and then used the( $ (<name1>)!<length>!(<name2>) $ )
from the calc library.You can use
to[out=<angle1>,in=<angle2>]
.I placed the desired labels to the
add
node.In a comment, some problem with cut labels was mentioned when including the figure from an external file. In this case, I'd suggest you to use the
standalone
class to produce your image as a separate pdf file that then can be easily included in your document using the standard\includegraphics
mechanism fromgraphicx
; you can use theborder
option for standalone to control the padding around your figure, in case it is required:For example, save the following as, say,
MyImage.tex
:After processing it through
pdflatex
you'll get aMyImage.pdf
file looking like (gray area around the figure is not part of the resulting pdf):Then you can use
in your
.tex
file to include the image. You can control individual margins with theboder
key (refer to the standalone documentation).