Graphics, Figures & TablesKeeping all the figures within a chapter

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
arwintcher
Posts: 29
Joined: Thu Feb 19, 2009 3:23 pm

Keeping all the figures within a chapter

Post by arwintcher »

I have one very image-heavy chapter in my thesis. I don't mind if some of the graphics get pushed to the end of the chapter, after the text, but LaTex is pushing them to the next chapter, so that I get these figures between unrelated blocks of text.

What's the best way to force LaTex to keep all of the images together, then start the next chapter on a new page?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Lucia
Posts: 36
Joined: Wed Dec 31, 2008 9:03 pm

Keeping all the figures within a chapter

Post by Lucia »

Hi arwintcher.

You could divide your thesis into several files, each containing a chapter, and then in the main file (that you compile) use the \include command. This command starts on a new page and all your images are kept together.

Example:

Code: Select all

\documentclass{article}
%this is the preamble with your options
\begin{document}
\include{chap1} %chapter with text
\include{chap2} %chapter with text and images
\include{chap3} %chapter with text
\end{document}
Hope this helps.
Lucia
arwintcher
Posts: 29
Joined: Thu Feb 19, 2009 3:23 pm

Re: Keeping all the figures within a chapter

Post by arwintcher »

Thanks for your help.

The chapters are already split up in the manner in which you describe. I've tried messing around with \clearpage but it didn't seem to have any effect.

Should splitting them into chapters avoid this problem? I'm not sure how to construct a MWE for this problem.

Thanks,
Amanda
Lucia
Posts: 36
Joined: Wed Dec 31, 2008 9:03 pm

Keeping all the figures within a chapter

Post by Lucia »

Yes, splitting into chapters avoids this problem. I have a thesis created in an word processor, and I'm rebuilding it in LaTeX. My thesis has seven chapters, with several tables and figures in each chapter, and the compiling process keeps figures and tables in the correct chapter.

But why are you using \clearpage? The command \include is internally defined to use the \clearpage command, so you don't need to use it again. Actually, the \include command is defined as

Code: Select all

\clearpage \input{file} \clearpage
. Could you explain in further detail the problem in your thesis?
arwintcher
Posts: 29
Joined: Thu Feb 19, 2009 3:23 pm

Re: Keeping all the figures within a chapter

Post by arwintcher »

Hi,

I read somewhere (can't recall where now) that \clearpage would force LaTex to dump the rest of the figures at the end of the chapter, if they didn't fit on any of the previous pages.

I've split the offending chapter into two chapters and now it doesn't happen. But what I was getting before was a few lines of chapter 6, then a figure from chapter 5, for the first 4 or 5 pages of chapter 6. The figure numbers were right, they were just displayed in the wrong place.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Keeping all the figures within a chapter

Post by localghost »

arwintcher wrote:[...] I read somewhere (can't recall where now) that \clearpage would force LaTex to dump the rest of the figures at the end of the chapter, if they didn't fit on any of the previous pages. [...]
That is wrong. The \clearpage command forces the output of all floats declared at this point. Hence the \include command for the next chapter should have this effect.

Just declare your floats at the end of each chapter. The key for float placement is the list of optional parameters. You may give the parameter [!p] to place them on a special float page without any text.


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
jortiz
Posts: 1
Joined: Thu Oct 28, 2010 10:51 pm

Re: Keeping all the figures within a chapter

Post by jortiz »

Dear all

Following this query, I've a closely related one.

Given that the CTABLE and ENDFLOAT packages are incompatible, I've desisted from using ENDFLOAT (as I want my figs and tables at the end of my thesis)

Now, I was thinking of a workaround for putting my figs and tables at the end of every CHAPTER.

How? I was thinking of using FloatBarrier command from PLACEINS package (inserted at the end of every Chapter), redefining the floating-related parameters (see below), and using placement options [tbp]. So, as in TEXT pages I'm setting bottomnumber, topnumber and totalnumber =0, and topfraction and bottomfractions too small to be able to contain any float, I'm forcing LaTeX to put all my unprocessed Floats at the end of every Chapter as that's where I put my \FloatBarrier commands.

Thxs vm, but I've spent hours and hours trying to make ENDFLOAT work with CTABLES, but .....

Does anyone know of another possible solution to what I'm trying to achieve?

Maybe it'd be better to use normal TABLE environment instead of CTABLES and use ENDFLOAT .....

Thxs vm in advance

Jose

\renewcommand{\topfraction}{0.1}
\renewcommand{\bottomfraction}{0.1}
% Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{0}
\setcounter{bottomnumber}{0}
\setcounter{totalnumber}{0}
\renewcommand{\textfraction}{0.07}
% Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.7}
% N.B.: floatpagefraction MUST be less than topfraction !!
Post Reply