
하위 그림을 사용하여 두 그림을 합쳤지만 중앙에 있지 않습니다.
아래는 내 코드입니다.
\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}
그리고 그것은 나에게 아래와 같은 그림을 보여줍니다
보시다시피 왼쪽 그림은 a(1)(캡션) 위에 있지 않고 왼쪽 정렬되어 있습니다. 오른쪽 그림과 비슷합니다.
이 문제를 어떻게 해결할 수 있나요?
답변1
눈에 보이지 않더라도 센터링에 영향을 미치는 노드가 있습니다.
- 노드가 필요하지 않으면 제거하세요.
노드를 유지하려면
overlay
공간을 차지하지 않도록 옵션을 추가하세요.\node[overlay, service, right of= s0, xshift=10mm, text width=3cm] (s10) {};
이 overlay
방법은 원치 않는 화살표 이동 효과를 제거하는 데에도 유용하므로 화살표가 차지하는 공간은 계산되지 않습니다.