これをよりエクスポートしやすい方法で記述するにはどうすればよいでしょうか?

これをよりエクスポートしやすい方法で記述するにはどうすればよいでしょうか?

Circuitikz で描いたこの図は、最初の石以来私が扱った初めての「複雑な」図ですが、将来のプロジェクトのために、これをもっと「エクスポート可能」にできるかどうか、つまり、FlipFlops 間の間隔を変更しても、現在とは異なり、位置が変わるものがあまりないかどうかを知りたいと思います。

私が書いたのは次の通りです:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[siunitx, RPvoltages]{circuitikzgit}

\tikzset{flipflop JK/.style={flipflop,
flipflop def={t1=Q, t3={\ctikztextnot{Q}}, t6=J, t4=K,c5=1, td=PRST, 
tu=CLR},
}}

\begin{document}
    \begin{center}
      \begin{circuitikz}[scale=0.8, transform shape]
        \node[vsourcesquareshape, rotate=90](clk){};
         \draw (-3,0) node[flipflop JK,external pins width=0](FF0){};
         \draw (-6,0) node[flipflop JK,external pins width=0](FF1){};
         \draw (-9,0) node[flipflop JK,external pins width=0](FF2){};
         \draw (-12,0) node[flipflop JK,external pins width=0](FF3){};
         \draw (-15,0) node[flipflop JK,external pins width=0](FF4){};

         \draw (clk.north) -- (FF0.east)node[inputarrow,rotate=180]{};
         \draw (FF0.pin 1) -| (-4.5,0);
         \draw (-4.5,0) -- (FF1.pin 5)node[inputarrow,rotate=180]{};

         \draw (FF1.pin 1) -| (-7.5,0);
         \draw (-7.5,0) -- (FF2.pin 5)node[inputarrow,rotate=180]{};

         \draw (FF2.pin 1) -| (-10.5,0);
         \draw (-10.5,0) -- (FF3.pin 5)node[inputarrow,rotate=180]{};

         \draw (FF3.pin 1) -| (-13.5,0);
         \draw (-13.5,0) -- (FF4.pin 5)node[inputarrow,rotate=180]{};

         \draw (FF0.pin 1) -| (-4.5,2)node[inputarrow,rotate=90] 
          {\rotatebox{-90}{$Q_0$}};
         \draw (FF1.pin 1) -| (-7.5,2)node[inputarrow,rotate=90] 
          {\rotatebox{-90}{$Q_1$}};
         \draw (FF2.pin 1) -| (-10.5,2)node[inputarrow,rotate=90] 
          {\rotatebox{-90}{$Q_2$}};
           \draw (FF3.pin 1) -| (-13.5,2)node[inputarrow,rotate=90] 
           {\rotatebox{-90}{$Q_3$}};
           \draw (FF4.pin 1) -| (-16.5,2)node[inputarrow,rotate=90] 
           {\rotatebox{-90}{$Q_4$}};

     \end{circuitikz}
   \end{center}
\end{document}

答え1

私はこの質問を、回路の一部の機能を全体的に変更しやすくしたいという要望だと解釈しています。これはchains\foreachと、Rmano が指摘したように calc を使用することで実現できます。フリップフロップをチェーンに載せて、残りをループで実行することができます。すると、これらのパラメータは 1 回だけ表示され、全体的に変更できます。たとえば、フリップフロップ間の距離は で与えられますnode distance

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[siunitx, RPvoltages]{circuitikz}
\usetikzlibrary{calc,chains}
\tikzset{flipflop JK/.style={flipflop,
flipflop def={t1=Q, t3={\ctikztextnot{Q}}, t6=J, t4=K,c5=1, td=PRST, 
tu=CLR},
}}

\begin{document}
    \begin{center}
      \begin{circuitikz}[scale=0.8, transform shape]
         \node[vsourcesquareshape, rotate=90](clk){};
         % do the flip flops     
         \begin{scope}[start chain=going left,node distance=1.5cm,
            nodes={on chain,flipflop JK,external pins width=0}]
            \path foreach \X in {0,...,4}
            {node(FF\X){}};
         \end{scope}
         % determine the midpoints between the flip flops and name them
         \path foreach \X in {1,...,4}
          {(FF\the\numexpr\X-1|-0,0) -- coordinate (c\X) (FF\X|-0,0)};
         % add one more of the points to the left
         \path let \p1=($(FF0.center)-(c1)$) in (FF4.center|-0,0)
          ++ (-\x1,0) coordinate (c5);
         % from original code
         \draw (clk.north) -- (FF0.east)node[inputarrow,rotate=180]{};
         % draw the stuff between those nodes
         \foreach \X in {1,...,4}
         {\draw (FF\the\numexpr\X-1\relax.pin 1) -| (c\X);
          \draw (c\X) -- (FF\X.pin 5)node[inputarrow,rotate=180]{};
          \draw (FF\the\numexpr\X-1\relax.pin 1) -| (c\X|-0,2)node[inputarrow,rotate=90] 
          {\rotatebox{-90}{$Q_{\the\numexpr\X-1\relax}$}};}
         % use c5 
         \draw (FF4.pin 1) -| (c5|-0,2) node[inputarrow,rotate=90] 
            {\rotatebox{-90}{$Q_4$}};
     \end{circuitikz}
   \end{center}
\end{document}

ここに画像の説明を入力してください

コードを実行する方法を教えてくれた Rmano に心から感謝します。私はcircuitikzCTAN の最新バージョンを使用しています。申し訳ありませんが、これを Overleaf で入手する方法を教えることはできませんし、Overleaf の問題の修正方法についても何も知りません。

関連情報