我正在使用tikz
LaTeX 中的包为控制系统构建反馈回路,这是一篇关于控制系统的论文的一部分。我遇到的问题是,除了当前位于箭头上方的符号之外,我还想在块之间的箭头下方放置符号。例如,我想在$phi$
箭头下方的符号下放置一个符号$tau$
。我不知道如何实现这一点,因为我对 LaTeX 和 还很陌生tikz
。任何帮助都将不胜感激。
我在下面嵌入了我的所有代码,以及反馈循环当前如何与代码一起出现的快照。
\documentclass[class=minimal,border=15pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\tikzstyle{block} = [draw, fill=gray!3, rectangle, minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=gray!3, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Regulator};
\node [block, right of=controller, node distance=3cm] (motor) {G$_{motor}$};
\node [block, right of=motor, pin={[pinstyle]above:Störningar},
node distance=3cm] (system) {Dynamik$_{\varphi}$};
\draw [->] (controller) -- node[name=u] {$u$} (motor);
\node [output, right of=system] (output) {};
\node [block, below of=motor] (msystem) {Mätsystem};
\draw [draw,->] (input) -- node {$\varphi_{ref}$} (sum);
\draw [->] (sum) -- node {$e$} (controller);
\draw [->] (motor) -- node {$\tau$} (system);
\draw [->] (system) -- node [name=y] {$\varphi$}(output);
\draw [->] (y) |- (msystem);
\draw [->] (msystem) -| node[pos=0.99] {$-$} node [near end] {$\varphi_m$} (sum);
\end{tikzpicture}
\end{document}
答案1
您可以label
在节点的选项中使用多个键:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[mynode/.style={draw,circle,minimum size=2cm}]
\node[mynode,label=left:$a$,label=right:$b$,label=60:$c$,label=220:$d$] {};
\end{tikzpicture}
\end{document}
就您而言,由于您已全局声明,因此需要采取额外的预防措施,因此您需要对具有多个标签的节点auto
使用:auto=false
\documentclass[class=minimal,border=15pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,arrows}
\tikzset{
block/.style = {draw, fill=gray!3, rectangle, minimum height=3em, minimum width=6em},
sum/.style = {draw, fill=gray!3, circle, node distance=1cm},
input/.style = {coordinate},
output/.style = {coordinate},
pinstyle/.style={pin edge={to-,thin,black}}
}
\begin{document}
\begin{tikzpicture}[node distance=1cm,>=latex']
\node [input, name=input] {};
\node [sum, right = of input] (sum) {};
\node [block, right = of sum] (controller) {Regulator};
\node [block, right = of controller, node distance=3cm] (motor) {G$_{motor}$};
\node [block, right = of motor, pin={[pinstyle]above:Störningar},
node distance=3cm] (system) {Dynamik$_{\varphi}$};
\draw [->] (controller) -- node[name=u,auto] {$u$} (motor);
\node [output, right=of system] (output) {};
\node [block, below = of motor] (msystem) {Mätsystem};
\draw [draw,->] (input) -- node[auto] {$\varphi_{ref}$} (sum);
\draw [->] (sum) -- node[auto] {$e$} (controller);
\draw [->] (motor) -- node[auto=false,label=below:$\varphi$,label=above:$\tau$] {} (system);
\draw [->] (system) -- node [auto,name=y] {$\varphi$}(output);
\draw [->] (y) |- (msystem);
\draw [->] (msystem) -| node[auto,pos=0.99] {$-$} node [auto,near end] {$\varphi_m$} (sum);
\end{tikzpicture}
\end{document}
还要注意,我\tikzstyle
用较新的\tikzset
语法替换了较旧的语法。
答案2
我认为
\draw [->] (motor) edge node[above] {$\tau$} node[below] {$\phi$} (system);
应该这样做
答案3
\usetikzlibrary{arrows.meta, positioning, calc}
\tikzset{%
port/.style = {inner sep=0pt, font=\tiny},
sum/.style n args = {4}{draw, circle, node distance = 2cm, minimum size=.6cm, alias=sum,
append after command={
(sum.45) -- (sum.225)
(sum.135) -- (sum.315)
node at (sum.north) [port, below=1pt] {\textbf{#1}}
node at (sum.west) [port, right=1pt] {\textbf{#2}}
node at (sum.south) [port, above=1pt] {\textbf{#3}}
node at (sum.east) [port, left=1pt] {\textbf{#4}}
},
},
}
\begin{center}
\begin{tikzpicture}
\draw node at (0, 0) [sum={}{+}{–}{}] (sum1) {}
node [tf, right = of sum1] (tf1) {$G_C(s)$}
node [tf, right = of tf1] (tf2) {$G_P(s)$}
node at ($(tf2) + (1,0)$) [branch] (circ1) {};
\draw[-Latex] (-1.5, 0) -- node [label = {[above, pos = .4]:$R(s)$}] () {} (sum1.west);
\draw[-Latex] (tf1.east) -- (tf2.west);
\draw[-Latex] (tf2.east) -- node [label = {[above, pos = .75]:$Y(s)$}] () {} ($(circ1)+(1,0)$);
\draw[-Latex] (sum1.east) -- (tf1.west);
\draw[-Latex] (circ1) -- ($(circ1) - (0, 1)$) -| (sum1.south);
\end{tikzpicture}
\end{center}
这是别人的代码,我只是做了一点修改。我找不到原始帖子。所以,无论谁发布了此代码的原始形式,我都向他/她表示敬意。