3

I have two simple graphs side by side that align perfectly when the arcs are not labeled, but as soon as I add the labels I get a spacing issue where there is a space between the second figure and its subcaption, but not the first figure. Here is my code:

 \documentclass[12ptm]{article}
 \usepackage{amsmath, amsthm}
 \usepackage{tikz}
 \usepackage{graphicx}
 \usetikzlibrary{arrows}
 \usepackage{subcaption}

 \begin{document}

 \begin{figure}[h]
 \centering
 \begin{subfigure}[t]{0.475\textwidth}
 \centering
 \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,
            thick,main node/.style={circle,draw,font=\Large\bfseries}]

\tikzstyle{every node}=[draw,shape=circle];
\node[draw=none, shape=circle,scale=0.03cm, main node] (n1) {} ;
\node[draw,shape=circle,scale=0.03cm, main node](n2) [left of=n1] {$M$} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n4) [above of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n6) [right of=n4] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n3) [below of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n5) [right of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n7) [right of=n3] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n8) [right of=n5] {$i$} ;

\draw[->] (n2) to[bend left] node[draw=none,fill=none,left]{\small$a$} (n4);
\draw[->] (n2) to[bend right] node[draw=none,fill=none,left]{\small$b$} (n3);
\draw[<-] (n2) to node[draw=none,fill=none,above=-5pt]{\small$(x,c)$}  (n1);
\draw[<-,dotted] (n1) to (n5);
\draw[->] (n6) to[bend left] node[draw=none,fill=none,right]{\small$a$} (n8);
\draw[->] (n7) to[bend right] node[draw=none,fill=none,right]{\small$b$} (n8);
\draw[<-] (n5) to node[draw=none,fill=none,above=-5pt]{\small$(x,c)$} (n8);
\draw[->,dotted] (n4) to (n6);
\draw[->,dotted] (n3) to (n7);

\end{tikzpicture}
\caption{{\it{A network satisfying condition $(i)$.}}}
\end{subfigure}
\hspace{.1cm}
\begin{subfigure}[t]{0.475\textwidth}
\centering
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,
            thick,main node/.style={circle,draw,font=\Large\bfseries}]

\tikzstyle{every node}=[draw,shape=circle];
\node[draw=none, shape=circle,scale=0.03cm, main node] (n1) {} ;
\node[draw,shape=circle,scale=0.03cm, main node](n2) [left of=n1] {$M$} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n4) [above of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n6) [right of=n4] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n3) [below of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n5) [right of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n7) [right of=n3] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n8) [right of=n5] {$i$} ;

\draw[->] (n2) to[bend left] node[draw=none,fill=none,left]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n4);
\draw[->] (n2) to[bend right] node[draw=none,fill=none,left]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n3);
\draw[->] (n1) to (n2);
\draw[->,dotted] (n5) to (n1);
\draw[->] (n6) to[bend left] node[draw=none,fill=none,right]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n8);
\draw[->] (n7) to[bend right] node[draw=none,fill=none,right]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n8);
\draw[->] (n8) to (n5);
\draw[->,dotted] (n4) to (n6);
\draw[->,dotted] (n3) to (n7);
\end{tikzpicture}
\caption{{\it{A network satisfying condition $(i)$.}}}
\end{subfigure}\caption{{\it{An illustration of conditions $(i)$ and $(ii)$ of theorem 1.}}}
\end{figure}

\end{document}

I have tried fiddling around with the parameters but with no luck. Any suggestions?

1 Answer 1

3

Because the nodes for those labels are circular in shape. Remove the draw=none from those labels to see them. Remedy is to add rectangle in

