3

enter image description here

I have a small code. With which I can draw a square, but I'm unable to draw the second square and join the corresponding vertices

  • 3
    Welcome to TeX.SE. Why not show your small code? Make it as complete small document, which we can copy to our computers and compile. With it not to need start from scratch ... – Zarko Aug 27 '16 at 19:02
3

Do you liked:

enter image description here

Above picture is generated by:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

    \begin{document}
\begin{tikzpicture}[
    every node/.style = {draw=black, minimum size=2cm},
        node distance = 2cm]
\node (A) {};
\node (B) [right=of A] {};

\foreach \pos [count=\i] in {north west, north east, south west, south east}
{
    \fill[gray] (A.\pos) circle (2mm) (B.\pos) circle (2mm);
\ifnum\i<3
    \draw[green, thick] (A.\pos) to [bend left=30] (B.\pos);
\else
    \draw[green, thick] (A.\pos) to [bend right=30] (B.\pos);
\fi
}
\end{tikzpicture}
    \end{document}

In above code I exploit TikZ library positioning by which the second node is positioned for node distance right of the first one. Circles and Green arcs are drawn by \foreach loop, where defined positions of circles and with additional counter \i are used in drawing arcs: for above two is used bend=left and for second two bend=right.

5

try this

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node[minimum size=2cm,draw, black] (A) at (0,0){};
\node[minimum size=2cm,draw, black] (B) at (4,0){};

\foreach \pos/\bend in {north east/left, south east/right, north west/left, south west/right}{
\draw[fill] (A.\pos) circle (0.1);
\draw[fill] (B.\pos) circle (0.1);
\draw[green, thick] (A.\pos) to [bend \bend=20] (B.\pos);
}

\end{tikzpicture}

\end{document}

enter image description here

  • 1
    The lower green arcs should bend to the outside according to the image in the question. For example, it can be fixed by using angles (45, 135, 225, 315) instead of directions. Then bend left and bend right can be selected depending on the angle, the option can then dynamically be calculated: bend \ifnum\pos<180 left\else right\fi=20 – Heiko Oberdiek Aug 27 '16 at 19:35
  • I adapted the code with a loop two variables – rpapa Aug 27 '16 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.