4
   \documentclass[11pt,a4paper]{article}
    \usepackage[T1]{fontenc}
    \usepackage{lipsum}
    \usepackage{tocloft}
    \begin{document}

    \tableofcontents
    \thispagestyle{empty}    
    \newpage

    \section{Preface} %want section number to be 0
    \thispagestyle{empty}    
    \pagenumbering{roman}
    \lipsum[1-3]
    \newpage

    \section{Start From Here}
    \lipsum[1-5]

    \section{And So On...}
    \lipsum[1-5]
    \end{document}

Currently I have page numbering and title in the header and for both the header and footer I have a line (I'm not sure what it's called). For the preface, I want all of that gone, which is why I used \thispagestyle{empty}, but I do want a roman page numbering in the bottom center.

How can I get the page numbering on the preface to show a roman numeral? (As of now it only shows in ToC).

  • How do you get page number and title in the header? A viable solution needs to know this information. – egreg Apr 8 '13 at 8:18
  • Now that the problem has been solved, perhaps you should add again the relevant information about your headers/footers; by the way, did my answer solved the problem? – Gonzalo Medina Apr 8 '13 at 12:56
8

You can define a new page style using \fancypagestyle{<name>}{<commands>} to get rid of other headers/footers and leave the page number, and then use \thispagestyle{<name>} at the desired locations:

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{fancyhdr}

\fancypagestyle{myplain}
{
  \fancyhf{}
  \renewcommand\headrulewidth{0pt}
  \renewcommand\footrulewidth{0pt}
  \fancyfoot[C]{\thepage}
}
\fancyhf{}
\fancyhf{}
\fancyhead[CO]{\nouppercase\leftmark}
\fancyhead[CE]{\hdrtitle}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
\renewcommand\sectionmark[1]{\markboth{#1}{}}%don't move this

\setcounter{section}{-1}

\title{The Title}
\author{The Author}
\makeatletter
\let\hdrtitle\@title
\makeatother

\begin{document}

\tableofcontents
\thispagestyle{empty}
\newpage

\section{Preface}
\thispagestyle{myplain}
\pagenumbering{roman}
\lipsum[1-3]
\newpage

\section{Start From Here}
\pagenumbering{arabic}
\lipsum[1-5]

\section{And So On...}
\lipsum[1-5]
\end{document}

The solution above will work if the preface is one page long; if the preface spans more than one page, you could define two styles: for example, myplain (with only the page number (I assumed it should be centered in the footer, but you can easily change this)), and myfancy (with your header/footer and rules); then you can use \pagestyle{<style>} at appropriate locations to switch styles:

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{fancyhdr}

\fancypagestyle{myplain}
{
  \fancyhf{}
  \renewcommand\headrulewidth{0pt}
  \renewcommand\footrulewidth{0pt}
  \fancyfoot[C]{\thepage}
}
\fancypagestyle{myfancy}{
  \fancyhf{}
  \fancyhead[CO]{\nouppercase\leftmark}
  \fancyhead[CE]{\hdrtitle}
  \fancyhead[LE,RO]{\thepage}
  \renewcommand\headrulewidth{0.4pt}
  \pagestyle{fancy}
  \renewcommand\sectionmark[1]{\markboth{##1}{}}%don't move this
}
\setcounter{section}{-1}

\title{The Title}
\author{The Author}
\makeatletter
\let\hdrtitle\@title
\makeatother

\begin{document}

\tableofcontents
\thispagestyle{empty}
\newpage

\pagestyle{myplain}
\pagenumbering{roman}
\section{Preface}
\lipsum[1-10]
\newpage

\pagestyle{myfancy}
\pagenumbering{arabic}
\section{Start From Here}
\lipsum[1-5]

\section{And So On...}
\lipsum[1-5]
\end{document}

Perhaps you could be interested in using the book document class and its \frontmatter, \mainmatter, \backmatter commands? (using \chapter as the high level sectional unit, of course).

  • but that doesn't clear header and footer in the preface? – AlanH Apr 8 '13 at 2:54
  • @AlanH please see my updated answer. – Gonzalo Medina Apr 8 '13 at 19:51

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.