垂直导线上方或上方的交叉扭结

垂直导线上方或上方的交叉扭结

我正在使用 tikz 绘制电路原理图,但在这种电路上做“扭结”十字时遇到了困难。我找到了如何做它们的答案这里。然而,我无法将答案延伸到跳过垂直线。

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usepackage{circuitikz}
\pagestyle{empty}

%answer from Qrrbrbirlbel for https://tex.stackexchange.com/questions/134067/circuitikz-wire-kink-thingy-when-wires-cross
\tikzset{
  declare function={% in case of CVS which switches the arguments of atan2
    atan3(\a,\b)=ifthenelse(atan2(0,1)==90, atan2(\a,\b), atan2(\b,\a));},
  kinky cross radius/.initial=+.125cm,
  @kinky cross/.initial=+, kinky crosses/.is choice,
  kinky crosses/left/.style={@kinky cross=-},kinky crosses/right/.style={@kinky cross=+},
  kinky cross/.style args={(#1)--(#2)}{
    to path={
      let \p{@kc@}=($(\tikztotarget)-(\tikztostart)$),
          \n{@kc@}={atan3(\p{@kc@})+180} in
      -- ($(intersection of \tikztostart--{\tikztotarget} and #1--#2)!%
             \pgfkeysvalueof{/tikz/kinky cross radius}!(\tikztostart)$)
      arc [ radius     =\pgfkeysvalueof{/tikz/kinky cross radius},
            start angle=\n{@kc@},
            delta angle=\pgfkeysvalueof{/tikz/@kinky cross}180 ]
      -- (\tikztotarget)}}}

\begin{document}
    \begin{tikzpicture}

        \node (a) at (-1,0) {a};
        \node (b) at (1,0) {b};
        \node (c) at (0,1) {c};
        \node (d) at (0,-1) {d};


        \draw (a) -- (b);
        \draw (c) to [kinky cross=(a)--(b), kinky crosses=left] (d);

    \end{tikzpicture}
\end{document}

其结果是: 在此处输入图片描述

所以,问题是:我有一条从 c -- d 的直线,从 a -- b 走的时候我需要跳过它。

答案1

(a)--(b)我误解了吗?在我看来,你只需要交换和的角色(c)--(d)

在此处输入图片描述

完整代码如下:

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usepackage{circuitikz}
\pagestyle{empty}

%answer from Qrrbrbirlbel for https://tex.stackexchange.com/questions/134067/circuitikz-wire-kink-thingy-when-wires-cross
\tikzset{
  declare function={% in case of CVS which switches the arguments of atan2
    atan3(\a,\b)=ifthenelse(atan2(0,1)==90, atan2(\a,\b), atan2(\b,\a));},
  kinky cross radius/.initial=+.125cm,
  @kinky cross/.initial=+, kinky crosses/.is choice,
  kinky crosses/left/.style={@kinky cross=-},kinky crosses/right/.style={@kinky cross=+},
  kinky cross/.style args={(#1)--(#2)}{
    to path={
      let \p{@kc@}=($(\tikztotarget)-(\tikztostart)$),
          \n{@kc@}={atan3(\p{@kc@})+180} in
      -- ($(intersection of \tikztostart--{\tikztotarget} and #1--#2)!%
             \pgfkeysvalueof{/tikz/kinky cross radius}!(\tikztostart)$)
      arc [ radius     =\pgfkeysvalueof{/tikz/kinky cross radius},
            start angle=\n{@kc@},
            delta angle=\pgfkeysvalueof{/tikz/@kinky cross}180 ]
      -- (\tikztotarget)}}}

\begin{document}
    \begin{tikzpicture}

        \node (a) at (-1,0) {a};
        \node (b) at (1,0) {b};
        \node (c) at (0,1) {c};
        \node (d) at (0,-1) {d};


        \draw (c) -- (d);
        \draw (a) to [kinky cross=(c)--(d), kinky crosses=left] (b);

    \end{tikzpicture}
\end{document}

相关内容