Page LayoutDifferent Formats for numbered and unnumbered Chapters

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
laurocesar
Posts: 7
Joined: Tue Dec 04, 2012 12:34 pm

Different Formats for numbered and unnumbered Chapters

Post by laurocesar »

Hi guys!

When using report class, how can I format \chapter* (starred) to be printed centralized and \chapter (normal one) to be printed flush left in the form "No. Chapter description", like "4 Trip over galaxy", I mean, without the string "Chapter 4 \\ Trip over galaxy" from report class.

Thanks a lot!

Lauro César

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Different Formats for numbered and unnumbered Chapters

Post by cgnieder »

Hi Lauro and welcome to the LaTeX community!

The titlesec package allows you to format chapter and section titles as you like. If I remember correctly you can also achieve different formats for numbered and unnumbered titles.

Regards
site moderator & package author
laurocesar
Posts: 7
Joined: Tue Dec 04, 2012 12:34 pm

Different Formats for numbered and unnumbered Chapters

Post by laurocesar »

Hi cgnieder!

Thanks for the answer and for the welcome.

In fact, I've tried titlesec, but I couldn't found a way to format \chapter* and \chapter differentially. But I may be wrong (I'm probably).

Another idea?

Thanks!

Lauro César
Last edited by localghost on Thu Dec 06, 2012 11:09 am, edited 2 times in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Different Formats for numbered and unnumbered Chapters

Post by cgnieder »

You must have missed section 3.8. Extended Settings of the titlesec manual. Here is a proof of concept that it is possible to define different formats for numbered and unnumbered titles using different sections formats (I used two formats from the manual for this):

Code: Select all

\documentclass{article}
\usepackage{titlesec}
\titleformat{name=\section}[block]
  {\normalfont\bfseries\filcenter}{\fbox{\itshape\thesection}}{1em}{}
\titleformat{name=\section,numberless}
  {\titlerule\vspace{.8ex}\normalfont\itshape}{}{0pt}{}

\usepackage{lipsum}
\begin{document}
\section{foo}
\lipsum[1]
\section*{bar}
\lipsum[1]

\end{document}
Regards
site moderator & package author
laurocesar
Posts: 7
Joined: Tue Dec 04, 2012 12:34 pm

Re: Different Formats for numbered and unnumbered Chapters

Post by laurocesar »

Thanks a lot for your answer!
Post Reply