서브플롯 아래의 공통 캡션

서브플롯 아래의 공통 캡션

레이블을 통해 참조할 수 있는 두 플롯 아래의 중간에 공통 캡션을 어떻게 만들 수 있으며, 서브플롯 캡션이 한 줄에 맞도록 (a)와 (b)를 제거하려면 어떻게 해야 합니까?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{subfig}
\usepackage{float}

\begin{document}
\begin{figure}
\centering
\subfloat[Compability graph]
{%
\begin{tikzpicture}
    \node[shape=circle,draw=black] (A) at (0,0) {3};
    \node[shape=circle,draw=black] (B) at (0,1) {2};
    \node[shape=circle,draw=black] (C) at (0,2) {1};
    \node[shape=circle,draw=black] (D) at (2,0) {6};
    \node[shape=circle,draw=black] (E) at (2,1) {5};
    \node[shape=circle,draw=black] (F) at (2,2) {4} ;

    \path [-] (C) edge node[left] {} (D);
    \path [-] (C) edge node[left] {} (E);
    \path [-] (C) edge node[left] {} (F);
    \path [-] (B) edge node[left] {} (E);
    \path [-] (B) edge node[left] {} (D);
     \path [-] (A) edge node[left] {} (D);
\end{tikzpicture}
%
}\hfil
\subfloat[Conflict graph]
{%
\begin{tikzpicture}
    \node[shape=circle,draw=black] (A) at (0,0) {3};
    \node[shape=circle,draw=black] (B) at (0,1) {2};
    \node[shape=circle,draw=black] (C) at (0,2) {1};
    \node[shape=circle,draw=black] (D) at (2,0) {6};
    \node[shape=circle,draw=black] (E) at (2,1) {5};
    \node[shape=circle,draw=black] (F) at (2,2) {4} ;

    \path [-] (B) edge node[left] {} (F);
    \path [-] (A) edge node[left] {} (E);
     \path [-] (A) edge node[left] {} (F);
\end{tikzpicture}
%
}
\end{figure}
\end{document}

답변1

나는 당신이 아래 그림과 같은 것을 갖고 싶어한다고 가정합니다.

여기에 이미지 설명을 입력하세요

나는 당신이 의도한 대로 하는 것을 권장하지 않습니다. subcation번호( (a), )를 지우면 (b)해당 번호를 참조할 수 없게 됩니다. 한 줄의 경우 subcation위 그림과 같이 수평 거리를 약간 늘리는 것이 좋습니다.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,positioning}
\usepackage{subfig}
\usepackage{float}

\begin{document}
\begin{figure}
\centering
\subfloat[Compability graph \label{fig:main-a}]
{%
\begin{tikzpicture}[
    node distance = 3mm and 22mm,
      start chain = going above,
every node/.style = {shape=circle, draw=black, 
    inner sep=1mm, on chain}
                    ]
\node   (A) {3};
\node   (B) {2};
\node   (C) {1};
%
\node   (D) [right=of A]    {6};
\node   (E) {5};
\node   (F) {4} ;
%%
\draw   (C) -- (D)  (C) -- (E)  (C) -- (F)
        (B) -- (E)  (B) -- (D)
        (A) -- (D);
\end{tikzpicture}
%
}\hfil
\subfloat[Conflict graph \label{fig:main-b}]
{%
\begin{tikzpicture}[
    node distance = 3mm and 22mm,
      start chain = going above,
every node/.style = {shape=circle, draw=black,
    inner sep=1mm, on chain}
                    ]
\node   (A) {3};
\node   (B) {2};
\node   (C) {1};
%
\node   (D) [right=of A]    {6};
\node   (E) {5};
\node   (F) {4} ;
%%
\draw   (B) -- (F)
        (A) -- (E)  (A) -- (F);
\end{tikzpicture}
%
}
\caption{Main caption}
    \label{fig:main}
\end{figure}
\end{document}

보시다시피 메인 캡션을 추가하는 것은 큰 문제가 아닙니다. article텍스트 너비 중간에 캡션을 넣는 캡션 기능입니다 . 패키지를 사용하려면 caption이에 따라 캡션을 설정해야 합니다. 이를 위해서는 패키지 설명서를 읽어야 합니다. 그렇지 않으면 나는 자유롭게 코드를 훨씬 더 간결하게 만들었지만 여전히 순수한 TikZ 그림을 유지합니다. 여기에는 라이브러리 chainspositioning.

답변2

다음은 다음을 사용하는 옵션입니다.subcaption- 상자의 너비를 지정할 수 있습니다. 따라서 각각의 너비를 가진 두 개의 상자를 지정하면 .5\linewidth페이지와 서로에 대해 중앙에 배치됩니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}

\usepackage{graphicx,subcaption}

\begin{document}

\begin{figure}[ht]
  \centering
  \subcaptionbox{Compability graph}{%
    \includegraphics[width=80pt]{example-image-a}%
  }\hfill
  \subcaptionbox{Conflict graph}{%
    \includegraphics[width=80pt]{example-image-b}%
  }

  \bigskip

  \subcaptionbox{Compability graph}[.5\linewidth]{%
    \includegraphics[width=80pt]{example-image-a}%
  }%
  \subcaptionbox{Conflict graph}[.5\linewidth]{%
    \includegraphics[width=80pt]{example-image-b}%
  }

  \bigskip

  \subcaptionbox*{Compability graph}{%
    \includegraphics[width=80pt]{example-image-a}%
  }\hfill
  \subcaptionbox*{Conflict graph}{%
    \includegraphics[width=80pt]{example-image-b}%
  }
  \caption{A figure caption}
\end{figure}

\end{document}

*또한 별표 표시된 버전의 캡션을 사용하여 번호 매기기를 제거하여 약간의 추가 공간을 제공하는 옵션도 허용합니다 .

관련 정보