4

I created these figures in tikzpictures. The two left ones are the first figure and the two right ones are the second figure.

How can I give them two separate captions respectively while keep both figures next to each other? If I add a second caption, the second figure always goes to the next line.

MWE:

\documentclass[12pt]{article}
\usepackage{caption}
\usepackage{tikz-qtree}
\usetikzlibrary{arrows.meta}
\usepackage{subcaption}

\begin{document}
\captionsetup[subfigure]{labelformat=empty}

\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.25\textwidth}
\centering
\begin{tikzpicture}[scale=0.25]
\tikzstyle{every node}=[font=\tiny]
\draw 
(4,9) node(a) [circle, draw] {}
(4,1) node(b) [circle, draw] {}
(1,3) node(c) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c); 
\draw [->,line width=0.8pt](c) to (a);
\draw (3,4) ellipse (6cm and 10cm);

\end{tikzpicture}
\captionof{figure}{Q}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\centering  \begin{tikzpicture}[scale=0.25]
\tikzstyle{every node}=[font=\tiny] 
\draw 
(1,1)   node(a) [circle, draw] {}
(0.5,9)  node(b) [circle, draw] {}
(4,8)  node(c) [circle, draw] {}
(4,4)   node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw [->,line width=0.8pt](d) to (a);
\draw (3,4) ellipse (6cm and 10cm);

\end{tikzpicture}
\captionof{figure}{V-Q}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\centering  \begin{tikzpicture}[scale=0.25,remember picture]
\tikzstyle{every node}=[font=\tiny] 
\draw 
(3,1)   node(x) [circle, draw] {}
(0,5)  node(y) [circle, draw] {}
(2,9)  node(z) [circle, draw] {};
\draw [->,line width=0.8pt](x) to (y);
\draw [->,line width=0.8pt](y) to (z);
\draw (3,4) ellipse (6cm and 10cm);
\end{tikzpicture}
\captionof{figure}{Q}
\end{subfigure}%
\begin{subfigure}[b]{0.25\textwidth}
\centering  \begin{tikzpicture}[scale=0.25,remember picture]
\tikzstyle{every node}=[font=\tiny] 
\draw 
(1,9)   node(a) [circle, draw] {}
(6,7)  node(b) [circle, draw] {}
(6,3)  node(c) [circle, draw] {}
(1,1)   node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw (3,4) ellipse (6cm and 10cm);
\end{tikzpicture}
\captionof{figure}{V-Q}
\end{subfigure}%
\begin{tikzpicture}[overlay, remember picture]
\draw[->,line width=0.8pt] (d) to (x);
\draw[->,line width=0.8pt] (z) to (a);
\end{tikzpicture}
\caption{Figure X}
\end{figure}
\end{document}

enter image description here

The desired outcome is: enter image description here

6
  • Thank you for editing @Bobyandbob. I'll try to follow these standards in the future.
    – XsLiar
    Nov 21, 2017 at 20:34
  • Have you tried \subcaption{} within subfigures?
    – Cragfelt
    Nov 21, 2017 at 21:06
  • Hi @Cragfelt! Yes and unfortunately it also forces the second figure (the two last circles) in the next line.
    – XsLiar
    Nov 21, 2017 at 21:09
  • 1
    Do you need 2 Subcaption(1xtwo left ones and 1xtwo right ones) and the caption of the whole figure? Or do you need also the shown Captions ( Q, V-Q,Q and V-Q)?
    – Bobyandbob
    Nov 21, 2017 at 21:13
  • @Bobyandbob I apologise for being not clear enough. I also added a picture of the desired outcome now. (Sorry for the large size). I need 2 Captions (1xtwo left ones and 1xtwo right ones). The two left circles as well as the two right circles should be seen as a whole figure respectively. I also have to keep the subcaptions (Q, V-Q, Q and V-Q).Thus I do not need a caption of the whole figure.
    – XsLiar
    Nov 21, 2017 at 21:21

3 Answers 3

2

Update: Refering to your comment. Here is a solution with Figure1 instead of the AAAA and Figure2 instead of the BBBB. So both figures will be listed themselves. The solution is similar/equivalent to Two figures side by side.

enter image description here

