Generalchapter heading position

LaTeX specific issues not fitting into one of the other forums of this category.
chao
Posts: 20
Joined: Tue Jun 17, 2008 5:52 pm

chapter heading position

Post by chao »

Hi,
I've got a question about positioning Chapter Heading.

I found a short script looks like this:

\documentclass[twoside,letterpaper,12pt]{report}

\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \centering
\normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@schapter#1{\if@twocolumn
\@topnewpage[\@makeschapterhead{#1}]%
\else
\@makeschapterhead{#1}%
\@afterheading
\fi}
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \centering
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother

\begin{document}
\chapter*{Introduction}
\end{document}

However it works only for unnummbered chapter.
e.g. Introduction
I would like to have
e.g. chapter1
Introduction
shown in the middle of a page.

Thanks a lot

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

chapter heading position

Post by localghost »

Omit this code and use the titlesec package. It lets you customize the headings of your document.


Best regards and welcome to the board
Thorsten¹
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

chapter heading position

Post by Stefan Kottwitz »

Hi chao,

welcome to this forum!
Those redefinitions work for \chapter with the book class without problem.
For using it with the report class I would delete two lines, the one containing \if@mainmatter and one of the following lines containing \fi.

Stefan
LaTeX.org admin
chao
Posts: 20
Joined: Tue Jun 17, 2008 5:52 pm

Re: chapter heading position

Post by chao »

your help is concise and sufficient.
:shock:
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

chapter heading position

Post by Stefan Kottwitz »

Hi chao,

with the titlesec package mentioned by Thorsten it could be very simple. Here's the complete changed code with centered chapter titles:

Code: Select all

\documentclass[twoside,letterpaper,12pt]{report}
\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\centering\normalfont\huge\bfseries}
  {\chaptertitlename\ \thechapter}{20pt}{\Huge}

\begin{document}
\chapter*{Introduction}
\chapter{First}
\end{document}
Stefan
LaTeX.org admin
chao
Posts: 20
Joined: Tue Jun 17, 2008 5:52 pm

Re: chapter heading position

Post by chao »

Thanks stephan!
:shock: :o
where to find these infomations?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

chapter heading position

Post by gmedina »

Read the packages documentation. Usually, when the use of a package is suggested, a link (to the location of that package on CTAN) is provided (see the response by localghost above). There you can find information about the package and its documentation.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

chapter heading position

Post by Stefan Kottwitz »

Hi chao,

you can find this information by reading the titlesec documentation. Thorsten already gave a link above, where you can find the link to that documentation.
I gave the small example above to demonstrate that the usage of titlesec may be simple, though in the documentation there may be much to read.

Stefan
LaTeX.org admin
chao
Posts: 20
Joined: Tue Jun 17, 2008 5:52 pm

Re: chapter heading position

Post by chao »

I've asked how to place a chapter title in the mid of a page.
a new problem following the original one

% place chapter headings in the middle of the page
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\centering\large\bfseries}
{\chaptertitlename\ \thechapter}{20pt}{\large\uppercase}

Now, how can I change the "chapter 1" into uppercase? I tried to find the infomation from titlesec.pdf provided by others but could not find proper place.

Also, if I want to change the ListOfFigures and others(ListOfTables...) into uppercase how to do that?

ListOfFigures.tex
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

chapter heading position

Post by Stefan Kottwitz »

Hi Chao,

both can be done by using \MakeUpercase (not \uppercase):

Code: Select all

\titleformat{\chapter}[display]
{\centering\large\bfseries}
{\MakeUppercase{\chaptertitlename}\ \thechapter}{20pt}{\large\MakeUppercase}
Stefan
LaTeX.org admin
Post Reply