2

I would like to insert in each page the chapter name and number (bottom right)
The problem is that this configuration does not apply to pages that contain the name of the chapter! My code :

 \usepackage[fit]{truncate}
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhead[RO,LE]{\truncate{.95\headwidth}{\leftmark}}
\fancyfoot[R]{\thepage}
\cfoot{}
  • In the footer ("bottom right")? Your code snippet uses \leftmark in the header... Which is it? Also what document class are you using? Do you have any restrictions in terms of packages? – Werner May 23 '13 at 18:54
  • I use : \documentclass[12pt,a4paper]{report} the problem is that: in all pages, the page number is centered except the pages that contain the title of the chapters and parts – physics May 23 '13 at 18:55
2

The titleps package provides easy access to sectional titles and is a viable alternative to using fancyhdr.

You can define a new page style (say main) and issue that at every start-of-chapter page, or redefine plain to include the details you want - plain is the default page style associated with the first page of a chapter.

Here's a complete example:

enter image description here

\documentclass{report}
\usepackage{lipsum,titleps}% http://ctan.org/pkg/{lipsum,titleps}
\makeatletter
\newpagestyle{main}{%
  % Header rule: \setheadrule
  % Footer rule: \setfootrule
  % Header: \sethead{<left>}{<centre>}{<right>}
  \setfoot{}{\thepage}{\@chapapp~\thechapter\ \chaptertitle}% \setfoot{<left>}{<centre>}{<right>}
}
\makeatother
\pagestyle{main}
\begin{document}
\chapter{First chapter}\thispagestyle{main}\lipsum[1-20]
\chapter{Second chapter}\lipsum[1-20]
\chapter{Last chapter}\lipsum[1-20]
\end{document}

Redefining plain would resemble:

\makeatletter
\renewpagestyle{plain}{%
  % Header rule: \setheadrule
  % Footer rule: \setfootrule
  % Header: \sethead{<left>}{<centre>}{<right>}
  \setfoot{}{\thepage}{\@chapapp~\thechapter\ \chaptertitle}% \setfoot{<left>}{<centre>}{<right>}
}
\makeatother
  • thank you. it works well, except at the end, kile display a file "ttlps" and it points to the following two lines : \newcommand\headrule{\setheadrule{.4\p@}} \newcommand\footrule{\setfootrule{.4\p@}} – physics May 23 '13 at 19:27
  • @physics: Can you provide more detail? Are you using titleps or ttlps? Also, you should use only titleps. Not that and fancyhdr. – Werner May 23 '13 at 19:55
  • I did not insert the line: \usepackage{lipsum,titleps} Is it interesting? – physics May 23 '13 at 19:58
  • @physics: You absolutely need \usepackage{titleps}, while lipsum was just for the above example and provides dummy text. – Werner May 23 '13 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.