2

I saw that this has been asked before, but none of the solutions appear to work in my document. I am trying to set an 2x2 grid of sub figures, each filled with a tikz graph. However, no matter how much i adjust the textwidth or the scale, they are always displayed one below the other.

\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[Ex2]%
{{\small Ex1}}    
\end{subfigure}

\quad

\begin{subfigure}[b]{0.4\textwidth}  
\centering 
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[]%
{{\small Ex2}}    
\end{subfigure}

\bigskip 

\begin{subfigure}[b]{0.4\textwidth}   
\centering 
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[]%
{{\small Ex3}}
\end{subfigure}

\quad

\begin{subfigure}[b]{0.4\textwidth}   
\centering 
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[]%
{{\small Ex4}}    
\end{subfigure}
\caption[ Ex ]
{\small A small Ex} 
\end{figure}
\end{document}
  • 2
    Assuming you are using subcaption (a full MWE would be helpful), you need to remove the empty lines between the subfigures. Each will appear in a separate row if you have blank lines between them. – Guho Jan 26 '16 at 0:52
  • Thank you... I am a Latex beginner writing my thesis, and I was not aware of the spacing requirement. You can post it as an answer if you would like. – user340082710 Jan 26 '16 at 0:54
4

The subcaption package interprets spaces between subfigure environments within the figure to be new rows. Removing the space between these environments (and the unnecessary \quad and bigskip) yields the desired 2x2

two rows figures

\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.4\textwidth}
\centering
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[Ex2]%
{{\small Ex1}}    
\end{subfigure}
\begin{subfigure}[b]{0.4\textwidth}  
\centering 
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[]%
{{\small Ex2}}    
\end{subfigure}

\begin{subfigure}[b]{0.4\textwidth}   
\centering 
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[]%
{{\small Ex3}}
\end{subfigure}
\begin{subfigure}[b]{0.4\textwidth}   
\centering 
\begin{tikzpicture}[scale=0.4]
\node[circle,draw]{$x$}
;
\end{tikzpicture}
\caption[]%
{{\small Ex4}}    
\end{subfigure}
\caption[ Ex ]
{\small A small Ex} 
\end{figure}
\end{document}
  • @Mico: I agree. Added. – Guho Jan 26 '16 at 1:34

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.