Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

header problem - \chaptername without "Chapter X."?

3,247 views
Skip to first unread message

PmI

unread,
Nov 9, 2009, 9:02:12 AM11/9/09
to
How do I get a chaptername to print as just the title I gave it in my source,
rather than with "Chapter X." in front of it?

My source has, for instance, \Chapter{Syntax}, and the header will say
"Chapter 1. Synax"... which is not what I exptected.

With some help from the internet, fancyhdr, and some testing I got it down
to:

\renewcommand{\chaptername}{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesubsection\ #1}}
\fancyhead{} % clear all header fields
\fancyhead[RO,LE]{\thepage}
\fancyhead[LO,RE]{\nouppercase{\leftmark} � section \nouppercase{\rightmark}}

Which already strips the word "Chapter"from the chaptername, but the number
is still there, so that the header now looks like "1. syntax - section ..."

How do I get rid of this number, too?

And where do I find this information listed in a convenient way, because I
search the net for hours trying to find this explained using a plethora of
search terms, and nothing actually explains why "chaptername" isn't actually
the chapter name, but some concatenated strong of "Chapter", its order
number, and then the actual chapter title. Which I assume is magically added
into it when the chaptermark is requested, because if there is a command that
gives the ACTUAL chapter title, the internet sure as heck isn't telling me
what that command is =(

- Mike Kamermans

Lars Madsen

unread,
Nov 9, 2009, 9:10:39 AM11/9/09
to
PmI wrote:
> How do I get a chaptername to print as just the title I gave it in my source,
> rather than with "Chapter X." in front of it?
>
> My source has, for instance, \Chapter{Syntax}, and the header will say
> "Chapter 1. Synax"... which is not what I exptected.
>
> With some help from the internet, fancyhdr, and some testing I got it down
> to:
>
> \renewcommand{\chaptername}{}
> \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
> \renewcommand{\sectionmark}[1]{\markright{\thesubsection\ #1}}
> \fancyhead{} % clear all header fields
> \fancyhead[RO,LE]{\thepage}
> \fancyhead[LO,RE]{\nouppercase{\leftmark} � section \nouppercase{\rightmark}}

>
> Which already strips the word "Chapter"from the chaptername, but the number
> is still there, so that the header now looks like "1. syntax - section ..."
>
> How do I get rid of this number, too?
>
> And where do I find this information listed in a convenient way, because I
> search the net for hours trying to find this explained using a plethora of
> search terms, and nothing actually explains why "chaptername" isn't actually
> the chapter name, but some concatenated strong of "Chapter", its order
> number, and then the actual chapter title. Which I assume is magically added
> into it when the chaptermark is requested, because if there is a command that
> gives the ACTUAL chapter title, the internet sure as heck isn't telling me
> what that command is =(
>
> - Mike Kamermans

would you please provide a minimal example please (I'd like to see a
compailable example that gives the result you mention).

It sounds a bit weird that the number is still there.


--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

PmI

unread,
Nov 9, 2009, 10:25:48 AM11/9/09
to
Ah yes, certainly.

You may find the .tex file and consequent .pdf on
http://pomax.nihongoresources.com/downloads/temp (texated.tex and
texated.pdf)

The pdf was generated using xelatex, using the following series of commands

xelatex texated.tex % initial run
xelatex texated.tex % to add ToC
makeindex -s texated.ist -t texated.glg -o texated.gls texated.glo
xelatex texated.tex % to add glossary
makeindex texated.idx
xelatex texated.tex % to add index
xelatex texated.tex % final realign run

- Mike "Pomax" Kamermans
nihongoresources.com

Lars Madsen

unread,
Nov 9, 2009, 10:37:31 AM11/9/09
to


easy fix, place your change to \chaptermark AFTER \pagestyle{fancy}

PmI

unread,
Nov 9, 2009, 3:03:48 PM11/9/09
to
> easy fix, place your change to \chaptermark AFTER \pagestyle{fancy}

Excellent, thank you. For future reference, where might one find this kind of
information so that the fix is indeed "easy" rather than "easy, but only if
you happened to know about it"? =)

- Mike

Lars Madsen

unread,
Nov 9, 2009, 4:59:24 PM11/9/09
to

cannot say much more than look in the code. And in particular read the
manuals for the packages being used.

/daleif

Peter Flynn

unread,
Nov 9, 2009, 5:02:03 PM11/9/09
to
PmI wrote:
> How do I get a chaptername to print as just the title I gave it in my
> source, rather than with "Chapter X." in front of it?
>
> My source has, for instance, \Chapter{Syntax}, and the header will
> say "Chapter 1. Synax"... which is not what I exptected.

Why not? That is exactly what I would expect a chapter head to say.

\Chapter (with the capital C) is not defined in any of the basic
classes, so you are presumably using some other document class you
haven't told us about.

The book and report classes provide \chapter but also \chapter*, which
does what you ask. If \Chapter*{Syntax} doesn't do this, tell us what
document class you are using.

If there is no package to do what you want (which should always be the
first thing to look for), then the procedure is to find the command
causing the effect by looking in the .cls or .sty file, copy it to your
own .sty file (or into the Preamble of your document), and change it there.

A quick look into book.cls reveals that \chapter end up by calling
either \@chapter or \@schapter, depending on the * being present or not,
but both of them end up by calling \@makechapterhead, which says:

> \def\@makechapterhead#1{%
> \vspace*{50\p@}%
> {\parindent \z@ \raggedright \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@
> }}

If you copy this into your own .sty file, you can edit it to do whatever
you want with a chapter heading; in your case, removing everything from
\ifnum \c@secnumdepth down to the second \fi.

But \chapter* does exactly this. See if \Chapter* also does it.

///Peter

liao...@gmail.com

unread,
Jan 2, 2018, 2:00:55 PM1/2/18
to
在 2009年11月9日星期一 UTC+8下午11:37:31,Lars Madsen写道:
Excellent, thank you! This has solved successfully my problem.
0 new messages