我正在尝试绘制模拟计算机符号(稍后我会贴出整个列表的图片)。现在,我正在尝试绘制模拟积分器的符号。以下是我现在的代码:
\documentclass[12pt]{article}
\usepackage{amssymb, graphicx}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{float}
\usepackage{enumitem}
\usepackage{amsfonts,bm}
\usepackage{diagbox}
\usepackage[makeroom]{cancel}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{verbatim}
\usepackage[american,siunitx]{circuitikz}
\usepackage[export]{adjustbox}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\usepackage{units}
\usepackage{relsize}
\usepackage[margin=1in]{geometry}
\begin{document}
\tikzstyle{block} = [draw, rectangle,
minimum height=3em, minimum width=3em]
\tikzstyle{sum} = [draw, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{figure}[H]
\centering
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node[regular polygon,regular polygon sides=3, draw, shape border rotate=-90, scale = 2.5, name = integrator]{};
\draw (integrator.corner 2) -- ++ (-0.5, 0) |- (integrator.corner 3);
\end{tikzpicture}
\caption{Control block diagram.}
\end{figure}
\end{document}
以下是我现在所拥有的:
目前,线条无法像我希望的那样正确连接到顶点。有没有办法正确地连接它们,使线条和角之间没有任何空隙?
编辑:这里是模拟计算机符号的列表,以便人们可以理解我正在尝试为积分器(和导数)做什么:
另一个例子(似乎是在 LaTeX 上完成的):
更新:这里是我想在 LaTeX 上绘制的示例电路:
对应方程如下:
有人能告诉我如何将输入数量推广到夏季和积分器,并详细解释语法吗?我试图遵循代码,但语法非常复杂,对用户非常不友好。
答案1
我认为所有这些都可以通过 实现circuitikz
。以下是两个示例。顺便说一句,\tikzstyle
已弃用。
\documentclass{article}
\usepackage{amsmath}
\usepackage[american,siunitx]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[amp,t=$\boldsymbol{K}$] ++(3,0);
\ctikzset{amplifiers/minus={$k_1$},amplifiers/plus={$k_2$}}
\draw (0,-1.5) -- ++(1,0) node[op amp, anchor=-](sum){};
\tikzset{cop amp/.style 2 args={op amp,
/utils/exec=\ctikzset{amplifiers/minus={},amplifiers/plus={}},
append after command={%
pic{rect={#1}{#2}}
}},
pics/rect/.style 2 args={code={\let\mytikzlastnode\tikzlastnode
\draw[thick,fill=white] (\tikzlastnode.bin up|-\tikzlastnode.north)
-- ++({-1.1*max(width("#1"),width("#2"))-8pt},0) |- (\tikzlastnode.bin up|-\tikzlastnode.south)
-- cycle;
\path (\mytikzlastnode.bin up) node[left=0pt,font=\boldmath] {#1}
(\mytikzlastnode.bin down) node[left=0pt,font=\boldmath] {#2};
}}}
\draw (1,-4) node[cop amp={$k_1$}{$k_2$}, anchor=-](sum){};
\end{circuitikz}
\end{document}
让我试着解释一下
\tikzset{cop amp/.style 2 args={op amp,
/utils/exec=\ctikzset{amplifiers/minus={},amplifiers/plus={}},
append after command={%
pic{rect={#1}{#2}}
}},
pics/rect/.style 2 args={code={\let\mytikzlastnode\tikzlastnode
\draw[thick,fill=white] (\tikzlastnode.bin up|-\tikzlastnode.north)
-- ++({-1.1*max(width("#1"),width("#2"))-8pt},0) |- (\tikzlastnode.bin up|-\tikzlastnode.south)
-- cycle;
\path (\mytikzlastnode.bin up) node[left=0pt,font=\boldmath] {#1}
(\mytikzlastnode.bin down) node[left=0pt,font=\boldmath] {#2};
}}}
确实如此。它定义了一个修改后的op amp
节点。它使用此节点,因此是op amp
键。然后它删除了和+
。(有人可能会说使用并不总是最佳的。我同意 Henri 的观点。然而,Ti-
/utils/exec=\ctikzset{amplifiers/minus={},amplifiers/plus={}}
/utils/exec
钾Z 甚至在内部使用它,即可以在 中找到它tikz.code.tex
。我认为在这里没问题。)主要成分是密钥append after command
,它发出添加矩形的图片。矩形附加到节点,节点的名称存储在 中\tikzlastnode
。由于我们要添加其他节点,因此它会存储在 上\mytikzlastnode
。通过测量参数的大小,我们可以确保矩形足够大。也可以fit
在这里使用。
以下是编辑爱德华多·阿尔维斯·达席尔瓦, 多谢!
编辑 :关于如何使用,例如,制作您提供的图像:
\documentclass[border = 5pt]{standalone}
\usepackage[RPvoltages]{circuitikz}
\usepackage{calc}
\usepackage{tikz}
\tikzset{cop amp/.style 2 args={op amp,
/utils/exec=\ctikzset{amplifiers/minus={},amplifiers/plus={}},
append after command={%
pic{rect={#1}{#2}}
}},
pics/rect/.style 2 args={code={\let\mytikzlastnode\tikzlastnode
\draw[thick,fill=white] (\tikzlastnode.bin up|-\tikzlastnode.north)
-- ++({-1.1*max(width("#1"),width("#2"))-8pt},0) |-
(\tikzlastnode.bin up|-\tikzlastnode.south)
-- cycle;
\path (\mytikzlastnode.bin up) node[left=0pt,font=\boldmath] {#1}
(\mytikzlastnode.bin down) node[left=0pt,font=\boldmath] {#2};
}}}
\begin{document}
\begin{circuitikz} [american voltages]
\node[draw,minimum size,fill=white] (-1) {-1};
\draw (-1.east) to[short,-] ++(1,0)
node[draw, circle,anchor=west] (g) {g};
\draw (g.east) to[short] ++(0.5,0) node[cop amp={}{}, anchor=-](int1){};
\draw (int1.out) to[short] ++(1,0) coordinate (aux) to[short] ++(1,0) node[cop amp={}{}, anchor=west] (int2) {};
\draw (aux) to[short,*-] ++(0,-2) coordinate (aux2);
\draw[-] (aux2) -- ++(-2,0) node[draw,circle,anchor=east] (dm) {$d/m$};
\draw[-] (dm) --++(-1.5,0) coordinate (aux2);
\draw[-] (aux2) |- (int1.+);
\draw (aux) node[above] () {$-\dot{y}$};
\draw (int2.out) to[short] ++(0.5,0) node[above] () {$y$};
\draw (int2.out) to[short, *-] ++(0,-3.5) to[short] ++(-1,0) node[buffer,xscale=-1,anchor=in] (buffer) {};
\draw (buffer.out) to[short] ++(-0.5,0) node[above] () {$-y$};
\draw (buffer.out) to[short] ++(-1,0) node[draw,circle,anchor=east] (cm) {$c/m$};
\draw (cm.west) to[short] ++(-3.5,0) coordinate (aux) to[short] (aux |- int1.west)
to[short] (int1.west);
\end{circuitikz}
\end{document}