我想知道有什么更好的方法可以用 tikz 来获取以下图表?
谢谢
代码 :
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[line width=1mm] (0,0) -- (0,10) node (Line1) [above] {$L_1$};
%---
\draw (0,9) -- (1,9) node (rung00) [left] {$0000$};
%---
\draw (1,8.5) -- (1,9.5) node (n1) [] {};
\draw (1.5,8.5) -- (1.5,9.5) node (n2) [] {};
%---
\draw (1.5,9) -- (4.5,9) node (n3) [] {};
%---
\draw (4.5,8.5) -- (4.5,9.5) node (n4) [] {};
\draw (5,8.5) -- (5,9.5) node (n5) [] {};
\draw (4.5,8.5) -- (5,9.5) node (n5) [] {};
\draw (5,9) -- (7,9) node (n6) [] {};
%---
\draw (7.2,8.5) arc (-150:-210:1cm);
\draw (7.8,9.5) arc (30:-30:1cm);
%---
\draw (8,9) -- (10,9);
\draw (0,7) -- (1,7) node (n8) [] {};
%---
\draw (1,6.5) -- (1,7.5) node (n9) [] {};
\draw (1.5,6.5) -- (1.5,7.5) node (n10) [] {};
%---
\draw (1.5,7) -- (4,7) node (n11) [] {};
%---
\draw (4,7) -- (4,9) node (n12) [] {};
%---
%\draw[red] (0,0) -- ([xshift=3pt] 1,1);
\draw[line width=1mm] (10,0) -- (10,10) node (Line1) [above] {$L_2$};
\end{tikzpicture}
\end{document}
答案1
始终使用xelatex
并且不加载inputenc
不需要的包xelatex
:
\documentclass[a4paper,10pt]{article}
\usepackage{pst-circ}
\begin{document}
\begin{pspicture}(7,7)
\pnodes(0,0){A}(7,7){B}
\multidipole(A)(B)\resistor{$R$}%
\capacitor[linecolor=red]{$C$}%
\diode{$D$}{}
\end{pspicture}
\begin{pspicture}(-1,-1)(1,1)
\xio[plcaddress=I:1/0,
plcsymbol=Symbol](0,0)
\end{pspicture}
\end{document}
答案2
以下是我的进展:在仔细阅读最初发布的代码的第一部分后,我学到了两件事。第一件事是 begin{pstricks} 后面的 (7,7) 是函数中定义的 2 个节点的总和。第二件事是,我可以使用“多偶极子并将对象放在花括号中”来连接 2 个对象。这适用于电阻器和电容器,但对于我想要/需要使用的元件,它是有效的。代码如下
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{}
\usepackage{pst-circ}
%opening
\title{My First Ladder Logic with \LaTex}
\author{Guy}
\begin{document}
\maketitle
\section{Section 1}
\begin{pspicture}(7,7)
\pnodes(0,0){A}(7,7){B}
\multidipole(A)(B)\resistor{$R$}%
\capacitor[linecolor=red]{$C$}%
\diode{$D$}{}
\end{pspicture}
\begin{pspicture}(-1,-1)(1,1)
\xio[plcaddress=I:1/0,plcsymbol=Symbol](0,0)
\end{pspicture}
%
\begin{pspicture}(-1,-1)(1,1)
\xic[plcaddress=I:1/0,plcsymbol=Symbol](0,0)
\end{pspicture}
%
\vspace{2cm}
%
\begin{pspicture}(-1,-1)(3,3)
\xio[plcaddress=I:1/1,plcsymbol=Symbol](0,0)(A)
\xic[plcaddress=I:1/1,plcsymbol=Symbol](2,2)(B)
\multidipole(A)(B){\xio}%
{\xic}.
\end{pspicture}
%
\end{document}