22

How could I have a figure with 3 or 4 subfigures side-by-side in the same row? I've tried it once but the best I had was only 2 subfigures side-by-side in the same row.

My code so far is:

\documentclass[12pt,a4paper,titlepage,twoside,openright]{article}
\usepackage[english,greek]{babel}
\usepackage{ucs} 
\usepackage[utf8x]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{subcaption} 

\begin{document}
\begin{figure}
     \begin{subfigure}[b]{0.30\textwidth}
\centering
        \begin{tikzpicture}
 \draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
    \draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
    \draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,2)  node[left] {$\text{Η}$} to [out=0, in=90] (2,0)node[below]{$\text{Θ}$};
\draw[<-, Cyan] (45:2.1) -- (45:2.9);
\end{tikzpicture}
    \label{fig:subfig8}
          \caption{}
       \end{subfigure}
     \begin{subfigure}[b]{0.30\textwidth}
\centering
           \begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
    \draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
    \draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,2.7)  node[left] {$\text{Γ}$} to [out=0, in=90] (1.5,0)node[below]{$\text{Δ}$};
\draw[<-, Cyan] (45:2.2) -- (45:2.9);
\end{tikzpicture}
    \label{fig:subfig9}
          \caption{}
          \end{subfigure}
     \begin{subfigure}[b]{0.35\textwidth}
\centering
        \begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
    \draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
    \draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,1.5)  node[left] {$\text{E}$} to [out=0, in=90] (2.5,0)node[below]{$\text{Z}$};
\draw[<-, Cyan] (45:2.1) -- (45:2.5);
\end{tikzpicture}
\label{fig:subfig10}
          \caption{}
     \end{subfigure}
\captionof{figure}{τεχνολογία και στα δυο αγαθά} \label{fig:subfig1.a.4}
 \end{figure}

\end{document}
1
30

The following code is used for 3, it requires the subcaption package. If have more than 3 change the 0.30\textwidth parameter of the subfigure to resize each of them accordingly

 \begin{figure}
     \begin{subfigure}[b]{0.30\textwidth}
          \centering
          \resizebox{\linewidth}{!}{\input{figures/a.tikz}}  
          \caption{Caption A}
          \label{fig:A}
     \end{subfigure}
     \begin{subfigure}[b]{0.30\textwidth}
          \centering
          \resizebox{\linewidth}{!}{\input{figures/b.tikz}}  
          \caption{Caption B}
          \label{fig:B}
     \end{subfigure}
     \begin{subfigure}[b]{0.30\textwidth}
          \centering
          \resizebox{\linewidth}{!}{\input{figures/c.tikz}}  
          \caption{Caption C}
          \label{fig:C}
     \end{subfigure}
 \end{figure}

EDIT: I've taken the time to fix your code. You were missing the \resizebox in order to properly locate your tikz figures. See code and results below

\documentclass[12pt,a4paper,titlepage,twoside,openright]{article}
\usepackage[english,greek]{babel}
\usepackage{ucs} 
\usepackage[utf8x]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{subcaption} 

\begin{document}
\begin{figure}
    \begin{subfigure}[b]{0.32\textwidth}
        \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
                \draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
                \draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
                \draw[ForestGreen] (0,2)  node[left] {$\text{Η}$} to [out=0, in=90] (2,0)node[below]{$\text{Θ}$};
                \draw[<-, Cyan] (45:2.1) -- (45:2.9);
            \end{tikzpicture}
        }
        \caption{Subfigure A}
        \label{fig:subfig8}
    \end{subfigure}
    \begin{subfigure}[b]{0.32\textwidth}
    \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
                \draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
                \draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
                \draw[ForestGreen] (0,2.7)  node[left] {$\text{Γ}$} to [out=0, in=90] (1.5,0)node[below]{$\text{Δ}$};
                \draw[<-, Cyan] (45:2.2) -- (45:2.9);
            \end{tikzpicture}
        }
        \caption{Subfigure B}   
        \label{fig:subfig9}
    \end{subfigure}
    \begin{subfigure}[b]{0.32\textwidth}
        \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
                \draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
                \draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
                \draw[ForestGreen] (0,1.5)  node[left] {$\text{E}$} to [out=0, in=90] (2.5,0)node[below]{$\text{Z}$};
                \draw[<-, Cyan] (45:2.1) -- (45:2.5);
            \end{tikzpicture}
        }
        \caption{Subfigure C}
        \label{fig:subfig10}
    \end{subfigure}
\caption{τεχνολογία και στα δυο αγαθά} 
\label{fig:subfig1.a.4}
\end{figure}

\end{document}

enter image description here

I hope this helps!

Update: Fixed missing { in resizeboxes.

9
  • 4
    Perhaps you should mention that your code requires the subcaption package. Jun 25 '13 at 15:11
  • If I use the subfigure package, does the code change?
    – Y_gr
    Jun 26 '13 at 11:14
  • 3
    @giannis Yes, it changes. You shouldn't use subfigure as it is deprecated. You are better off with subcaption
    – Dan
    Jun 26 '13 at 11:31
  • Thank you. That was helpful. I'd like to add, however, that the caption (a), (b), (c) of each subfigure is not centered below of figure. I've tried also \centering but still they aren't centered.
    – Y_gr
    Jun 26 '13 at 11:49
  • 1
    @giannis I've updated my answer, fixing your code.
    – Dan
    Jun 28 '13 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.