LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 06-11-2009, 06:11 AM   #1
edgjerp
Member
 
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Rep: Reputation: 31
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.
 
Old 06-11-2009, 11:46 AM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,758

Rep: Reputation: Disabled
That depends on the style file.

Search for a suitable style file on Internet or edit .....

Which file did you try to edit?
 
Old 06-13-2009, 02:47 AM   #3
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware
Posts: 299

Rep: Reputation: 50
Quote:
Originally Posted by edgjerp View Post
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}}

then, instead of
\chapter{some title}

use
\cchapter{some title}


you could do the same with section, subsection, ...
(\newcommand{\ssection}[1]{\section[#1]{\centering #1}}, etc.)
 
Old 09-09-2009, 07:17 PM   #4
thedoctor818
LQ Newbie
 
Registered: May 2009
Posts: 19

Rep: Reputation: 0
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
 
Old 09-14-2009, 03:48 AM   #5
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware
Posts: 299

Rep: Reputation: 50
Have you tried this?

Code:
\documentclass[12pt,letterpaper,twoside]{book}
\newcommand{\cchapter}[1]{\chapter[#1]{\centering #1}}
\newcommand{\scchapter}[1]{%
  \csname chapter*[#1]\endcsname{\csname centering #1\endcsname}}
\begin{document}
\tableofcontents

\addcontentsline{toc}{chapter}{WEEKDAY EVENING PRAYERS.}
\scchapter{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
\cchapter{ON THE SIGN OF THE PRECIOUS AND LIFE-GIVING CROSS.}
 
Old 10-16-2009, 09:52 AM   #6
Stefan_K
LQ Newbie
 
Registered: May 2009
Location: Hamburg, Germany
Distribution: Ubuntu Linux
Posts: 12

Rep: Reputation: 1
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
 
Old 10-17-2009, 02:02 AM   #7
thedoctor818
LQ Newbie
 
Registered: May 2009
Posts: 19

Rep: Reputation: 0
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
 
Old 10-17-2009, 09:22 AM   #8
Stefan_K
LQ Newbie
 
Registered: May 2009
Location: Hamburg, Germany
Distribution: Ubuntu Linux
Posts: 12

Rep: Reputation: 1
centered section headings

Try
Code:
\titleformat{\section}
  {\normalfont\Large\bfseries\centering}{\thesection}{1em}{}
\titleformat{\subsection}
  {\normalfont\large\bfseries\centering}{\thesubsection}{1em}{}
Stefan


--
TeXblog
 
Old 10-18-2009, 08:46 PM   #9
thedoctor818
LQ Newbie
 
Registered: May 2009
Posts: 19

Rep: Reputation: 0
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
 
Old 10-19-2009, 07:16 AM   #10
Stefan_K
LQ Newbie
 
Registered: May 2009
Location: Hamburg, Germany
Distribution: Ubuntu Linux
Posts: 12

Rep: Reputation: 1
Quote:
Originally Posted by thedoctor818 View Post
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
 
  


Reply

Tags
latex


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LFS 6.3, messed up somewhere prior to chapter 6.12 (gcc), how to restart chapter 6? Funkster Linux From Scratch 2 12-24-2008 06:30 AM
larger letters for the menu headings in Opera? tramni1980 Slackware 7 11-05-2007 10:25 AM
[SOLVED] [OOo writer]Numbering of headings Wim Sturkenboom Linux - Software 2 02-12-2007 11:30 PM
An application that allows viewing e-mail headings before downloading Ariod Linux - Software 1 09-26-2005 01:16 PM
Numbered headings in XHTML vharishankar Programming 6 08-07-2005 01:12 AM


All times are GMT -5. The time now is 01:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration