以下代码:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pagestyle{empty}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.misc}
\usepackage{bigints}
\usetikzlibrary{arrows}
\definecolor{tokloGrey}{rgb}{0.68,0.68,0.68}
\definecolor{tkblue}{rgb}{0,0.212,0.369}
\definecolor{tkred}{rgb}{1,0.064,0.064}
\newcommand{\A}{\underline{\mathrm{A}}}
\newcommand{\B}{\underline{\mathrm{B}}}
\newcommand{\bv}{\vec{\mathrm{b}}}
\newcommand{\bz}{\vec{\mathrm{b_z}}}
\newcommand{\CM}{\underline{\mathrm{C}}}
\newcommand{\D}{\underline{\mathrm{D}}}
% Zustandsvektor
\newcommand{\zv}{\dot{\vec{\mathrm{x}}}}
\newcommand{\xv}{\vec{\mathrm{x}}}
% Zustandsgrößen
\newcommand{\uC}[1]{\mathrm{u_{C_{#1}}}}
\newcommand{\iL}{\mathrm{i_L}}
% Reglervariablen
\newcommand{\K}[1]{\mathrm{k_{#1}}}
\newcommand{\kT}{\vec{\mathrm{k}}^{\mathrm{T}}}
\newcommand{\cT}{\vec{\mathrm{c}}^{\mathrm{T}}}
\newcommand{\edot}{\dot{\mathrm{e}}}
\newcommand{\uS}[1]{\mathrm{u_{#1}}(\mathrm{t})}
\newcommand{\w}{\mathrm{w}(\mathrm{t})}
\begin{document}
\tikzset{
input/.style={coordinate},
block/.style={draw, fill=white!20,rectangle,minimum height=2em,minimum width=2em},
sum/.style={draw,fill=white!20,circle,node distance=1.25cm},
output/.style={coordinate},
x0/.style = {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}},
dot/.style = {circle,fill,draw,inner sep=0pt,minimum size=1pt}
}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[auto,node distance=1.75cm,>=latex',scale=0.04]
\node [input, name=input] (input) {$\mathrm{w}$};
\node [sum,right of=input] (esum) {};
% PI-Regler
\node [block, right of=esum] (kI) {$\bigintssss$};
\node [block, above of=kI] (kP) {$\mathrm{k_p}$};
\node [block, right of=kI] (integrale) {$\mathrm{k_i}$};
\node [sum,right of=integrale] (usum) {};
\node [sum,right of=usum] (usum2) {};
\node [block, right of=usum2] (b) {$\B$};
\node [sum, right of=b] (sum) {};
\node [block, right of=sum] (integralx) {$\bigintssss$};
\node [block, right of=integralx] (c) {$\vec{\mathrm{c}}^{\mathrm{T}}$};
\node [block, below of=integralx] (A) {$\A$};
\node [block, below of=A] (kT) {$\mathrm{k_1}$};
\node [block, below of=kT] (kT2) {$\mathrm{k_2}$};
\node [output, name=output,right of=c,node distance=1.25cm] (output) {};
\draw[->] (input) -- node[name=u,align=left,below,font=\scriptsize] {$\mathrm{w}$} (esum);
\draw[->] (esum) -- node[name=edot,below,font=\scriptsize] {$\dot{\mathrm{e}}$} (kI);
\draw[->] (edot) |- (kP);
\draw[->] (kP) -| node[pos=0.99,left,font=\tiny] {$+$} (usum);
\draw[->] (kI) -- node[name=e,below] {} (integrale);
\draw[->] (integrale) -- node[name=uPI,below] {} (usum);
\draw[->] (usum2) -- node[name=u,above,font=\scriptsize] {$\mathrm{u}$} (b);
\draw[->] (usum) -- node[name=uPI,above,font=\scriptsize] {$\mathrm{u_{PI}}$} (usum2);
\draw[->] (b) -- (sum);
\draw[->] (sum) -- node[name=xdot,font=\scriptsize] {$\Delta\dot{\vec{x}}$} (integralx);
\draw[->] (integralx) -- node[name=x,font=\scriptsize] {$\Delta\vec{x}$} (c);
\draw[->] (x) |- (A);
\draw[->] (x) |- node[pos=0.745,above,font=\tiny] {\tiny$\Delta\iL$} (kT);
\draw[->] (x) |- node[pos=0.5,below,font=\tiny] {\tiny$\Delta\uC{2}$} (kT2);
\draw[->] (kT) -| node[pos=0.99,font=\tiny] {$+$} node[pos=0.99,right,font=\scriptsize] {$\mathrm{u_{ZR}}$} (usum2);
\draw[->] (kT2) -| (usum2);
\draw[->] (A) -| node[pos=0.99,font=\tiny] {\tiny$+$} (sum);
\draw[->] (c) -- node[name=y,align=center,above,font=\scriptsize] {$\mathrm{y}$} (output);
\end{tikzpicture}
\label{abb:strukturbild_Zustandsraum}
\end{figure}
\end{document}
产生以下图像:
但我想要一个从 $y$ 到 $w$ 之后的总和的箭头,如下所示:
我怎样才能实现这个目标?
答案1
主要问题的答案非常简单:将图表(除了您要求的箭头外)放在局部边界框(diagram
此处称为)中,然后添加
\draw[->] (y|-c) |- ([yshift=-1em]diagram.south) -| (esum);
原则上,您甚至不需要local bounding box
,您可以用 来current bounding box
代替,但我发现这种做法更简洁。
除了上述评论之外,还有一些题外的更改和建议:
- 您的图形对于标准文章类来说太宽,您无法
figure
在standalone
类中使用环境。当前修复:使用包使页面更宽geometry
。 - 请使用
positioning
库。below of=<node>
现在您可以说below=<distance> of <node>
,distance
实际上出现的垂直空间在哪里。我做了这些改变。 - 不要定义单字母宏。这可能会产生严重的副作用,例如当您使用其他引擎(例如)进行编译时
xelatex
。这只是不好的做法。
结果如下:
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\usetikzlibrary{positioning}%<- added
\usetikzlibrary{arrows.meta}%<- changed
\usepackage{bigints}
\definecolor{tokloGrey}{rgb}{0.68,0.68,0.68}
\definecolor{tkblue}{rgb}{0,0.212,0.369}
\definecolor{tkred}{rgb}{1,0.064,0.064}
\newcommand{\uC}[1]{\mathrm{u_{C_{#1}}}}
\newcommand{\iL}{\mathrm{i_L}}
\begin{document}
\tikzset{% maybe better define these locally but OK
input/.style={coordinate},
block/.style={draw, fill=white!20,rectangle,minimum height=2em,minimum width=2em},
sum/.style={draw,fill=white!20,circle,node distance=1.25cm},
output/.style={coordinate},
x0/.style = {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}},
dot/.style = {circle,fill,draw,inner sep=0pt,minimum size=1pt}
}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[auto,node distance=1cm,>=Latex]
\begin{scope}[local bounding box=diagram]
\node [input, name=input] (input) {$\mathrm{w}$};
\node [sum,right=of input] (esum) {};
% PI-Regler
\node [block, right=of esum] (kI) {$\bigintssss$};
\node [block, above=of kI] (kP) {$\mathrm{k_p}$};
\node [block, right=of kI] (integrale) {$\mathrm{k_i}$};
\node [sum,right=of integrale] (usum) {};
\node [sum,right=of usum] (usum2) {};
\node [block, right=of usum2] (b) {$\underline{\mathrm{B}}$};
\node [sum, right=of b] (sum) {};
\node [block, right=of sum] (integralx) {$\bigintssss$};
\node [block, right=of integralx] (c) {$\vec{\mathrm{c}}^{\mathrm{T}}$};
\node [block, below=of integralx] (A) {$\underline{\mathrm{A}}$};
\node [block, below=of A] (kT) {$\mathrm{k_1}$};
\node [block, below=of kT] (kT2) {$\mathrm{k_2}$};
\node [output, name=output,right=1.25cm of c] (output) {};
\draw[->] (input) -- node[name=u,align=left,below,font=\scriptsize] {$\mathrm{w}$} (esum);
\draw[->] (esum) -- node[name=edot,below,font=\scriptsize] {$\dot{\mathrm{e}}$} (kI);
\draw[->] (edot) |- (kP);
\draw[->] (kP) -| node[pos=0.99,left,font=\tiny] {$+$} (usum);
\draw[->] (kI) -- node[name=e,below] {} (integrale);
\draw[->] (integrale) -- node[name=uPI,below] {} (usum);
\draw[->] (usum2) -- node[name=u,above,font=\scriptsize] {$\mathrm{u}$} (b);
\draw[->] (usum) -- node[name=uPI,above,font=\scriptsize] {$\mathrm{u_{PI}}$} (usum2);
\draw[->] (b) -- (sum);
\draw[->] (sum) -- node[name=xdot,font=\scriptsize] {$\Delta\dot{\vec{x}}$} (integralx);
\draw[->] (integralx) -- node[name=x,font=\scriptsize] {$\Delta\vec{x}$} (c);
\draw[->] (x) |- (A);
\draw[->] (x) |- node[pos=0.745,above,font=\tiny] {$\Delta\mathrm{i_L}$} (kT);
\draw[->] (x) |- node[pos=0.5,below,font=\tiny] {\tiny$\Delta\uC{2}$} (kT2);
\draw[->] (kT) -| node[pos=0.99,font=\tiny] {$+$} node[pos=0.99,right,font=\scriptsize] {$\mathrm{u_{ZR}}$} (usum2);
\draw[->] (kT2) -| (usum2);
\draw[->] (A) -| node[pos=0.99,font=\tiny] {\tiny$+$} (sum);
\draw[->] (c) -- node[name=y,align=center,above,font=\scriptsize] {$\mathrm{y}$} (output);
%
\end{scope}
\draw[->] (y|-c) |- ([yshift=-1em]diagram.south) -| (esum);
\end{tikzpicture}
\label{abb:strukturbild_Zustandsraum}
\end{figure}
\end{document}