Como centralizar a subfigura

Como centralizar a subfigura

Eu uso a subfigura para juntar duas figuras, porém elas não ficam centralizadas.

Abaixo está meu código:

\documentclass[10pt]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{
    shapes.geometric,
    positioning,
    fit,
    calc
}

\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.24\textwidth}
\centering
\begin{tikzpicture}[
 block/.style = {circle, draw,
    text width=1em,align=center,inner sep=0pt},
    line/.style = {draw,thick, -latex},
  service/.style={align=left, text width=0.5cm},
node distance=1.0cm and 0.4cm
]

% Place nodes
\node[block](s0){$0$};
\node[service, right of= s0, xshift=10mm, text width=3cm](s10){};
\node[block, below of = s0](s1){$1$};
\node[block, below of =s1](s2){$2$};
\node[block, right of =s2] (s3){$3$};
\node[block, below of =s2] (s4){$4$};
\path [line] (s0)--(s1);
\path [line] (s1)--(s2);
\path [line]  (s1)-|(s3);
\path [line] (s2)--(s4);
\end{tikzpicture}
\caption{1}
\label{fig:workflowsim}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\begin{tikzpicture}[
 block/.style = {circle, draw,
    text width=1em,align=center,inner sep=0pt},
line/.style = {draw,thick, -latex},
  service/.style={align=left, text width=0.5cm},
node distance=1.0cm and 0.4cm
]

% Place nodes
\node[block](s2){$0$} ;
\node[service, right of=s2,xshift=10mm, text width=3cm](s10){};
\node[block, below of =s2] (s4){$4$};
\node[block, below of =s4] (s6){$6$};
\node[block, right of =s6] (s7){$S7$};
\path [line] (s2)--(s4);
\path [line] (s4)--(s6);
\path [line] (s4)-|(s7);
\end{tikzpicture}
\caption{2}
\end{subfigure}
\caption{3}
\end{figure}
\end{document}

E isso me mostra a figura abaixo insira a descrição da imagem aqui

Como você pode ver, a figura à esquerda não está em cima de a(1) (a legenda), ela está alinhada à esquerda. É semelhante à figura certa.

Como eu poderia resolver isso?

Responder1

Existe um nó que afeta a centralização, mesmo que não esteja visível.

  • Se você não precisar do nó, remova-o.
  • Se você quiser manter o nó, adicione a overlayopção para que não ocupe espaço:

    \node[overlay, service, right of= s0, xshift=10mm, text width=3cm] (s10) {};
    

Este overlaymétodo é igualmente útil para remover esse efeito de deslocamento indesejado das setas, de forma que o espaço que elas cobrem não conte.

informação relacionada