GeneralStarting chapter without a pagebreak

LaTeX specific issues not fitting into one of the other forums of this category.
Cedric Tsui
Posts: 7
Joined: Mon Sep 22, 2008 5:37 am

Starting chapter without a pagebreak

Post by Cedric Tsui »

Hello everyone!

So. My professor complained about wanting to save trees and told me not to leave any white space in my thesis at all.
This meant shrinking chapter headings, using ragged ends and so on. But now I need to start chapters in this report without starting a new page.

Is there a way to force a chapter to start without breaking to a new page?
Thanks for all your help! I'm using a special .cls file that's based on the report class.

Cedric
My code (abridged)

\documentclass[oneandahalfspaced, 12pt]{ut-thesis}
\usepackage{appendix}
(bunch of random packages)
(special commands to shrink chapter headers)
(special commands to favor putting figures on the same page)

\raggedbottom
(bunch of random automatic title page and Toc commands)

\input{introduction}
\input{background}
\input{methods}
\input{discussion}
\input{conclusion}

\appendix
\addappheadtotoc
\input{sims}
\input{ldsTrouble}
\input{obake}

Recommended reading 2024:

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

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

balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Starting chapter without a pagebreak

Post by balf »

You can use titlesec to redefine the aspect of chapters. You should first change its sectioning class to straight. Take a look at the doc.

B.A.
Cedric Tsui
Posts: 7
Joined: Mon Sep 22, 2008 5:37 am

Re: Starting chapter without a pagebreak

Post by Cedric Tsui »

Thanks Balf

But I've had terrible luck with the titlesec package. It doesn't seem to do what it says it does.
I've never been able to get the titlespacing command to work, and ended up renewing commands to change the way the chapters are defined.

Right now, if I even call the titlesec package, latex gives an error once it enters the document. The ut thesis class controls the abstract.

underfull \hbox (badness 10000) in paragraph at lines 194-194
|\OT1/cmr/bx/n/14.4 Abstract|

!LaTeX Error: Something's wrong--perhaps a missing \item.

see the latex manual...... for explanation

1.194 \begin{abstract}




Sorry. I'm so very confused.
Oh. And here's what I did instead of using titlesec to shrink chapter title headings and remove the whitespace around them. I feel that I understand these commands about 2% more than I understand titlesec.

%This part removes all the white space around the chapter heading
%I have no idea how it works :(
\makeatletter
\renewcommand*\@makechapterhead[1]{%
{\parindent \z@ \raggedright \normalfont
\huge\bfseries
\ifnum \c@secnumdepth >\m@ne
\thechapter\hspace{1cm}
\fi
#1\par\nobreak
\vskip 20\p@
}}
\makeatother

\makeatletter
\renewcommand*\@makeschapterhead[1]{%
{\parindent \z@ \raggedright
\normalfont
\huge\bfseries #1\par\nobreak
\vskip 20\p@
}}
\makeatother
%End of chapter header voodoo section
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

Starting chapter without a pagebreak

Post by Stefan Kottwitz »

Hi Cedric,

the problem of ut-thesis with titlesec is caused by its implementation of the abstract environment, because it's using \section* inside a center environment. Temporarily disabling the center environment by

Code: Select all

\renewenvironment{center}{}{}
enclosed in braces to limit the scope would prevent the error from occuring.
But it seems you have solved the problem in a different way.

Stefan
LaTeX.org admin
Cedric Tsui
Posts: 7
Joined: Mon Sep 22, 2008 5:37 am

Starting chapter without a pagebreak

Post by Cedric Tsui »

Oh. That's interesting. I've found where UT-THESIS.CLS declares the abstract.

Code: Select all

   \begin{center}
      \section*{Abstract}
   \end{center}
I can see that removing those center formatting commands would solve the problem, just as well as \renewenvironment{center}{}{}. But I don't understand why calling \section* inside a centered environment is abnormal to the point that it would cause a crash. It seems like a pretty simple and straightforward change to me.

Is it this class file that's not following etiquette? Or is it the titlesec package that is inflexible?

Cheers
Cedric
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

Starting chapter without a pagebreak

Post by Stefan Kottwitz »

The center environment is internally using \trivlist, that's why the missing \item error occured. I usually prefer \centering (used by center too), for an explanation see \center vs. \centering.
As ut-thesis is based on standard classes I would not complain about center and \section*, it's just not compatible with titlesec, but that can be solved.

Stefan
LaTeX.org admin
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Starting chapter without a pagebreak

Post by balf »

Perhaps you didn't notice that titlesec discourages the use of starred sectioning commands and suggests instead to use a set of mark-up commands (see §4.2 and 4.3 of the doc). I suppose it's for some reason... You might overload the defintion of abstract given in ut-thesis in order to make it compatible with titlesec, following its guidelines.

B.A.
Cedric Tsui
Posts: 7
Joined: Mon Sep 22, 2008 5:37 am

Re: Starting chapter without a pagebreak

Post by Cedric Tsui »

Hey everyone.

Thanks for all the help.
So I've spent a day fiddling with titlesec, and still can't get it to work at all.

First, I made a new version of the ut-thesis class and made a few changes.

I changed anything that said something similar to:
\begin{center}
\section*{Abstract}
\end{center}


to:
{\centering
\section*{Abstract}
}%end of centering

That got rid of the conflict with titlesec, but strangely enough, the section heading was no longer centered. The same thing happened if I used \renewenvironment{center}{}{} around the abstract.


Even at this point, I can't get titlesec to do anything except for change the size of the words 'chapter' which I want to remove anyways.
\usepackage[compact]{titlesec} does nothing
Even if I add \titlespacing{\chapter}{0pt}{*0}{*0}
I get no results whatsoever.
I've read titlesec.pdf that comes with the package. I just don't seem to understand what it says.

I'm so frustrated. How on earth did you guys learn how to navigate LaTeX? I'm not a programmer by profession, but I thought I was half decent at it. :(

This is what I'm looking for. Starting on the SAME PAGE as the last chapter ended.

1 Background
blah blah blah

I need to control the size of the header, and need almost no whitespace.


Thanks!
Cedric
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

Starting chapter without a pagebreak

Post by Stefan Kottwitz »

Hi Cedric!

titlesec can center the sections, there's no need to put \centering before or center around, for example:

Code: Select all

\titleformat{\section}{%
\centering\normalfont\Large\bfseries}{\thesection}{1em}{}
To prevent the page breaks before new chapters, one possibility is to redefine chapter without \clearpage or \cleardoublepage, let's use \par instead:

Code: Select all

\makeatletter
\renewcommand\chapter{\par%
  \thispagestyle{plain}%
  \global\@topnum\z@
  \@afterindentfalse
  \secdef\@chapter\@schapter}
\makeatother
Is made of the \chapter code from report, used by ut-thesis.cls.

You could make \chapter similar to \section, perhaps just a bit larger:

Code: Select all

\titleformat{\chapter}{%
\centering\normalfont\LARGE\bfseries}{\thechapter}{1em}{}
Similar for the spacing:

Code: Select all

\titlespacing*{\chapter} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
I know the titlesec doc is not very easy to read. But 9.2. Standard Classes in it's appendix provides a good start. On the other hand it's not so difficult to take the source of the used class (like report.cls here) and to redefine a command as needed, like I did with \chapter above.

Stefan
LaTeX.org admin
Cedric Tsui
Posts: 7
Joined: Mon Sep 22, 2008 5:37 am

Re: Starting chapter without a pagebreak

Post by Cedric Tsui »

Oh. I understand now.

For some reason I thought that the page break was contained in the makechapterhead code, and was trying to find out what \z@ meant. (btw. what does it mean?)

Thank you so much!
Cedric
Post Reply