MWE:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{figure}
\centering
\begin{minipage}{0.45\textwidth}
\centering
\begin{tikzpicture}[scale=0.24]
\begin{scope}[xshift=-6.3cm]
\tikzstyle{every node}=[font=\tiny]
\draw 
(4,9) node(a) [circle, draw] {}
(4,1) node(b) [circle, draw] {}
(1,3) node(c) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c); 
\draw [->,line width=0.8pt](c) to (a);
\draw (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (current bounding box.south){Q};
\end{scope}
\begin{scope}[xshift=6.3cm]
\tikzstyle{every node}=[font=\tiny] 
\draw[xshift=1cm,yshift=-0.5cm] 
(1,1)   node(a) [circle, draw] {}
(0.5,9) node(b) [circle, draw] {}
(4,8)   node(c) [circle, draw] {}
(4,4)   node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw [->,line width=0.8pt](d) to (a);
\draw (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (3,-3){V-Q};
\end{scope}
\end{tikzpicture}
\caption{figure a}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\begin{tikzpicture}[scale=0.24]
\tikzstyle{every node}=[font=\tiny] 
\draw[xshift=-6.3cm](3,1)   node(x) [circle, draw] {}
(0,5)  node(y) [circle, draw] {}
(2,9)  node(z) [circle, draw] {};
\draw [->,line width=0.8pt](x) to (y);
\draw [->,line width=0.8pt](y) to (z);
\draw[xshift=-6.3cm]  (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (-3.3,-3){Q};
\draw[xshift=6.3cm] 
(1,9)  node(a) [circle, draw] {}
(6,7)  node(b) [circle, draw] {}
(6,3)  node(c) [circle, draw] {}
(1,1)  node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw[xshift=6.3cm,name=E2]  (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (9.3,-3){V-Q};
\draw[->,line width=0.8pt] (d) to (x);
\draw[->,line width=0.8pt] (z) to (a);
\end{tikzpicture}
\caption{figure b}
\end{minipage}
\end{figure}
\end{document}

Bad/ old Version:

Like this?

enter image description here

Similiar to my answer here you can do it like this below. The labels Q, V-Q, Q and V-Q are added with simple \nodes. Instead of subfigure i usd subfloat.I also have scaled your ellipsis a little bit, hope its okay.

\documentclass[12pt,border=2cm]{article}
%\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{subfig}
\usepackage{pgfplots}

\def\drawORnot{2}% 1-> bounding box on; else -> bounding box off
\usepackage{ifthen}

\newcommand{\drawboundingbox}[2][red]{
  \ifthenelse{\equal{#2}{1}}
    {
    \draw [#1] (current bounding box.south west) rectangle (current bounding box.north east);
    }
    {
    %FALSE
    }%
}
\begin{document}
\begin{figure}[h!]
\subfloat[AAAA]{\label{fig:AAAA}
\resizebox{0.5\textwidth}{!}{
\begin{tikzpicture}[scale=0.24]
\tikzstyle{every node}=[font=\tiny]
\draw 
(4,9) node(a) [circle, draw] {}
(4,1) node(b) [circle, draw] {}
(1,3) node(c) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c); 
\draw [->,line width=0.8pt](c) to (a);
\draw (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (current bounding box.south){Q};
\drawboundingbox[green]{\drawORnot}
\end{tikzpicture}
\begin{tikzpicture}[scale=0.24]
\tikzstyle{every node}=[font=\tiny] 
\draw 
(1,1)   node(a) [circle, draw] {}
(0.5,9)  node(b) [circle, draw] {}
(4,8)  node(c) [circle, draw] {}
(4,4)   node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw [->,line width=0.8pt](d) to (a);
\draw (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (current bounding box.south){V-Q};
\drawboundingbox[blue]{\drawORnot}
\end{tikzpicture}
}
}
%\hfill 
\subfloat[BBBB]{\label{fig:BBB}
\resizebox{0.5\textwidth}{!}{
\begin{tikzpicture}[scale=0.24,remember picture]
\tikzstyle{every node}=[font=\tiny] 
\draw 
(3,1)   node(x) [circle, draw] {}
(0,5)  node(y) [circle, draw] {}
(2,9)  node(z) [circle, draw] {};
\draw [->,line width=0.8pt](x) to (y);
\draw [->,line width=0.8pt](y) to (z);
\draw (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (current bounding box.south){Q};
\drawboundingbox[yellow]{\drawORnot}
\end{tikzpicture}
\begin{tikzpicture}[scale=0.24,remember picture]
\tikzstyle{every node}=[font=\tiny] 
\draw 
(1,9)   node(a) [circle, draw] {}
(6,7)  node(b) [circle, draw] {}
(6,3)  node(c) [circle, draw] {}
(1,1)   node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw (3,4) ellipse (6cm and 7cm);
\node[anchor=north] at (current bounding box.south){V-Q};
\drawboundingbox[black]{\drawORnot}
\end{tikzpicture}
\begin{tikzpicture}[overlay, remember picture]
\draw[->,line width=0.8pt] (d) to (x);
\draw[->,line width=0.8pt] (z) to (a);
\end{tikzpicture}
}
}
\hfill 
\caption{Figure X\label{fig:X}}
\end{figure}
\end{document}
0
3

I'd use tabular and two minipages for the two captions.

\documentclass[12pt]{article}
\usepackage{caption}
\usepackage{tikz-qtree}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{figure}[htp]

\begin{minipage}[b]{0.5\textwidth}

\begin{tabular}[b]{@{}cc@{}}
\begin{tikzpicture}[scale=0.25]
\tikzstyle{every node}=[font=\tiny]
\draw (4,9) node(a) [circle, draw] {}
      (4,1) node(b) [circle, draw] {}
      (1,3) node(c) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c); 
\draw [->,line width=0.8pt](c) to (a);
\draw (3,4) ellipse (6cm and 10cm);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.25]
\tikzstyle{every node}=[font=\tiny] 
\draw (1,1)   node(a) [circle, draw] {}
      (0.5,9) node(b) [circle, draw] {}
      (4,8)   node(c) [circle, draw] {}
      (4,4)   node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw [->,line width=0.8pt](d) to (a);
\draw (3,4) ellipse (6cm and 10cm);
\end{tikzpicture}
\\
Q & V--Q
\end{tabular}

\caption{X}

\end{minipage}% <---- IMPORTANT
\begin{minipage}[b]{0.5\textwidth}

\begin{tabular}[b]{@{}cc@{}}
\begin{tikzpicture}[scale=0.25,remember picture]
\tikzstyle{every node}=[font=\tiny] 
\draw (3,1) node(x) [circle, draw] {}
      (0,5) node(y) [circle, draw] {}
      (2,9) node(z) [circle, draw] {};
\draw [->,line width=0.8pt](x) to (y);
\draw [->,line width=0.8pt](y) to (z);
\draw (3,4) ellipse (6cm and 10cm);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.25,remember picture]
\tikzstyle{every node}=[font=\tiny] 
\draw (1,9) node(a) [circle, draw] {}
      (6,7) node(b) [circle, draw] {}
      (6,3) node(c) [circle, draw] {}
      (1,1) node(d) [circle, draw] {};
\draw [->,line width=0.8pt](a) to (b);
\draw [->,line width=0.8pt](b) to (c);
\draw [->,line width=0.8pt](c) to (d); 
\draw (3,4) ellipse (6cm and 10cm);
\end{tikzpicture}% <---- IMPORTANT
\begin{tikzpicture}[overlay, remember picture]
\draw[->,line width=0.8pt] (d) to (x);
\draw[->,line width=0.8pt] (z) to (a);
\end{tikzpicture}
\\
Q & V-Q
\end{tabular}

\caption{Y}

\end{minipage}

\end{figure}

\end{document}

enter image description here

6
  • Thank you @egreg. That is indeed exactly what I was looking for! I already accepted Bobyandbob's answer, but I really appreciate your help.
    – XsLiar
    Nov 21, 2017 at 21:54
  • @XsLiar Don't worry, I have enough points to call it a reputation. ;-)
    – egreg
    Nov 21, 2017 at 22:03
  • XsLiar: I think my solution isen't helpful and not so good. The answer mentioned in the comments Two figures side by side and also @egregs answer fits your question much better. I will delete my answer if its okay for you. Nevertheless you could switch to this answer and accept.
    – Bobyandbob
    Nov 21, 2017 at 22:03
  • \newcommand{\sidebysidecaption}[4]{ \RaggedRight \begin{minipage}[t]{#1} \vspace*{0pt} #3 \end{minipage} \hfill \begin{minipage}[t]{#2} \vspace*{0pt} #4 \end{minipage} } Nov 21, 2017 at 22:04
  • @XsLiarOh i can't deleted my question, before you switch to egregs answer. So you have to decide.
    – Bobyandbob
    Nov 21, 2017 at 22:08
1

Another approach with minipage

\documentclass[12pt]{article}
\usepackage{caption}
\usepackage{tikz-qtree}
\usetikzlibrary{arrows.meta}
\usepackage{subcaption}

\begin{document}
\captionsetup[subfigure]{labelformat=empty}

\begin{figure}[!htpb]
\begin{minipage}{.5\textwidth}
\centering
\begin{subfigure}[b]{0.5\textwidth}
    \centering
    \begin{tikzpicture}[scale=0.25]
        \tikzstyle{every node}=[font=\tiny]
            \draw 
        (4,9) node(a) [circle, draw] {}
        (4,1) node(b) [circle, draw] {}
        (1,3) node(c) [circle, draw] {};
        \draw [->,line width=0.8pt](a) to (b);
        \draw [->,line width=0.8pt](b) to (c); 
        \draw [->,line width=0.8pt](c) to (a);
        \draw (3,4) ellipse (6cm and 10cm);
        \end{tikzpicture}
        \captionof{figure}{Q}
    \end{subfigure}%~
    %
    \begin{subfigure}[b]{0.5\textwidth}
    \centering  
    \begin{tikzpicture}[scale=0.25]
        \tikzstyle{every node}=[font=\tiny] 
        \draw 
        (1,1)   node(a) [circle, draw] {}
        (0.5,9)  node(b) [circle, draw] {}
        (4,8)  node(c) [circle, draw] {}
        (4,4)   node(d) [circle, draw] {};
        \draw [->,line width=0.8pt](a) to (b);
        \draw [->,line width=0.8pt](b) to (c);
        \draw [->,line width=0.8pt](c) to (d); 
        \draw [->,line width=0.8pt](d) to (a);
        \draw (3,4) ellipse (6cm and 10cm);
    \end{tikzpicture}
    \captionof{figure}{V-Q}
    \end{subfigure}
    \centering\subcaption{Abb. 3.3a}
\end{minipage}%~
%
\begin{minipage}{.75\textwidth}
    \centering
    \begin{subfigure}[b]{0.25\textwidth}
    \centering  
    \begin{tikzpicture}[scale=0.25,remember picture]
        \tikzstyle{every node}=[font=\tiny] 
        \draw 
        (3,1)  node(x) [circle, draw] {}
        (0,5)  node(y) [circle, draw] {}
        (2,9)  node(z) [circle, draw] {};
        \draw [->,line width=0.8pt](x) to (y);
        \draw [->,line width=0.8pt](y) to (z);
        \draw (3,4) ellipse (6cm and 10cm);
        \end{tikzpicture}
        \captionof{figure}{Q}
    \end{subfigure}
    \hspace{1cm}
    \begin{subfigure}[b]{0.25\textwidth}
    \centering
    \begin{tikzpicture}[scale=0.25,remember picture]
        \tikzstyle{every node}=[font=\tiny] 
        \draw 
        (1,9)  node(a) [circle, draw] {}
        (6,7)  node(b) [circle, draw] {}
        (6,3)  node(c) [circle, draw] {}
        (1,1)  node(d) [circle, draw] {};
        \draw [->,line width=0.8pt](a) to (b);
        \draw [->,line width=0.8pt](b) to (c);
        \draw [->,line width=0.8pt](c) to (d); 
        \draw (3,4) ellipse (6cm and 10cm);
        \end{tikzpicture}
        \captionof{figure}{V-Q}
    \end{subfigure}
    \centering\subcaption{Abb. 3.3b}
    \hfill
    \begin{tikzpicture}[overlay, remember picture]
        \draw[->,line width=0.8pt] (d) to (x);
        \draw[->,line width=0.8pt] (z) to (a);
    \end{tikzpicture}
    \end{minipage}
\end{figure}
\end{document}

enter image description here

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