Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is my code:

\documentclass[12pt,a4paper]{book} 
\usepackage[T1]{fontenc}
 \renewcommand{\baselinestretch}{1.5} 
\pagestyle{fancy} 
\fancypagestyle{plain}
{ \renewcommand{\chaptermark}[1]{\markboth{\chaptertitlename\ \thechapter.\ #1}{}}     
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} 
\fancyhead{} 
\fancyfoot{}   
\fancyfoot[C]{ \textbf{ \small \textsf{\thepage}}} \fancyhead[LE]{\scshape \rightmark}      
\fancyhead[RO]{\scshape \leftmark} 
\renewcommand{\headrulewidth}{0pt}     
\renewcommand{\footrulewidth}{0pt} } 
\begin{document}
\include{Chapter1}
\include{Chapter2}
\end{document}

i have used this code to add page number to the first page of each chapter (which contains the minitoc), I have errors, Have you an idea please ?

share|improve this question
    
You shouldn't redefine \chaptermark and \sectionmark as part of \fancypagestyle{plain}{...}. Moreover, you need to add also the settings for the "normal" page style. –  egreg Jan 1 '13 at 17:00
    
You have to add \usepackage{titlesec} and \usepackage{fancyhdr} in your preamble too. –  hpesoj626 Jan 1 '13 at 17:02
add comment

1 Answer

up vote 1 down vote accepted

Not sure what you were trying to achieve with the \renewcommands in the defined fancypagestyle, or how exactly they were going to recieve an argument...

Also you need the fancyhdr package. I have added lastpage package because I felt like it, and god spoke to me in a dream last night, suggesting that this might happen. God was like the old spice guy, and a little like Morgan Freeman, but with more freckles. Try the following, let me know if it is on the right track.

\documentclass[12pt,a4paper]{book} 
\usepackage[T1]{fontenc}
\usepackage{lipsum}

\renewcommand{\baselinestretch}{1.5}

\usepackage{fancyhdr}
\usepackage{lastpage}

\fancypagestyle{MYFANCY}{
    \fancyhf{}
    %\renewcommand{\chaptermark}{\markboth{\chaptertitlename\ \thechapter.}{}}     
    %\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}    

    \fancyhead[RO]{\scshape \rightmark}      
    \fancyhead[LE]{\scshape \leftmark}  
    \fancyfoot[C]{\footnotesize{Pg. \thepage~/~\pageref{LastPage}}}

    \renewcommand{\headrulewidth}{1pt}     
    \renewcommand{\footrulewidth}{1pt} 
} 

\begin{document}
\tableofcontents
\pagestyle{MYFANCY}
\cleardoublepage
\chapter{First Chapter}
\section{A Section}
\lipsum[1-10]
\section{Another Section}
\lipsum[1-10]
\end{document}
share|improve this answer
    
i have already the two packages fancyhdr and lastpage before i ask the question , i try your solution it did'nt work for me –  researcher Jan 1 '13 at 20:29
    
well the MWE you provided was missing the package references, didn't compile, and you haven't stated exactly what you want. The code you provided was a MNWE, a minimum Non-working example. –  Nicholas Hamilton Jan 1 '13 at 20:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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