我的代码是:
\documentclass{article}
\usepackage{calligra}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage[utf8]{inputenc}
\begin{document}
\tikzstyle{block} = [draw, fill=blue!20, rectangle,
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!30, circle, node distance=1.5cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% Localizção dos Blocos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controlador};
\node [block, right of=controller, pin={[pinstyle]above:Pertubação},node distance=4cm] (system) {Conversor};
% We draw an edge between the controller and system block to
% calculate the coordinate u. We need it to place the measurement block.
\draw [->] (controller) -- node[name=u] {$d$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Medição};
% Conexão dos nós.
\draw [draw,->] (input) -- node {$V_{ref}$} (sum);
\draw [->] (sum) -- node {$V_{err}$} (controller);
\draw [->] (system) -- node [name=y] {$V_{out}$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$}
node [near end] {$V_{med}$} (sum);
\end{tikzpicture}
\end{document}
我想要的结果是
答案1
使用与减号相同的方法,只需将节点放在另一条路径上即可。具体来说,进入sum
节点的箭头:
\draw [->] (input) -- node {$V_{\mathrm{ref}}$} (sum) node[pos=0.95] {$+$};
其他事情:
- 我
\mathrm
在这里用了下标单词。 - 像艾伦一样,我也改成了
\tikzset{stylename/.style={...},...}
。 - 我添加了
positioning
库,并将 改为由其定义的语法,即right=of ...
而不是right of=...
。请参阅PGF/TikZ 中“right of=”和“right=of”之间的区别
\documentclass{article}
\usepackage{calligra}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning} % added positioning
\usepackage[utf8]{inputenc}
\tikzset{
block/.style={draw, fill=blue!20, rectangle,
minimum height=3em, minimum width=6em},
sum/.style={draw, fill=blue!30, circle, node distance=1.5cm},
input/.style={coordinate},
output/.style={coordinate},
pinstyle/.style={pin edge={to-,thin,black}}
}
\begin{document}
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex', on grid] % added on grid
% Localizção dos Blocos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right=of sum] (controller) {Controlador};
\node [block, right=4cm of controller, pin={[pinstyle]above:Pertubação}] (system) {Conversor};
% We draw an edge between the controller and system block to
% calculate the coordinate u. We need it to place the measurement block.
\draw [->] (controller) -- node[name=u] {$d$} (system);
\node [output, right=of system] (output) {};
\node [block, below=of u] (measurements) {Medição};
% Conexão dos nós.
\draw [->] (input) -- node {$V_{\mathrm{ref}}$} (sum) node[pos=0.95] {$+$};
\draw [->] (sum) -- node {$V_{\mathrm{err}}$} (controller);
\draw [->] (system) -- node [name=y] {$V_{\mathrm{out}}$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$}
node [near end] {$V_{\mathrm{med}}$} (sum);
\end{tikzpicture}
\end{document}
答案2
您只需将 添加label
到包含 的节点即可$-$
。我还将您的\tikzstyle
命令更改为\tikzset
。请参阅应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?。
\documentclass{article}
\usepackage{calligra}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage[utf8]{inputenc}
\begin{document}
\tikzset{block/.style = {draw, fill=blue!20, rectangle,
minimum height=3em, minimum width=6em},
sum/.style = {draw, fill=blue!30, circle, node distance=1.5cm},
input/.style = coordinate,
output/.style = coordinate,
pinstyle/.style = {pin edge={to-,thin,black}}
}
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% Localizção dos Blocos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controlador};
\node [block, right of=controller, pin={[pinstyle]above:Pertubação},node distance=4cm] (system) {Conversor};
% We draw an edge between the controller and system block to
% calculate the coordinate u. We need it to place the measurement block.
\draw [->] (controller) -- node[name=u] {$d$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Medição};
% Conexão dos nós.
\draw [draw,->,] (input) -- node {$V_{ref}$} (sum);
\draw [->] (sum) -- node {$V_{err}$} (controller);
\draw [->] (system) -- node [name=y] {$V_{out}$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99,label=above:$+$] {$-$}
node [near end] {$V_{med}$} (sum);
\end{tikzpicture}
\end{document}