# Positioning of a tikz picture

I have two tikz pictures in a figure. Here is the code:

\begin{figure}[H]
\begin{tikzpicture}
\draw (0,0) node (a1) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_1$] {}
-- ++(252:1.2cm)  node (a2) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_2$] {}
-- ++(324:1.2cm)  node (a3) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt,label=left:$a_3$] {}
-- ++(36:1.2cm)  node (a4) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_4$] {}
-- ++(108:1.2cm)  node (a5) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=above:$a_5$] {}
-- (a1);
\draw (0.75,-2.2) node (aux1)[minimum size=0pt, inner sep=0pt]{};
\draw (4,0)  node (b3) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_3$] {}
-- ++(216:1.2cm)  node (b2) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_2$] {}
-- ++(288:1.2cm)  node (b1) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=below:$b_1$] {}
-- ++(0:1.2cm)  node (b5) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_5$] {}
-- ++(72:1.2cm)  node (b4) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_4$] {}
-- (b3);
\draw (4,0.4) node (aux2)[minimum size=0pt, inner sep=0pt]{};
\draw (a1) -- (a3);
\draw (a5) -- (a3);
\draw (b3) -- (b1);
\draw (b3) -- (b5);
\draw (a5) -- (b2);
\draw (a4) -- (b1);
\draw (a2) to [out=-80,in=180] (aux1);
\draw (aux1) to [out=0,in=-100] (a4);
\draw (a2) to [out=-90,in=-110] (b5);
\draw (b2) to [out=90,in=180] (aux2);
\draw (aux2) to [out=-10,in=110] (b4);
%\draw (b2) to [out=80,in=100] (b4);
\draw (a1) to [out=70,in=90] (b4);
\end{tikzpicture}
\hspace{0.3cm}
\begin{tikzpicture}
\tikzstyle{every node}=[draw,circle,fill=white,minimum size=4pt, inner sep=0pt]
\draw (0,0) node (3) [label=above:$3$] {}
-- ++(216:1.2cm) node (2) [label=left:$2$] {}
-- ++(288:1.2cm) node (1) [label=left:$1$] {}
-- ++(0:1.2cm) node (5) [label=right:$5$] {}
-- ++(72:1.2cm) node (4) [label=right:$4$] {}
-- (3);
\draw (1) -- (3);
\draw (1) -- (4);
\draw (2) -- (4);
\draw (2) -- (5);
\draw (3) -- (5);
\end{tikzpicture}
\caption{}
\end{figure}


As you can see the drawings stand not side by side, the second is a little below the first. So if anyone has time to answer please suggest me a possible solution. How can I have the three pentagons side by side?

Just add the baseline key to both tikz pictures.

\documentclass[]{article}
\usepackage{tikz}

\begin{document}
\begin{figure}[h]
\begin{tikzpicture}[baseline]
\draw (0,0) node (a1) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_1$] {}
-- ++(252:1.2cm)  node (a2) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_2$] {}
-- ++(324:1.2cm)  node (a3) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt,label=left:$a_3$] {}
-- ++(36:1.2cm)  node (a4) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_4$] {}
-- ++(108:1.2cm)  node (a5) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=above:$a_5$] {}
-- (a1);
\draw (0.75,-2.2) node (aux1)[minimum size=0pt, inner sep=0pt]{};
\draw (4,0)  node (b3) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_3$] {}
-- ++(216:1.2cm)  node (b2) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_2$] {}
-- ++(288:1.2cm)  node (b1) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=below:$b_1$] {}
-- ++(0:1.2cm)  node (b5) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_5$] {}
-- ++(72:1.2cm)  node (b4) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_4$] {}
-- (b3);
\draw (4,0.4) node (aux2)[minimum size=0pt, inner sep=0pt]{};
\draw (a1) -- (a3);
\draw (a5) -- (a3);
\draw (b3) -- (b1);
\draw (b3) -- (b5);
\draw (a5) -- (b2);
\draw (a4) -- (b1);
\draw (a2) to [out=-80,in=180] (aux1);
\draw (aux1) to [out=0,in=-100] (a4);
\draw (a2) to [out=-90,in=-110] (b5);
\draw (b2) to [out=90,in=180] (aux2);
\draw (aux2) to [out=-10,in=110] (b4);
%\draw (b2) to [out=80,in=100] (b4);
\draw (a1) to [out=70,in=90] (b4);
\end{tikzpicture}
\hspace{0.3cm}
\begin{tikzpicture}[baseline]
\tikzstyle{every node}=[draw,circle,fill=white,minimum size=4pt, inner sep=0pt]
\draw (0,0) node (3) [label=above:$3$] {}
-- ++(216:1.2cm) node (2) [label=left:$2$] {}
-- ++(288:1.2cm) node (1) [label=left:$1$] {}
-- ++(0:1.2cm) node (5) [label=right:$5$] {}
-- ++(72:1.2cm) node (4) [label=right:$4$] {}
-- (3);
\draw (1) -- (3);
\draw (1) -- (4);
\draw (2) -- (4);
\draw (2) -- (5);
\draw (3) -- (5);
\end{tikzpicture}
\caption{}
\end{figure}
\end{document}


