我对 Latex 中的框图有疑问。
我想知道如何用红线标出框图的方块线,我已经知道如何更改内部文本和箭头,但正如我所说的,我需要帮助来更改框线。
这就是框图,这是代码:
\begin{frame}{Desarrollo Diagrama en Bloques}
Simplificamos el diagrama:
\bigskip
\bigskip
\centering
\tikzstyle{block} = [draw, fill=white, rectangle,
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=white, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
%Declara los nodos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (Controller1) {\textcolor{red}{$\frac{K}{s}$}};
\node [block, right of=Controller1, node distance = 4.5cm] (system) {\textcolor{red}{$\frac{1}{s+1}$}};
\draw [->,red] (Controller1) -- node[name= ] {$ $} (system);
\node [output, right of=system] (output) {};
\node [block, below = 2 cm, right = 4cm] (Controller2) {$1+sK_h$};
%Ahora conectamos los bloques
\draw [draw,->] (input) -- node {$X(s)$} (sum);
\draw [->,red] (sum) -- node {$ $} (Controller1);
\draw [->] (system) -- node [name=y] {$Y(s)$}(output);
\draw [->] (y) |- (Controller2);
\draw [->] (Controller2) -| node[pos=0.99] {$-$} node [near end] {} (sum);
\end{tikzpicture}
\end{frame}
答案1
欢迎!
- 您可能正在寻找键
draw=red
,和 ,而不是使用\textcolor
,text=red
。 - 我们通常会提供完整的文档,以 开始
\documentclass
和结束\end{document}
,并加载所有样式文件,以便可以进行编译。 \tikzstyle
已被弃用,我用相应的\tikzset
命令替换了它。- 您的定位方法已被弃用,我加载
positioning
并使用相应的语法,例如,而不是right of=...
使用right=of ...
或right=<distance> of ...
。 - 该
arrows
库也有点被弃用,并被取代arrows.meta
。
代码和结果:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning}
\usepackage{mathtools}
\begin{document}
\begin{frame}[t]
\frametitle{Desarrollo Diagrama en Bloques}
Simplificamos el diagrama:
\bigskip
\bigskip
\centering
\tikzset{block/.style={draw, fill=white, rectangle,
minimum height=3em, minimum width=6em},
sum/.style={draw, fill=white, circle, node distance=1cm},
input/.style={coordinate},
output/.style={coordinate},}
\begin{tikzpicture}[auto, node distance=1.5cm,>=Latex]
%Declara los nodos
\node [input, name=input] {};
\node [sum, right=of input] (sum) {};
\node [block,text=red,draw=red,right=of sum] (Controller1) {$\dfrac{K}{s}$};
\node [block,text=red,draw=red,right=of Controller1] (system) {$\dfrac{1}{s+1}$};
\path (Controller1) -- node [block, below=2.5cm] (Controller2) {$1+s\,K_h$}
(system);
\node [output, right=of system] (output) {};
%Ahora conectamos los bloques
\draw [->,red] (Controller1) -- (system);
\draw [draw,->] (input) -- node {$X(s)$} (sum);
\draw [->,red] (sum) -- node {$ $} (Controller1);
\draw [->] (system) -- node [name=y] {$Y(s)$}(output);
\draw [->] (y) |- (Controller2);
\draw [->] (Controller2) -| node[pos=0.99] {$-$} node [near end] {} (sum);
\end{tikzpicture}
\end{frame}
\end{document}
答案2
我将按照以下方式绘制您的框图:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc,
positioning,
quotes}
\begin{document}
\begin{frame}[fragile]
\frametitle{Desarrollo Diagrama en Bloques}
Simplificamos el diagrama:
\begin{center}
\tikzset{
block/.style = {draw=#1, % color of shape border
minimum height=3em, minimum width=6em,
text=#1}, % color of node contents
block/.default = red, % default color is red
sum/.style = {circle, draw=red, minimum size=3mm,
node contents={}},
}
\begin{tikzpicture}[auto,
node distance = 6mm and 8mm,
> = Stealth]
% Declara los nodos
\coordinate (input);
\node (sum) [sum, right=of input];
\node (cntrl1) [block, right=of sum] {$\frac{K}{s}$};
\node (sys) [block, right=of cntrl1] {$\frac{1}{s+1}$};
\coordinate[right=of sys] (out);
\node (cntrl2) [block=black, below= of $(cntrl1.south)!0.5!(sys)$] {$1+sK_h$};
% Lines
\draw (input) edge ["$X(s)$"] (sum)
(sum) edge[red] (cntrl1)
(cntrl1) edge[red] (sys)
(sys) edge["$Y(s)$" {name=y}] (out);
\draw [->] (y |- sys) |- (cntrl2);
\draw [->] (cntrl2) -| node[pos=0.99] {$-$} (sum);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}