node[rectangle,draw=none,fill=none,left]{\small$(\f.....

You may add small in the node options like

node[rectangle,draw=none,fill=none,left,font=\small]{$(\f....

BTW. Better, define a new style for these labels as you did for main nodes. As a side note, use tikzset instead of \tikzstyles. Change them yourself.

 \documentclass[12ptm]{article}
 \usepackage{amsmath, amsthm}
 \usepackage{tikz}
 \usepackage{graphicx}
 \usetikzlibrary{arrows}
 \usepackage{subcaption}
 \begin{document}

 \begin{figure}[h]
 \centering
 \begin{subfigure}[t]{0.475\textwidth}
 \centering
 \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,
            thick,main node/.style={circle,draw,font=\Large\bfseries}]

\tikzstyle{every node}=[draw,shape=circle];
\node[draw=none, shape=circle,scale=0.03cm, main node] (n1) {} ;
\node[draw,shape=circle,scale=0.03cm, main node](n2) [left of=n1] {$M$} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n4) [above of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n6) [right of=n4] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n3) [below of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n5) [right of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n7) [right of=n3] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n8) [right of=n5] {$i$} ;

\draw[->] (n2) to[bend left] node[draw=none,fill=none,left]{\small$a$} (n4);
\draw[->] (n2) to[bend right] node[draw=none,fill=none,left]{\small$b$} (n3);
\draw[<-] (n2) to node[draw=none,fill=none,above=-5pt]{\small$(x,c)$}  (n1);
\draw[<-,dotted] (n1) to (n5);
\draw[->] (n6) to[bend left] node[draw=none,fill=none,right]{\small$a$} (n8);
\draw[->] (n7) to[bend right] node[draw=none,fill=none,right]{\small$b$} (n8);
\draw[<-] (n5) to node[draw=none,fill=none,above=-5pt]{\small$(x,c)$} (n8);
\draw[->,dotted] (n4) to (n6);
\draw[->,dotted] (n3) to (n7);

\end{tikzpicture}
\caption{{\it{A network satisfying condition $(i)$.}}}
\end{subfigure}
\hspace{.1cm}
\begin{subfigure}[t]{0.475\textwidth}
\centering
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,
            thick,main node/.style={circle,draw,font=\Large\bfseries}]

\tikzstyle{every node}=[draw,shape=circle];
\node[draw=none, shape=circle,scale=0.03cm, main node] (n1) {} ;
\node[draw,shape=circle,scale=0.03cm, main node](n2) [left of=n1] {$M$} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n4) [above of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n6) [right of=n4] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n3) [below of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n5) [right of=n1] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n7) [right of=n3] {} ;
\node[draw,shape=circle,scale=0.03cm, main node] (n8) [right of=n5] {$i$} ;

\draw[->] (n2) to[bend left] node[rectangle,draw=none,fill=none,left]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n4);
\draw[->] (n2) to[bend right] node[rectangle,draw=none,fill=none,left]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n3);
\draw[->] (n1) to (n2);
\draw[->,dotted] (n5) to (n1);
\draw[->] (n6) to[bend left] node[rectangle,draw=none,fill=none,right]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n8);
\draw[->] (n7) to[bend right] node[rectangle,draw=none,fill=none,right]{\small$(\frac{a_{k}\oplus b_{k}}{2},x\oplus c_{k})$} (n8);
\draw[->] (n8) to (n5);
\draw[->,dotted] (n4) to (n6);
\draw[->,dotted] (n3) to (n7);
\end{tikzpicture}
\caption{{\it{A network satisfying condition $(i)$.}}}
\end{subfigure}\caption{{\it{An illustration of conditions $(i)$ and $(ii)$ of theorem 1.}}}
\end{figure}

\end{document}

enter image description here

As you can see those two pictures are too wide together to fit within the text width. You may want to scale them down.

2
  • Ah yes! I have had many problems in the past related to this and never thought that it was the node shape. Thank you for pointing this out! Also, I am relatively new to these forums. Could you let me know how you get the code to compile on the post? Jan 21, 2015 at 13:40
  • @ThomasJRivera Compile using your editor, take a screen shot of your pdf file, upload the png image pressing the image button above (Cntrl+G)..
    – user11232
    Jan 21, 2015 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .