Page LayoutReformat Chapter Headings to minimize white Space

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
seth_teller
Posts: 3
Joined: Sun May 06, 2012 12:30 pm

Reformat Chapter Headings to minimize white Space

Post by seth_teller »

I wish to redefine chapter hedaings so that instead of rendering as it does now, i.e. as:

[page break]
[lots of whitespace]
Chapter \thechapter
[whitespace]
Foo
[lots of whitespace]

I would instead get

Chapter \thechapter{:} Foo % note no page or line break
[minimal whitespace]

I managed to do this by copying book.cls to mybook.cls and randomly hacking it, but still had to add white space manually after each \chapter call throughout the body of the document.

Can someone suggest an elegant way to accomplish this via a single \renewcommand or the like in my preamble? Thank you.

Code: Select all

\documentclass[12pt]{mybook}

\begin{document}
\chapter{Foo}
\chapter{Bar}
\end{document}

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Reformat Chapter Headings to minimize white Space

Post by localghost »

Take a look at the titlesec package. Its manual has several examples which should be a good start. Other solutions can be found by a Forum Search.


Best regards and welcome to the board
Thorsten
seth_teller
Posts: 3
Joined: Sun May 06, 2012 12:30 pm

Reformat Chapter Headings to minimize white Space

Post by seth_teller »

Thanks much. OK, I tried titlesec (see MWE below) and it does what I want,
with two exceptions:
1) There is an unexplained blank page before the 2nd chapter.
How can I suppress it?
2) There is a lot of whitespace above each heading.
How can I suppress it?
Seth

Code: Select all

\documentclass[12pt]{book}
\usepackage{titlesec}
\def\chaptertitlename{Section}
\titleformat{\chapter}{\normalfont\Large\bfseries}{\chaptertitlename\ \thechapter{:\ }}{0pt}{\Large}{}
\titlespacing{\chapter}{0pt}{0pt}{10pt}
\begin{document}
\chapter{Foo}
%
This is chapter Foo.
\chapter{Bar}
%
This is chapter Bar.
\end{document}
Last edited by Stefan Kottwitz on Sun May 06, 2012 4:26 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Reformat Chapter Headings to minimize white Space

Post by cgnieder »

You can use the \titlespacing{<cmd>}{<left>}{<above>}{<below>}[<right>] command to shift the title further up.

I can't see any unexplained blank space before the 2nd chapter.

I used the showframe package to visualize page dimensions:

Code: Select all

\documentclass[12pt]{book}
\usepackage{showframe}
\usepackage{titlesec}
\def\chaptertitlename{Section}
\titleformat{\chapter}{\normalfont\Large\bfseries}{\chaptertitlename\ \thechapter{:\ }}{0pt}{\Large}{}
\titlespacing{\chapter}{0pt}{-20pt}{10pt}
\begin{document}
\chapter{Foo}
%
This is chapter Foo.
\chapter{Bar}
%
This is chapter Bar.
\end{document}
Regards
site moderator & package author
seth_teller
Posts: 3
Joined: Sun May 06, 2012 12:30 pm

Re: Reformat Chapter Headings to minimize white Space

Post by seth_teller »

Thanks. The cause of the extra blank page was a \cleardoublepage in book style, I think.

Everything works now.

Best,

Seth
Post Reply