我一直在嘗試創建我的第二個 Tikz 模型TikZ:感知器圖。我已經設法根據我的初學者知識和實驗對其進行修改,但是我缺少的部分並且我不知道如何製作子彈。我正在嘗試縮小距離,但沒有影響。我嘗試過distance node = 1 em
但暫時沒有成功。我的問題有可能的解決方案嗎?提供了輸出範例。任何建議表示讚賞。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc} % braces {}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\tikzset{
block/.style={
draw,
rectangle,
minimum height=2em,
minimum width=5em,
},
sum/.style={
draw,
circle,
minimum size=2em
},
input/.style={coordinate},
output/.style={coordinate},
mytext/.style={
draw,
text depth=4pt,
text height=10pt
}
}
\begin{figure}[!ht]
\begin{center}
\makebox[\textwidth][c]{%
\begin{tikzpicture}[auto,>=latex']
% Blocks
\node[input, name = input] {};
\node[sum, right = of input, node distance = 1em] (sum) {MP};
\node[block, right of = sum, node distance = 6.5em] (stream) {Stream $2$};
\node[sum, right = of stream, node distance = 1em] (filter) {$F_2$};
\node[sum, above = of sum, node distance = 5em] (sum_2) {MP};
\node[block, right of = sum_2, node distance = 6.5em] (stream_2) {Stream$1$};
\node[sum, right = of stream_2, node distance = 1em] (filter_2) {$F_1$};
% Bullets
\node[below of = sum, node distance = 3em] (dot) {$\bullet$} -- (dot);
\node[below of = dot, node distance = 1em] (dot_2) {$\bullet$} -- (dot_2);
\node[below of = dot_2, node distance = 1em] (dot_3) {$\bullet$} -- (dot_3);
\node[below of = stream, node distance = 3em] (dot_4) {$\bullet$} -- (dot_4);
\node[below of = dot_4, node distance = 1em] (dot_5) {$\bullet$} -- (dot_5);
\node[below of = dot_5, node distance = 1em] (dot_6) {$\bullet$} -- (dot_6);
\node[below of = filter, node distance = 3em] (dot_7) {$\bullet$} -- (dot_7);
\node[below of = dot_7, node distance = 1em] (dot_8) {$\bullet$} -- (dot_8);
\node[below of = dot_8, node distance = 1em] (dot_9) {$\bullet$} -- (dot_9);
% Blocks
\node[input, name = input_n] {};
\node[sum, below = of dot_3, node distance = 1em] (sum_n) {MP};
\node[block, right of = sum_n, node distance = 6.5em] (stream_n) {Stream $n$};
\node[sum, right = of stream_n, node distance = 1em] (filter_n) {$F_n$};
% Sum
\node[sum, right = of filter, node distance = 3em] (total) {$\sum$};
% Oneway delay
\node[block, right of = total, node distance = 7.5em] (delay) {One Way Delay};
\node[block, right of = delay, node distance = 15em] (segments) {$MP_1$ $|$ $Payload_1$ $\dots$ $MP_n$ $|$ $Payload_n$};
\node[output,right = of segments] (output) {};
% Inputs
\node[input,left = of sum_2] (output_2) {};
\node[input,left = of sum_n] (output_n) {};
% Lines Center Block
\draw[->] (input) -- node [name = begging] {$IN_2$} (sum);
\draw[->] (sum) -- node {} (stream);
\draw[->] (stream) -- node {} (filter);
\draw[->] (filter) -- node {} (total);
\draw[->] (total) -- node {} (delay);
\draw[->] (delay) -- node {} (segments);
\draw[->] (segments) -- node {Data} (output);
% Lines Above Center Block
\draw[->] (sum_2) -- node {} (stream_2);
\draw[->] (stream_2) -- node {} (filter_2);
\draw[->] (filter_2) -- node {} (total);
% Lines Below Center Block
\draw[->] (sum_n) -- node {} (stream_n);
\draw[->] (stream_n) -- node {} (filter_n);
\draw[->] (filter_n) -- node {} (total);
% Input Lines
\draw[->] (output_2) -- node {$IN_1$} (sum_2);
\draw[->] (output_n) -- node {$IN_n$} (sum_n);
\end{tikzpicture} }% End of makebox
\caption{New Tikz}
\label{fig:tikz }
\end{center}
\end{figure}
\end{document}
答案1
我建議您採用不同的方法來保持層之間的間距一致:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc} % braces {}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\tikzset{
block/.style={
draw,
rectangle,
minimum height=2em,
minimum width=5em,
},
sum/.style={
draw,
circle,
minimum size=2em
},
input/.style={coordinate},
output/.style={coordinate},
mytext/.style={
draw,
text depth=4pt,
text height=10pt
}
}
\begin{figure}[!ht]
\begin{center}
\makebox[\textwidth][c]{%
\begin{tikzpicture}[auto,>=latex']
% Blocks
\node[input, name = input] {};
\node[sum, right = of input, node distance = 1em] (sum) {MP};
\node[block, right of = sum, node distance = 6.5em] (stream) {Stream $2$};
\node[sum, right = of stream, node distance = 1em] (filter) {$F_2$};
\node[sum, above = of sum, node distance = 5em] (sum_2) {MP};
\node[block, right of = sum_2, node distance = 6.5em] (stream_2) {Stream$1$};
\node[sum, right = of stream_2, node distance = 1em] (filter_2) {$F_1$};
% Blocks
\node[input, name = input_n] {};
\node[sum, below = of sum, node distance = 1em] (sum_n) {MP};
\node[block, right of = sum_n, node distance = 6.5em] (stream_n) {Stream $n$};
\node[sum, right = of stream_n, node distance = 1em] (filter_n) {$F_n$};
% Bullets
\foreach \Nodo in {sum,stream,filter}
{
\node[rotate=90,font=\footnotesize] (dot)
at ( $ (\Nodo)!0.5!(\Nodo_n) $ ) {$\bullet\bullet\bullet$};
}
% Sum
\node[sum, right = of filter, node distance = 3em] (total) {$\sum$};
% Oneway delay
\node[block, right of = total, node distance = 7.5em] (delay) {One Way Delay};
\node[block, right of = delay, node distance = 15em] (segments) {$MP_1$ $|$ $Payload_1$ $\dots$ $MP_n$ $|$ $Payload_n$};
\node[output,right = of segments] (output) {};
% Inputs
\node[input,left = of sum_2] (output_2) {};
\node[input,left = of sum_n] (output_n) {};
% Lines Center Block
\draw[->] (input) -- node [name = begging] {$IN_2$} (sum);
\draw[->] (sum) -- node {} (stream);
\draw[->] (stream) -- node {} (filter);
\draw[->] (filter) -- node {} (total);
\draw[->] (total) -- node {} (delay);
\draw[->] (delay) -- node {} (segments);
\draw[->] (segments) -- node {Data} (output);
% Lines Above Center Block
\draw[->] (sum_2) -- node {} (stream_2);
\draw[->] (stream_2) -- node {} (filter_2);
\draw[->] (filter_2) -- node {} (total);
% Lines Below Center Block
\draw[->] (sum_n) -- node {} (stream_n);
\draw[->] (stream_n) -- node {} (filter_n);
\draw[->] (filter_n) -- node {} (total);
% Input Lines
\draw[->] (output_2) -- node {$IN_1$} (sum_2);
\draw[->] (output_n) -- node {$IN_n$} (sum_n);
\end{tikzpicture} }% End of makebox
\caption{New Tikz}
\label{fig:tikz }
\end{center}
\end{figure}
\end{document}
這個想法是首先繪製所有區塊,然後使用calc
庫(您已經加載)將子彈精確地放置在第二層和第三層之間的中間(這可以透過單一循環完成):
% Bullets
\foreach \Nodo in {sum,stream,filter}
{
\node[rotate=90,font=\footnotesize] (dot)
at ( $ (\Nodo)!0.5!(\Nodo_n) $ ) {$\bullet\bullet\bullet$};
}
答案2
只需使用小於 的尺寸1em
。下面我用過0.7em
:
筆記:
- 對於垂直間距,應使用
ex
尺寸而不是em
( 應用於水平距離。
代碼:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc} % braces {}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\tikzset{
block/.style={
draw,
rectangle,
minimum height=2em,
minimum width=5em,
},
sum/.style={
draw,
circle,
minimum size=2em
},
input/.style={coordinate},
output/.style={coordinate},
mytext/.style={
draw,
text depth=4pt,
text height=10pt
}
}
\begin{figure}[!ht]
\begin{center}
\makebox[\textwidth][c]{%
\begin{tikzpicture}[auto,>=latex']
% Blocks
\node[input, name = input] {};
\node[sum, right = of input, node distance = 1em] (sum) {MP};
\node[block, right of = sum, node distance = 6.5em] (stream) {Stream $2$};
\node[sum, right = of stream, node distance = 1em] (filter) {$F_2$};
\node[sum, above = of sum, node distance = 5em] (sum_2) {MP};
\node[block, right of = sum_2, node distance = 6.5em] (stream_2) {Stream$1$};
\node[sum, right = of stream_2, node distance = 1em] (filter_2) {$F_1$};
% Bullets
\node[below of = sum, node distance = 3em] (dot) {$\bullet$} -- (dot);
\node[below of = dot, node distance = 0.7em] (dot_2) {$\bullet$} -- (dot_2);
\node[below of = dot_2, node distance = 0.7em] (dot_3) {$\bullet$} -- (dot_3);
\node[below of = stream, node distance = 3em] (dot_4) {$\bullet$} -- (dot_4);
\node[below of = dot_4, node distance = 0.7em] (dot_5) {$\bullet$} -- (dot_5);
\node[below of = dot_5, node distance = 0.7em] (dot_6) {$\bullet$} -- (dot_6);
\node[below of = filter, node distance = 3em] (dot_7) {$\bullet$} -- (dot_7);
\node[below of = dot_7, node distance = 0.7em] (dot_8) {$\bullet$} -- (dot_8);
\node[below of = dot_8, node distance = 0.7em] (dot_9) {$\bullet$} -- (dot_9);
% Blocks
\node[input, name = input_n] {};
\node[sum, below = of dot_3, node distance = 1em] (sum_n) {MP};
\node[block, right of = sum_n, node distance = 6.5em] (stream_n) {Stream $n$};
\node[sum, right = of stream_n, node distance = 1em] (filter_n) {$F_n$};
% Sum
\node[sum, right = of filter, node distance = 3em] (total) {$\sum$};
% Oneway delay
\node[block, right of = total, node distance = 7.5em] (delay) {One Way Delay};
\node[block, right of = delay, node distance = 15em] (segments) {$MP_1$ $|$ $Payload_1$ $\dots$ $MP_n$ $|$ $Payload_n$};
\node[output,right = of segments] (output) {};
% Inputs
\node[input,left = of sum_2] (output_2) {};
\node[input,left = of sum_n] (output_n) {};
% Lines Center Block
\draw[->] (input) -- node [name = begging] {$IN_2$} (sum);
\draw[->] (sum) -- node {} (stream);
\draw[->] (stream) -- node {} (filter);
\draw[->] (filter) -- node {} (total);
\draw[->] (total) -- node {} (delay);
\draw[->] (delay) -- node {} (segments);
\draw[->] (segments) -- node {Data} (output);
% Lines Above Center Block
\draw[->] (sum_2) -- node {} (stream_2);
\draw[->] (stream_2) -- node {} (filter_2);
\draw[->] (filter_2) -- node {} (total);
% Lines Below Center Block
\draw[->] (sum_n) -- node {} (stream_n);
\draw[->] (stream_n) -- node {} (filter_n);
\draw[->] (filter_n) -- node {} (total);
% Input Lines
\draw[->] (output_2) -- node {$IN_1$} (sum_2);
\draw[->] (output_n) -- node {$IN_n$} (sum_n);
\end{tikzpicture} }% End of makebox
\caption{New Tikz}
\label{fig:tikz }
\end{center}
\end{figure}
\end{document}