Graphics, Figures & Tablessubfloats run over textwidth and do not form subfigures?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
arjmage
Posts: 2
Joined: Sun Feb 13, 2011 6:55 pm

subfloats run over textwidth and do not form subfigures?

Post by arjmage »

Hello World!

My first post to the latex community. I've read several posts before, but this time I'm flummoxed (frustrated?) enough to need direct help.

I have been using the subfigure to make figures with multiple images, and using caption package to adjust the caption. Once I came to the problem of having too many subfigures to fit into one page, I discovered on reading that subfig is the new package to use, which makes subfloats.

So I changed the needed code, and now I can produce subfloats in the figure environment -- with one very basic flaw. The subfloats are all stacked horizontally one next to the other. To elaborate:

1) the subfigures are loading the right images in the right size
2) the subfigures are horizontally placed next to each other
3) they do not recognize the end of \textwidth and break to the next 'row' of subfigures as used to happen with the subfigure package. instead they seem to flow over the line.

How do I fix this problem to have the same functionality as the subfigure package?

I know that whitespace affects placement of subfloats, but I would like to render my placement by adjusting the \width=X\textwidth in \includegraphic and not by introducing linebreaks inside the figure. This is because I'm generating my tex file programmatically, and I would like the tex engine to recognize:

1. the next subfigure cannot fit on this 'row' and must be placed on the next row (with \width=0.18\textwidth, this should be 5 images in the row)
2. the next subfigure cannot fit onto this page and must be to the next page.

Please see the attached code and the generated output for more details.

Thanks in advance,
A

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}
\usepackage[multidot]{grffile}
\usepackage{graphicx}
\usepackage{fancyhdr, lastpage, verbatim}
\usepackage[labelfont={sf}, textfont=sf]{caption,subfig}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\renewcommand{\thesubfigure}{[\thefigure.\arabic{subfigure}]}

\captionsetup[subfigure]{font=footnotesize,labelformat=simple,labelsep=colon, justification=Centering,format=hang,indention=0pt}

\begin{document}
\fancyfoot[R]{Page \thepage  ~of \pageref {LastPage} }
\pagestyle{fancy}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%          Maptype: RGB          %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\fancyfoot[C]{ helgo2011\_aquaria }
\fancyhead[C]{ RGB }
\begin{center}
 ************************** 
\end{center}
\begin{figure}
\centering
\subfloat[25.01.2011  08:58 \newline RGB:  \newline aquaria\_00 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0125_aquaria/bmp/rgb/aquaria_00_rgb.png}}
\subfloat[25.01.2011  13:01 \newline RGB:  \newline aquaria\_01 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0125_aquaria/bmp/rgb/aquaria_01_rgb.png}}
\subfloat[25.01.2011  17:03 \newline RGB:  \newline aquaria\_02 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0125_aquaria/bmp/rgb/aquaria_02_rgb.png}}
\subfloat[26.01.2011  08:54 \newline RGB:  \newline aquaria\_00 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/rgb/aquaria_00_rgb.png}}
\subfloat[26.01.2011  13:01 \newline RGB:  \newline aquaria\_01 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/rgb/aquaria_01_rgb.png}}
\subfloat[26.01.2011  13:26 \newline RGB:  \newline aquaria\_02 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/rgb/aquaria_02_rgb.png}}
\subfloat[26.01.2011  17:01 \newline RGB:  \newline aquaria\_03 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/rgb/aquaria_03_rgb.png}}
\end{figure}
\addtocounter{figure}{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%         Maptype: CMPI          %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\fancyfoot[C]{ helgo2011\_aquaria }
\fancyhead[C]{ CMPI }
\begin{center}
 ************************** 
\end{center}
\begin{figure}
\centering
\subfloat[25.01.2011  08:58 \newline CMPI: 4.0174 \newline aquaria\_00 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0125_aquaria/bmp/cmpi/aquaria_00_cmpi_4.0174_0.0000_15.0000.png}}
\subfloat[25.01.2011  13:01 \newline CMPI: 3.9624 \newline aquaria\_01 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0125_aquaria/bmp/cmpi/aquaria_01_cmpi_3.9624_0.0000_15.0000.png}}
\subfloat[25.01.2011  17:03 \newline CMPI: 4.0024 \newline aquaria\_02 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0125_aquaria/bmp/cmpi/aquaria_02_cmpi_4.0024_0.0000_15.0000.png}}
\subfloat[26.01.2011  08:54 \newline CMPI: 3.9852 \newline aquaria\_00 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/cmpi/aquaria_00_cmpi_3.9852_0.0000_15.0000.png}}
\subfloat[26.01.2011  13:01 \newline CMPI: 4.0789 \newline aquaria\_01 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/cmpi/aquaria_01_cmpi_4.0789_0.0000_15.0000.png}}
\subfloat[26.01.2011  13:26 \newline CMPI: 4.0263 \newline aquaria\_02 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/cmpi/aquaria_02_cmpi_4.0263_0.0000_15.0000.png}}
\subfloat[26.01.2011  17:01 \newline CMPI: 4.0476 \newline aquaria\_03 \newline \textbf{}]{\includegraphics[width=0.18\textwidth] {/media/ARJMPI/helgo2011/hsi/hsscans/0126_aquaria/bmp/cmpi/aquaria_03_cmpi_4.0476_0.0000_15.0000.png}}
\end{figure}
\addtocounter{figure}{1}

\end{document}

Attachments
Problem with output of code.
Problem with output of code.
PDFoutput.png (145.91 KiB) Viewed 2667 times

Recommended reading 2024:

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

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

arjmage
Posts: 2
Joined: Sun Feb 13, 2011 6:55 pm

subfloats run over textwidth and do not form subfigures?

Post by arjmage »

A reply to myself for the first (minor) part of the question:

The figure environment with subfloats tracks the whitespaces, but with no whitespaces at all it is unable to know when to break to the next line. This is easily solved by introducing some space between the images (also looks good anyhow).

Code: Select all

\begin{figure}
\subfloat[Subcaption here]{\includegraphic{width=1cm}{graphic.png}} \,    % note the \, math space. also works with \hspace
However, I still do not know how to break the single figure across multiple pages by using the \ContinuedFloat command in subfig package -- that is to do it programmatically.

Does anybody know if this would even be possible with tex?
Post Reply