0

I just tried to draw a block diagram with tikzpicture using the dsp library. It all worked correctly until I tried to add the caption to it.

The problem is that the vertical space between the tikzpicture and the caption is too small:

Caption get too close to picture

Here is my source code:

\documentclass[12pt, a4paper, bibliography=totoc, listof=totoc, 
 numbers=noendperiod, abstracton, parskip=half, headsepline
 %, plainheadsepline
]{scrreprt}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,dsp,chains,calc}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}
\newcommand{\z}{\mathpzc{z}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix (m1) [row sep=15mm, column sep=20mm]
{
    %------------------------------------------
    \node[dspnodeopen,dsp/label=above] (m00) {$x[n]$};    &
    \node[dspnodeopen]                 (m01) {};        &
    \node[dspnodeopen]                 (m02) {};        &
    \node[dspnodeopen]                 (m03) {};        &
    \node[dspnodeopen]                 (m04) {};        &
    \node[dspnodeopen]                 (m05) {};        \\
    %------------------------------------------
    \node[coordinate]                  (m10) {};        &
    \node[coordinate]                  (m11) {};        &
    \node[coordinate]                  (m12) {};        &
    \node[coordinate]                  (m13) {};        &
    \node[coordinate]                  (m14) {};        &
    \node[coordinate]                  (m15) {};  \\
    %------------------------------------------
    \node[coordinate]                  (m20) {};        &
    \node[coordinate]                  (m21) {};        &
    \node[coordinate]                  (m22) {};        &
    \node[coordinate]                  (m23) {};        &
    \node[coordinate]                  (m24) {};        &
    \node[coordinate]                  (m25) {};  \\
    %------------------------------------------
    \node[coordinate]                   (m30) {};        &
    \node[dspnodeopen,dsp/label=below]  (m31) {$B[0]$};  &
    \node[dspnodeopen,dsp/label=below]  (m32) {$B[1]$};  &
    \node[dspnodeopen,dsp/label=below]  (m33) {$B[2]$};  &
    \node[dspnodeopen,dsp/label=below]  (m34) {$B[3]$};  &
    \node[dspnodeopen,dsp/label=below]  (m35) {$B[128]$};  \\
};

\draw[dspflow] (m00) -- (m01);

\foreach \i [evaluate = \i as \j using int(\i+1)] in {1,2,3}
    \draw[dspflow] (m0\i) -- node[midway,above] {$\z^{-1}$} (m0\j);

\path (m04) -- node[auto=false]{\ldots} (m05);

\foreach \i [evaluate = \i as \j using int(\i-1)] in {1,2,...,4}
    \draw[dspflow] (m0\i) -- node[midway,right] {$h[\j]$} (m1\i);
\draw[dspflow] (m05) --node[midway,right] {$h[128]$} (m15);

\draw ($(m11) - (2mm,0)$) rectangle node[midway] {128-Punkt FFT} ($(m25) + (2mm,0)$);

\foreach \i [evaluate = \i as \j using int(\i-1)] in {1,2,...,4}
    \draw[dspflow] (m2\i) --  (m3\i);
\draw[dspflow] (m25) -- (m35);

\end{tikzpicture}

\caption{Blockschaltbild einer 128-Punkt FFT-Filterbank}
\label{fig:fft128}
\end{figure}
\end{document}
7
  • 1
    please make your code compilable! add \documentclas{...} necessary preamble, and on the end \end{document}.
    – Zarko
    Jul 30, 2017 at 16:26
  • Your definition of dsp/label seems to be the culprit. Replacing \node[dspnodeopen,dsp/label=below] (<mxx>) {<text>}; with \node[dspnodeopen,label={below:<text>}] (<mxx>) {}; fixed the problem. But without a complete MWE we can't help you any further.
    – Mike
    Jul 31, 2017 at 21:47
  • have edited the source code, should be compilable. the solution with dsp/labe={below:text} dosen't solve the problem, when use that all text disapprear...
    – tyker1
    Aug 1, 2017 at 22:54
  • It can't be compiled without the library, which is not standard. Package tikz Error: I did not find the tikz library 'dsp'. ....
    – cfr
    Aug 1, 2017 at 22:55
  • you can download dsp library here:texample.net/media/tikz/examples/zip/tikz-dsp.zip
    – tyker1
    Aug 2, 2017 at 12:24

1 Answer 1

1

Quick fix: add \medskip between \end{tikzpicture} and \caption.

The reason is that the B[N] labels seem to not be considered for the bounding box of the tikzpicture. You can (as an alternative to \medskip) modify the bounding box manually, by adding

\useasboundingbox (current bounding box.north west) rectangle ([yshift=-2ex]current bounding box.south east);

right before \end{tikzpicture}.

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.