我有两个并排的简单图表,当弧线未标记时,它们可以完美对齐,但是一旦添加标签,就会出现间距问题,即第二个图与其子标题之间有空格,但第一个图没有。这是我的代码:
\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}
我尝试调整参数,但没有成功。有什么建议吗?
答案1
因为node
这些标签的 s 是圆形的。draw=none
从这些标签上取下 才能看到它们。补救措施是rectangle
添加
node[rectangle,draw=none,fill=none,left]{\small$(\f.....
您可以添加small
节点选项,例如
node[rectangle,draw=none,fill=none,left,font=\small]{$(\f....
顺便说一句。最好为这些标签定义一种新样式,就像您对main node
s 所做的那样。顺便提一下,使用tikzset
而不是\tikzstyle
s。自己更改它们。
\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}
如您所见,这两张图片太宽了,无法容纳在文本宽度内。您可能需要缩小它们。