Or draw both figures inside same tikzpicture:

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

\begin{document}
\begin{figure}[h]
\begin{tikzpicture}[baseline]
\draw (0,0) node (a1) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_1$] {}
-- ++(252:1.2cm)  node (a2) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_2$] {}
-- ++(324:1.2cm)  node (a3) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt,label=left:$a_3$] {}
-- ++(36:1.2cm)  node (a4) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=left:$a_4$] {}
-- ++(108:1.2cm)  node (a5) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=above:$a_5$] {}
-- (a1);
\draw (0.75,-2.2) node (aux1)[minimum size=0pt, inner sep=0pt]{};
\draw (4,0)  node (b3) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_3$] {}
-- ++(216:1.2cm)  node (b2) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_2$] {}
-- ++(288:1.2cm)  node (b1) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=below:$b_1$] {}
-- ++(0:1.2cm)  node (b5) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_5$] {}
-- ++(72:1.2cm)  node (b4) [draw,circle,fill=white,minimum size=4pt, inner sep=0pt, label=right:$b_4$] {}
-- (b3);
\draw (4,0.4) node (aux2)[minimum size=0pt, inner sep=0pt]{};
\draw (a1) -- (a3);
\draw (a5) -- (a3);
\draw (b3) -- (b1);
\draw (b3) -- (b5);
\draw (a5) -- (b2);
\draw (a4) -- (b1);
\draw (a2) to [out=-80,in=180] (aux1);
\draw (aux1) to [out=0,in=-100] (a4);
\draw (a2) to [out=-90,in=-110] (b5);
\draw (b2) to [out=90,in=180] (aux2);
\draw (aux2) to [out=-10,in=110] (b4);
%\draw (b2) to [out=80,in=100] (b4);
\draw (a1) to [out=70,in=90] (b4);
%        \end{tikzpicture}
%        \hspace{0.3cm}
%        \begin{tikzpicture}[baseline]
\begin{scope}[every node/.style={draw,circle,fill=white,minimum size=4pt, inner sep=0pt}]
\draw node[right=3cm of b3] (3) [label=above:$3$] {} (3)
-- ++(216:1.2cm) node (2) [label=left:$2$] {}
-- ++(288:1.2cm) node (1) [label=left:$1$] {}
-- ++(0:1.2cm) node (5) [label=right:$5$] {}
-- ++(72:1.2cm) node (4) [label=right:$4$] {}
-- (3);
\draw (1) -- (3);
\draw (1) -- (4);
\draw (2) -- (4);
\draw (2) -- (5);
\draw (3) -- (5);
\end{scope}
\end{tikzpicture}
\caption{}
\end{figure}
\end{document}


Update: (and not related with previous answer)

Just for fun here you find another solution for previous figure.

I've used regular polygons nodes and their already defined anchors. This way it's easier to use relative placement for them. Two right pentagonal nodes use transform shape, xscale=-1 to revert corners order to be CW.

Labels on vertex are placed with three foreach constructions.

And aux1 and aux2 nodes has been eliminated by adding some control points in to constructions. Hope it helps.

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.geometric}

\begin{document}
\begin{figure}[h]
\begin{tikzpicture}[vertex/.style={circle, fill=white, minimum size=4pt, inner sep=0pt, draw}]
\node[draw, regular polygon, shape border rotate=36, minimum size=2cm, anchor=corner 1] (a) {};
\draw (a.corner 3) edge (a.corner 1) edge (a.corner 5);

\node[draw, regular polygon, shape border rotate=216, minimum size=2cm,  right=4cm of a.corner 1, anchor=corner 3, transform shape, xscale=-1] (b) {};
\draw (b.corner 3) edge (b.corner 1) edge (b.corner 5);

\node[draw, regular polygon, shape border rotate=216, minimum size=2cm,  right=4cm of b.corner 3, anchor=corner 3, transform shape, xscale=-1] (c) {};
\foreach \i/\j in  {1/3,2/4,3/5,4/1,5/2}
\draw (c.corner \i) edge (c.corner \j);

\foreach \i [count=\ni] in  {left, left, left, left, above}
\node[vertex, label=\i:{$a_\ni$}] (a\ni) at (a.corner \ni) {};

\foreach \i [count=\ni] in  {below, right, right, right, right}
\node[vertex, label=\i:{$b_\ni$}] (b\ni) at (b.corner \ni) {};

\foreach \i [count=\ni] in {left,left,above,right,right}
\node[vertex, label=\i:{$\ni$}] (c\ni) at (c.corner \ni) {};

\draw (a5) -- (b2);
\draw (a4) -- (b1);
\draw (a2) to [controls=+(-90:1.2) and +(-90:1.2), out=-80,in=-110] (a4);
\draw (a2) to [out=-90,in=-110] (b5);
\draw (b2) to [controls=+(90:1.2) and +(90:1.2), out=90,in=110] (b4);
\draw (a1) to [out=70,in=90] (b4);
\end{tikzpicture}
\caption{}
\end{figure}
\end{document}

• I hesitate proposing such a solution! – NBur Oct 18 '18 at 7:54