Text Formattingcentering a chapter title

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
thedoctor818
Posts: 92
Joined: Fri Apr 24, 2009 8:02 pm

centering a chapter title

Post by thedoctor818 »

Hello. I am back. I have one more question for the day, if I may. I am trying to get my chapter titles centered from left to right, and have tried the titlesec.sty package; but I must not be doing something correctly: Below is what I have thus far. Any help would be appreciated. Thanks for the help earlier today.

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{titlesec}
\begin{document}
\tableofcontents

\addcontentsline{toc}{chapter}{WEEKDAY EVENING PRAYERS.}
\chapter*{WEEKDAY EVENING PRAYERS.}
<body text>

<and 3 additional chapters, sim to above in format>

\appendix
\chapter{<TEXT>}

<and 3 additional appendices, sim to above in format>

\end{document}

I could not seem to get it to work right. I tried the follwing, but to no avail:

\titleformat{\chapter}{%
\centering\normalfont\LARGE\bfseries}{\WEEKDAY EVENING PRAYERS}{1em}{}

-Michael D
-Michael D

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

centering a chapter title

Post by gmedina »

Hi,

here's a little example:

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{titlesec}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter} 
  {0pt}{50pt}{40pt}

\begin{document}
\tableofcontents

\addcontentsline{toc}{chapter}{WEEKDAY EVENING PRAYERS.}
\chapter*{WEEKDAY EVENING PRAYERS.}

\appendix
\chapter{Test appendix}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
thedoctor818
Posts: 92
Joined: Fri Apr 24, 2009 8:02 pm

Re: centering a chapter title

Post by thedoctor818 »

Thanks, that helped a lot. I think I have what I need. Someone on another forum posted the following:



you might put this in the preamble (before \begin{document})

\newcommand{\cchapter}[1]{\chapter[#1]{\centering #1}}

then, instead of
\chapter{some title}

use
\cchapter{some title}


I tried this first (to no avail obviosuly), but I suppsose this could not work b/c I am using chapter headings that are not numbered. Will what you have provided me work with my appendices [since they ARE labelled]?

Thanks for all your help.

-Michael D
-Michael D
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

centering a chapter title

Post by gmedina »

thedoctor818 wrote:...Will what you have provided me work with my appendices [since they ARE labelled]?

Thanks for all your help.
You are welcome. Please notice that you use \chapter* (the starred version, that suppresses numbering and inclusion in the ToC) for the main chapters and \chapter (the unstarred version, that includes numbering and inclusion in the ToC) for the appendices.

So, my suggestion (if I understand your question correctly) would be to use \chapter* for the appendices too. If you desire other result, please describe it in detail and we'll try to give advise.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
thedoctor818
Posts: 92
Joined: Fri Apr 24, 2009 8:02 pm

Re: centering a chapter title

Post by thedoctor818 »

No, I would *actually* like to have the appendices numbered or labelled, as I refer to them in the body of the Prayerbook, & thus would like to be able to simply refer to them by number or letter [I really do not mind them being referred to by letters.

I just looked at a prayerbook I really liked, and swa what I *really* wanted. This prayerbook had the chapters un-numbered in the body of the text; but numbered in the toc - BUT in the toc, the numbering was not ``Chapter 01. Weekday Evening Prayers'' etc, but rather ``1. Weekday Evening Prayers'' Is *that* possible - b/c that is *really* how I would like this doc to be formatted if possible. Is this a `hard' fix? Thanks again.

-Michael D
-Michael D
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: centering a chapter title

Post by gmedina »

One more question: the appendices should appear as they are now or do you want to remove the word "Appendix" or do some other modification?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
thedoctor818
Posts: 92
Joined: Fri Apr 24, 2009 8:02 pm

Re: centering a chapter title

Post by thedoctor818 »

I would just like for the appendices to be labelled (and centered like the chapter headings are) as:

Appendix A On the Sign of the Cross ...
<body text> ...

Appendix B Festal Troparia ....

<body text> ...

etc


\end{document}


Like that - but as for the toc, just to have them reffered to as:

A On the Sign of the Cross ...

B Festal Troparia ....

etc

Thanks.
-Michael D
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

centering a chapter title

Post by gmedina »

Maybe something like the following is close to what you are looking for?

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{titlesec}
\usepackage{titletoc}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}{}{20pt}{\Huge}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}

\begin{document}
\tableofcontents

\chapter{WEEKDAY EVENING PRAYERS.}
Some text for this chapter

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}
\appendix
\chapter{On the Sign of the Cross ...}
Some text for this appendix

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
thedoctor818
Posts: 92
Joined: Fri Apr 24, 2009 8:02 pm

Re: centering a chapter title

Post by thedoctor818 »

What I send below worked out.



\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}
{0pt}{50pt}{40pt}

\begin{document}
\tableofcontents

\addcontentsline{toc}{chapter}{WEEKDAY EVENING PRAYERS.}
\chapter*{WEEKDAY EVENING PRAYERS.}
<text>

\appendix
\chapter{ON THE SIGN OF THE PRECIOUS AND LIFE-GIVING CROSS.}
<text>



That apparently did it. Thanks a bunch.

I just have one more [well it ended up being 2; sorry](hopefully easier) question(s). In the 2-sided book format, how do I `get-rid' of the blank sheets between chapters, and how do I get the pages numbers on the bottom and get rid of the *tags* i.e. the header, I guess you would call it?

-Michael D
-Michael D
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

centering a chapter title

Post by gmedina »

To suppress the additional pages you can use the openany class option. To customise the headers and footers, you can use the titlesec package to define a customised page style; take a look at the following example that includes your previous code:

Code: Select all

\documentclass[12pt,letterpaper,twoside,openany]{book}
\usepackage[pagestyles]{titlesec}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}

\newpagestyle{mystyle}{\sethead{}{}{}\setfoot{}{\thepage}{}}
\pagestyle{mystyle}

\begin{document}
\tableofcontents

\addcontentsline{toc}{chapter}{WEEKDAY EVENING PRAYERS.}
\chapter*{WEEKDAY EVENING PRAYERS.}
text

\appendix
\chapter{ON THE SIGN OF THE PRECIOUS AND LIFE-GIVING CROSS.}
text

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply