GeneralFormatting for Chapter Number

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
amradly
Posts: 7
Joined: Fri Sep 14, 2012 9:35 pm

Formatting for Chapter Number

Post by amradly »

Hey,

I have a problem in a document. I write a master thesis with the book class and I want to make the chapter format as

Chapter (1) instead Chapter 1
Chapter (2) instead Chapter 2
Chapter (3) instead Chapter 3
...


Thanx
Last edited by localghost on Sat Sep 15, 2012 11:01 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Formatting for Chapter Number

Post by Stefan Kottwitz »

Hi amradly,

welcome to the board!

It can easily be redefined. Just put into your preamble:

Code: Select all

\renewcommand*{\thechapter}{(\arabic{chapter})}
Stefan
LaTeX.org admin
amradly
Posts: 7
Joined: Fri Sep 14, 2012 9:35 pm

Re: Formatting for Chapter Number

Post by amradly »

Hey,

thanks Stefan... it is working well!

But I have another problem, the chapter becomes Chapter (1) but the section becomes
(1).1
(1).2
(1).3
...

Thanks in advance
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Formatting for Chapter Number

Post by Stefan Kottwitz »

That's consistent, because a section 1 in chapter (1) may be called (1).1. But no problem, it can be changed in a similar way:

Code: Select all

\renewcommand*{\thesection}{\arabic{chapter}.\arabic{section}}
Stefan
LaTeX.org admin
amradly
Posts: 7
Joined: Fri Sep 14, 2012 9:35 pm

Re: Formatting for Chapter Number

Post by amradly »

Thanks Stevan for your effort,

I want also to remove the vertical space between chapter title and the "chapter" keyword so I want the chapter will be

Chapter (1) | instead Chapter (1)
Introduction |
Introduction
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Formatting for Chapter Number

Post by Stefan Kottwitz »

Regarding spacing, font, and formatting of headings in general, have a look at the titlesec package. The manual is some stuff to read, because of the many features, but an easy start is given by the examples for standard classes. They are a good start for customization.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Formatting for Chapter Number

Post by localghost »

If it is only about getting rid of that vertical space without any other modifications to the other heading levels, you can patch a helper macro for the \chapter command by the etoolbox package.

Code: Select all

\documentclass[11pt]{book}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@makechapterhead}{\vspace 20\p@}{}{}{}
\makeatother

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

Best regards and welcome to the board
Thorsten
Attachments
The old chapter formatting.
The old chapter formatting.
chapter-before.png (2.76 KiB) Viewed 4332 times
The new chapter formatting.
The new chapter formatting.
chapter-after.png (2.69 KiB) Viewed 4332 times
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
amradly
Posts: 7
Joined: Fri Sep 14, 2012 9:35 pm

Re: Formatting for Chapter Number

Post by amradly »

@Stefan_K ,
thanks, I download the manual of titlesec package and I found the "titlespacing"
\titlespacing*{<command>}{<left>}{<beforesep>}{<aftersep>}[<right>]

but I don't need it , I want to remove vertical space between chapter title and the "chapter" keyword.

@localghost,
thanks, the figure you attached is really what I want , but the code is n't working well I think the titlesec package will be good but I don't know how....

Regards,
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Formatting for Chapter Number

Post by localghost »

amradly wrote:[…] the figure you attached is really what I want , but the code is n't working well I think the titlesec package will be good but I don't know how. […]
The words "code isn't working" are not a good description of the problem. Make sure that you have a TeX system that is up to date.

Add the \listfiles command as very first line to my code example, run the compiler and search the log file (*.log) for the list of used files (quite at the end). This is what I get.

Code: Select all

 *File List*
    book.cls    2007/10/19 v1.4h Standard LaTeX document class
    bk11.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
 fontenc.sty
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
etoolbox.sty    2011/01/03 v2.1 e-TeX tools for LaTeX
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
 ***********
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
Post Reply