LinuxAnswers - the LQ Linux tutorial section.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org center chapter headings in LaTeX
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 06-11-2009, 07:11 AM #1 edgjerp Member   Registered: Dec 2004 Location: Trondheim, Norway Distribution: kubuntu 10.04 Posts: 308 Rep: center chapter headings in LaTeX how can I make chapter headings in LaTeX become centered, without changing anything else? I have tried a number of things, but they have either not worked, or radically changed the look of the heading, or both.
 06-11-2009, 12:46 PM #2 amani Senior Member   Registered: Jul 2006 Location: Kolkata, India Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware, Posts: 2,758 Rep: That depends on the style file. Search for a suitable style file on Internet or edit ..... Which file did you try to edit?
06-13-2009, 03:47 AM   #3
vonbiber
Member

Registered: Apr 2009
Distribution: slackware
Posts: 299

Rep:
Quote:
 Originally Posted by edgjerp how can I make chapter headings in LaTeX become centered, without changing anything else? I have tried a number of things, but they have either not worked, or radically changed the look of the heading, or both.
you might put this in the preamble (before \begin{document})

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

\chapter{some title}

use
\cchapter{some title}

you could do the same with section, subsection, ...
(\newcommand{\ssection}[1]{\section[#1]{\centering #1}}, etc.)

 09-09-2009, 08:17 PM #4 thedoctor818 LQ Newbie   Registered: May 2009 Posts: 19 Rep: How do I do this (i.e. center a chapter) if I have the following: \documentclass[12pt,letterpaper,twoside]{book} \begin{document} \tableofcontents \addcontentsline{toc}{chapter}{WEEKDAY EVENING PRAYERS.} \chapter*{WEEKDAY EVENING PRAYERS.} In the Name of the Father, and of the Son, and of the Holy Spirit. Amen. more text quite a bit of text, including several more chapters as above \appendix \chapter{ON THE SIGN OF THE PRECIOUS AND LIFE-GIVING CROSS.} three more appendices \end{document} Thanks, -Michael D
 10-16-2009, 10:52 AM #6 Stefan_K LQ Newbie   Registered: May 2009 Location: Hamburg, Germany Distribution: Ubuntu Linux Posts: 12 Rep: centered chapter headings I recommend to use the titlesec package to achieve that, here's a complete example: Code: \documentclass[a4paper,10pt]{book} \usepackage{titlesec} \titleformat{\chapter}[display] {\normalfont\huge\bfseries\centering}{\chaptertitlename\ \thechapter}{20pt}{\Huge} \begin{document} \chapter{One} text \end{document} Stefan -- TeXblog
 10-17-2009, 03:02 AM #7 thedoctor818 LQ Newbie   Registered: May 2009 Posts: 19 Rep: How would I do this for section headers & subsection headers? I tried the following, but got an error code. \titleformat{\chapter}[display] {\normalfont\huge\bfseries\centering}{\chaptertitlename\ \thechapter}{20pt}{\Huge} \titleformat{\section}[display] {\normalfont\Large\bfseries\centering}{\sectiontitlename\ \thesection}{16pt}{\LARGE} Help, please. -The Doctor
 10-17-2009, 10:22 AM #8 Stefan_K LQ Newbie   Registered: May 2009 Location: Hamburg, Germany Distribution: Ubuntu Linux Posts: 12 Rep: centered section headings Try Code: \titleformat{\section} {\normalfont\Large\bfseries\centering}{\thesection}{1em}{} \titleformat{\subsection} {\normalfont\large\bfseries\centering}{\thesubsection}{1em}{} Stefan -- TeXblog
 10-18-2009, 09:46 PM #9 thedoctor818 LQ Newbie   Registered: May 2009 Posts: 19 Rep: Thanks for the help Stephan. Only one more question, and that is how do I get the headings [chapter, section, etc] numbered in the toc, & yet unnumbered in the body of the text? Thanks a lot for your patience & help, -The Doctor
10-19-2009, 08:16 AM   #10
Stefan_K
LQ Newbie

Registered: May 2009
Location: Hamburg, Germany
Distribution: Ubuntu Linux
Posts: 12

Rep:
Quote:
 Originally Posted by thedoctor818 how do I get the headings [chapter, section, etc] numbered in the toc, & yet unnumbered in the body of the text?
That seems to be inconsistent for me. Further, numbering supports browsing/finding sections, to follow the order of sections. While it's easy to read a toc and to have an overview of the order there, it's harder to find the way inside a document, that's why I think numbering is even more important in the document than in the toc. Or, to go further, do you show page numbers for chapters and sections in the toc, but don't use any page number in the document itself...? Numbering is not just counting in order to show how much has been done. I'm just thinking.

Such numbering is not a direct supported style (that tells something about if it's common), but of course you can achieve that. Use \chapter* and \section* in the document and use there also \addcontentsline (or \addtocontents) to produce a numbered toc entry. Use a counter, define your own counter or use standard chapter/section counters.
Another way would be to redefine internal macros like \@startsection, \@makechapterhead etc. but first be sure that you really want to use this style.

Stefan

 Tags latex