Tikzで図形の間に描画する

Tikzで図形の間に描画する

私は、中央の円 (総会) から経済社会理事会と国際刑事裁判所の円まで、3 つの円すべてに対する線の入射角が 0 度、つまり円の表面に対して線が 90 度の角度になるように線を引こうとしています。現在、これが私の手元にあるものです。

\documentclass{article}
\usetikzlibrary{calc}
\usetikzlibrary{matrix, shapes}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{snakes}
\usetikzlibrary{positioning, intersections}
\pgfplotsset{compat=1.10}
\begin{document}

    \begin{figure}[H]
    \label{fig:structure}
    \centering
    \begin{tikzpicture}
    \node[xshift=6cm,draw,regular polygon, regular polygon sides=4,text width=3cm,align=center] (sa)
      {{\Large Specialized agencies}:\\
      \textbullet FAO\\
      \textbullet ILO\\
      \textbullet ITU\\
      \textbullet WHO};
      \node[minimum size= 4.5cm, xshift=12cm,draw,circle, text width=3cm,align=center] (ga) {\Large{General Assembly}\\
      \small{1 nation, 1 vote}};
      \node[xshift=12cm,yshift=-5cm,draw, circle, text width=3cm,align=center] (sc) {\Large Security Council\\
      \small{5 permanent members\\
      10 rotating members chosen by GA}};
        \node[xshift=12cm,yshift=5cm,draw,circle, text width=3cm,align=center] (sg) {\Large Secretary General\\
      \small{Supports GA decisions}};
          \node[xshift=17cm,yshift=2cm,draw,circle, text width=3cm,align=center] (ecsoc) {\Large Economic and Social Council
    };
          \node[xshift=17cm,yshift=-2cm,draw,circle, text width=3cm,align=center] (icc) {\Large International Criminal Court
    };
    \draw (sa.east) -- (ga.west);
    \draw (sg.south) -- (ga.north);
    \draw (sc.north) -- (ga.south);
    \draw (ga.east) -- (ecsoc.west);
    \draw (ga.east) -- (icc.west);
    \end{tikzpicture}
    \caption{Structure of the United Nations}
    \end{figure}

\end{document}

チャート

答え1

円の境界に対して垂直にする必要がある場合は、 の代わりに のように--使用します。この方法では、線は 0 度 (右) で出て、 180 度 (左) に入ります。edge[out=0, in=180]\draw (ga.east) edge[out=0, in=180] (ecsoc.west);

また、Tikzライブラリをすべて1か所にカンマで区切って記述します。エラーが発生しないように、Tikz パッケージを呼び出します。私は通常、必要なすべてのパッケージをリストし、その後に該当する場合はライブラリをリストします。この方法の方が理解しやすく、整理も容易です。

図1

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\usetikzlibrary{positioning, intersections, calc, matrix, shapes, snakes}
\pgfplotsset{compat=1.10}

\begin{document}

    \begin{figure}[H]
    \label{fig:structure}
    \centering
    \begin{tikzpicture}
    \node[xshift=6cm,draw,regular polygon, regular polygon sides=4,text width=3cm,align=center] (sa)
      {{\Large Specialized agencies}:\\
      \textbullet FAO\\
      \textbullet ILO\\
      \textbullet ITU\\
      \textbullet WHO};
      \node[minimum size= 4.5cm, xshift=12cm,draw,circle, text width=3cm,align=center] (ga) {\Large{General Assembly}\\
      \small{1 nation, 1 vote}};
      \node[xshift=12cm,yshift=-5cm,draw, circle, text width=3cm,align=center] (sc) {\Large Security Council\\
      \small{5 permanent members\\
      10 rotating members chosen by GA}};
        \node[xshift=12cm,yshift=5cm,draw,circle, text width=3cm,align=center] (sg) {\Large Secretary General\\
      \small{Supports GA decisions}};
          \node[xshift=17cm,yshift=2cm,draw,circle, text width=3cm,align=center] (ecsoc) {\Large Economic and Social Council
    };
          \node[xshift=17cm,yshift=-2cm,draw,circle, text width=3cm,align=center] (icc) {\Large International Criminal Court
    };
    \draw (sa.east) -- (ga.west);
    \draw (sg.south) -- (ga.north);
    \draw (sc.north) -- (ga.south);
    \draw (ga.east) edge[out=0, in=180] (ecsoc.west);
    \draw (ga.east) edge[out=0, in=180] (icc.west);
    \end{tikzpicture}
    \caption{Structure of the United Nations}
    \end{figure}

\end{document}

ちなみに、キー「looseness」を追加することで、曲線の外観を変更できます。デフォルトは 1 です。0 は直線を作成し、数値を増やすと曲線が強調されます。次に例を示します (黒が標準、つまり 1)。

図2

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\usetikzlibrary{positioning, intersections, calc, matrix, shapes, snakes}
\pgfplotsset{compat=1.10}

\begin{document}

    \begin{tikzpicture}
    \node[draw, circle, text width=3cm, align=center] (ga) {\Large General Assembly};
    \node[draw, circle, text width=3cm, align=center, xshift=6cm, yshift=3cm] (ecsoc) {\Large Economic and Social Council};

    \draw[green] (ga.east) edge[out=0, in=180, looseness=0] (ecsoc.west);
    \draw (ga.east) edge[out=0, in=180, looseness=1] (ecsoc.west);
    \draw[red] (ga.east) edge[out=0, in=180, looseness=5] (ecsoc.west);
    \draw[blue] (ga.east) edge[out=0, in=180, looseness=10] (ecsoc.west);

    \end{tikzpicture}

\end{document}

関連情報