TikZ:具有四个端口的求和圆,由两个前圆直径隔开

TikZ:具有四个端口的求和圆,由两个前圆直径隔开

我想修改代码这个答案

\documentclass[tikz, border=5pt]{standalone}
\begin{document}
  \tikzset{
    charge node/.style={inner sep=0pt},
    pics/sum block/.style n args={4}{
      code={
        \path node (n) [draw, circle, inner sep=0pt, minimum size=9mm] {}
          (n.north) +(0,-1.5mm) node [charge node] {$#1$}
          (n.south) +(0,1.5mm) node [charge node] {$#2$}
          (n.west) +(1.5mm,0) node [charge node] {$#3$}
          (n.east) +(-1.5mm,0) node [charge node] {$#4$}
          ;
      }
    }
  }
  \begin{tikzpicture}
    \path pic at (10mm,0) {sum block={+}{-}{+}{-}}
    pic at (20mm,0) {sum block={}{+}{-}{}}
    ;
  \end{tikzpicture}
\end{document}

得到输出这个答案具有四个输入端口的求和圆,输入端口由两个垂直直径隔开。


此外,如果圆是由

\documentclass{article}
\usepackage{tikz,mathtools,amssymb}
\usetikzlibrary{shapes,arrows,positioning,calc}

\begin{document}
    \tikzset{
        port/.style     = {inner sep=0pt, font=\tiny},
        sum/.style n args = {4}{draw, circle, node distance = 2cm, minimum size=5mm, alias=sum,%https://tex.stackexchange.com/a/234545/2288
            append after command={
                node at (sum.north) [port, below=1pt] {$#1$}
                node at (sum.west) [port, right=1pt] {$#2$}
                node at (sum.south) [port, above=1pt] {$#3$}
                node at (sum.east) [port, left=1pt] {$#4$}}},
        }
    \begin{tikzpicture}[auto, node distance=5mm,>=latex',align=center,]
    \node [sum={}{+}{-}{}] (sum) {};
    \end{tikzpicture}   
\end{document}

两条垂线直径怎样画出来?

在此处输入图片描述

答案1

你是說這樣嗎?

\documentclass[tikz, border=5pt]{standalone}
\begin{document}
  \tikzset{
    charge node/.style={inner sep=0pt},
    pics/sum block/.style n args={4}{
      code={
        \path node (n) [draw, circle, inner sep=0pt, minimum size=9mm] {}
          (n.north) +(0,-1.5mm) node [charge node] {$#1$}
          (n.south) +(0,1.5mm) node [charge node] {$#2$}
          (n.west) +(1.5mm,0) node [charge node] {$#3$}
          (n.east) +(-1.5mm,0) node [charge node] {$#4$}
          ;
        \draw
          (n.north west) -- (n.south east)
          (n.south west) -- (n.north east)
          ;
      }
    }
  }
  \begin{tikzpicture}
    \path pic at (10mm,0) {sum block={+}{-}{+}{-}}
    pic at (20mm,0) {sum block={}{+}{-}{}}
    ;
  \end{tikzpicture}
\end{document}

在此处输入图片描述

您也可以在第二个变体中添加这些行。感谢@土拨鼠,无需进一步关注即可做到这一点:

\documentclass{standalone}
\usepackage{tikz}

\tikzset
  {
    port/.style     = {inner sep=0pt, font=\tiny},
    cross/.style =
      {%
        path picture=%
          {
            \draw
              (path picture bounding box.north west) --
                (path picture bounding box.south east)
              (path picture bounding box.south west) --
                (path picture bounding box.north east)
              ;
          }
      },
    sum/.style n args = {4}%
      {%
        draw, circle, node distance = 2cm, minimum size=5mm, cross, alias=sum,%https://tex.stackexchange.com/a/234545/2288
        append after command=%
          {%
            node at (sum.north) [port, below=1pt] {$#1$}
            node at (sum.west) [port, right=1pt] {$#2$}
            node at (sum.south) [port, above=1pt] {$#3$}
            node at (sum.east) [port, left=1pt] {$#4$}
          },
      },
  }
\begin{document}
\begin{tikzpicture}
  \node [sum={}{+}{-}{}] (b) {};
\end{tikzpicture}   
\end{document}

在此处输入图片描述

相关内容