Graphics, Figures & Tables2x2 figures with subfig

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
miceleee
Posts: 7
Joined: Wed Jan 19, 2011 1:50 am

2x2 figures with subfig

Post by miceleee »

Hi all,

I'd like to have 4 subfloats organized in two lines
(i.e.:
x x
x x )
But when I had 2x subfloats separated by \newline, the second pair of figures won't align.
Do I have to use subfigure?
I'm at the end of a long document, I'm concerned having to change all the syntax of my figures.

Thanks everyone!
M

my example:
\usepackage{subfig}
\begin{document}
\begin{figure}%[!hbt]
\begin{center}
\subfloat[Float1]{\includegraphics[width=0.33\textwidth, height=0.23\textheight]{figures/F1}}
\subfloat[Figure2]{\includegraphics[width=0.33\textwidth,height=0.23\textheight]{figures/F2}}
\newline
\noindent
\subfloat[Figure3]{\includegraphics[width=0.33\textwidth, height=0.23\textheight]{figures/F3}} % \newline
\subfloat[Biomass in bioreactor]{\includegraphics[width=0.33\textwidth,height=0.23\textheight]{figures/F3}}
\end{center}
\caption[caption]{caption}
\end{center}
\end{figure}
\end{document}
Last edited by miceleee on Sat Jan 22, 2011 3:14 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: 2x2 figures with subfig

Post by sommerfee »

1. This is not a complete minimal example. (See forum rules.) So we can't reproduce the problem, and therefore can't fix it for sure, only a mixture of suggesting, guessing, and looking into the crystal ball is possible.

2. There are two \end{center} but only one \begin{center}. Anyway, this produces extra (and usually unwanted) extra vertical space, so better use a simple \centering instead.

3. Never ever use \newline inside a centered environment because it simply don't work correctly. Use \\ instead.
miceleee
Posts: 7
Joined: Wed Jan 19, 2011 1:50 am

Re: 2x2 figures with subfig

Post by miceleee »

Thanks for the reply.

No 3. did the trick. All good.

Thanks for reminding me the correct syntax and a minimal working example, in other words have a rest when it is late night.
Thanks!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

2x2 figures with subfig

Post by localghost »

miceleee wrote:[…] No 3. did the trick. All good. […]
Then please be so kind and mark the topic accordingly as written in Section 3 of the Board Rules.


Thorsten
Post Reply