Graphics, Figures & TablesSubfigures in sub fig package appear vertically

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Compaq
Posts: 6
Joined: Tue Feb 05, 2013 7:23 pm

Subfigures in sub fig package appear vertically

Post by Compaq »

Hi,

I am trying to generate three subfigures using the subfig package. However, instead of my subfigures being aligned horizontally, they are placed vertically. There's a MWE at the end of my post that demonstrates my problem.

I appreciate any help I can get.
Anders

Code: Select all

\documentclass{report}

\usepackage{subfig}
\usepackage{graphicx}

\begin{document}

\begin{figure}[H]
\centering

\subfloat[Kohler illumination + white light. This image is a good representation of the sample.]{
	\label{subfig:correct}
	\includegraphics[width=0.3\textwidth]{correct} } 

\subfloat[Kohler illumination + not white light: The colors, brightness, and contrast are way off.]{
	\label{subfig:notwhitelight}
	\includegraphics[width=0.3\textwidth]{wronglight} } 

\subfloat[Not kohler illumination + white light. Notice the black spot suddenly appearing (lower left corner) that has nothing to do with the sample]{
	\label{subfig:nonkohler}
	\includegraphics[width=0.3\textwidth]{nonkohler}} 
	
\caption{Three subfigures}
\label{kohler}

\end{figure}

\end{document}
Attachments
Screen Shot 2014-01-17 at 16.49.07 1.png
Screen Shot 2014-01-17 at 16.49.07 1.png (70.71 KiB) Viewed 63337 times
Last edited by cgnieder on Fri Jan 17, 2014 6:34 pm, edited 1 time 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

Compaq
Posts: 6
Joined: Tue Feb 05, 2013 7:23 pm

Subfigures in sub fig package appear vertically

Post by Compaq »

Never mind, the problem was resolved when I added \hfill in-between the images!
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Subfigures in sub fig package appear vertically

Post by sommerfee »

Compaq wrote:Never mind, the problem was resolved when I added \hfill in-between the images!
Nearly everything between the images would have solved your problem. But you had an empty line between them which indicated TeX that you would like to start a new paragraph, and therefore your three images appeared vertically aligned, just like three paragraphs.

So if you want an empty line in your source file for aesthetic reasons but don't want to start a new paragraph, use % instead, e.g.:

Code: Select all

\subfloat{.....}
%
\subfloat{.....}
Post Reply