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

Book title left, chapter title right in Book class with fancyhdr

178 views
Skip to first unread message

marsup

unread,
Jul 16, 2011, 4:41:13 AM7/16/11
to
I am using book class & fancyhdr package.

I wish to put book title on the left header, and chapter title on the
right header.
Cute ideas? thanks.

-Marsup

Peter Flynn

unread,
Jul 17, 2011, 3:57:16 PM7/17/11
to
On 16/07/11 09:41, marsup wrote:
> I am using book class& fancyhdr package.

>
> I wish to put book title on the left header, and chapter title on the
> right header.
> Cute ideas? thanks.

\pagestyle{fancy}
\fancyhead{RO,LE}{}
\fancyhead{LE,RO}{}
\fancyhead{CE}{\small\@title}
\fancyhead{CO}{\small\rightmark}

(untested, I'm away from base right now)

///Peter

marsup

unread,
Jul 19, 2011, 11:01:37 PM7/19/11
to
On Jul 18, 5:57 am, Peter Flynn <pe...@silmaril.ie> wrote:
> On 16/07/11 09:41,marsupwrote:

What is the meanting of @title here? I am not good at these,
however, if I wish to put the book title, how can I change this?
{\small\@title}

Any one while Peter is away? Thanks.

-Marsup

Dan

unread,
Jul 20, 2011, 4:30:05 PM7/20/11
to
On Jul 19, 10:01 pm, marsup <arasu....@gmail.com> wrote:
> On Jul 18, 5:57 am, Peter Flynn <pe...@silmaril.ie> wrote:
>
> > On 16/07/11 09:41,marsupwrote:
>
> > > I am using book class&  fancyhdr package.
>
> > > I wish to put book title on the left header, and chapter title on the
> > > right header.
>
> > \pagestyle{fancy}
> > \fancyhead{RO,LE}{}
> > \fancyhead{LE,RO}{}
> > \fancyhead{CE}{\small\@title}
> > \fancyhead{CO}{\small\rightmark}
>
> > (untested, I'm away from base right now)
>
> > ///Peter
>
> What is the meanting of @title here? I am not good at these,
> however, if I wish to put the book title, how can I change this?
> {\small\@title}

After the command
\title{My Actual Title Here}
the title text is stored in the macro \@title. However, after the
command
\maketitle
the contents of \@title are discarded. Thus, Peter's code cannot
work unless
1. You use \title
2. You don't use \maketitle

Also, since the macro uses an @ sign, you must surround
it with \makeatletter and \makeatother.
\makeatletter
\fancyhead{CE}{\small \@title}
\makeatother

A better solution would be to type in the actual title:


\pagestyle{fancy}
\fancyhead{RO,LE}{}
\fancyhead{LE,RO}{}

\fancyhead{CE}{\small My Actual Title Here}
\fancyhead{CO}{\small\rightmark}

Caveat: I do not use fancyhdr, so I can't say for sure if Peter's
incantations are otherwise correct. But clearly the fancyhdr
documentation would be able to say.


Dan

Enrico Gregorio

unread,
Jul 20, 2011, 5:10:46 PM7/20/11
to
Dan <luec...@uark.edu> wrote:

No, they are not correct! The positioning arguments
should go inside square brackets.

\newcommand{\booktitle}{How to write a book}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE]{\small\booktitle}
\fancyhead[CO]{\small\rightmark}
\fancyfoot{\small\thepage}

The command \fancyhf{} resets all header and footer fields,
so we need only to fill in the ones we want.

If \title is needed, it's easy:

\title{\booktitle}
\maketitle

Ciao
Enrico

Peter Flynn

unread,
Jul 21, 2011, 6:11:11 PM7/21/11
to
On 20/07/11 04:01, marsup wrote:
> On Jul 18, 5:57�am, Peter Flynn<pe...@silmaril.ie> wrote:
>> On 16/07/11 09:41,marsupwrote:
>>
>>> I am using book class& �fancyhdr package.
>>
>>> I wish to put book title on the left header, and chapter title on the
>>> right header.
>>> Cute ideas? thanks.
>>
>> \pagestyle{fancy}
>> \fancyhead{RO,LE}{}
>> \fancyhead{LE,RO}{}
>> \fancyhead{CE}{\small\@title}
>> \fancyhead{CO}{\small\rightmark}
>>
>> (untested, I'm away from base right now)
>>
>> ///Peter
>
> What is the meanting of @title here?

\@title is where LaTeX stores the title you give in \title.

> I am not good at these,
> however, if I wish to put the book title, how can I change this?
> {\small\@title}

Sorry, I don't understand the question.

///Peter

Peter Flynn

unread,
Jul 21, 2011, 6:12:48 PM7/21/11
to
On 20/07/11 21:30, Dan wrote:
[...]

> After the command
> \title{My Actual Title Here}
> the title text is stored in the macro \@title. However, after the
> command
> \maketitle
> the contents of \@title are discarded. Thus, Peter's code cannot
> work unless
> 1. You use \title
> 2. You don't use \maketitle

Quite right, I had forgotten this, sorry. I almost always rewrite
\maketitle.

> Also, since the macro uses an @ sign, you must surround
> it with \makeatletter and \makeatother.
> \makeatletter
> \fancyhead{CE}{\small \@title}
> \makeatother

That too.

///Peter

0 new messages