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.

I am trying to use roman numerals for the table of contents (and abstract, notes of thanks etc.) and then start the main body of the text from page 1 in arabic numerals. I am using the article document class and do not want a page number on the title page. At the same time in the footer I want to show Page x of y.

i.e. I want

Title page: no number
Table of contents first page: Page i of ii
Table of contents second page: page ii of ii [ii was just chosen for this example]
First page of document: page 1 of x
Second page of document: page 2 of x

The code works fine for the table of contents, i do get page i of ii, page ii of ii etc. However, for the rest of the document I then get page 1 of ii, page 2 of ii Actually I can see what causes the mistake (the use of a \label{lastromanpage}), but I do not know how to solve this.

\documentclass{article}

\newcommand{\Title}{Title}
\newcommand{\DueDate}{\today}
\newcommand{\Class}{}
\newcommand{\ClassTime}{}
\newcommand{\ClassInstructor}{}
\newcommand{\AuthorName}{Authorname}

\title{\vspace{2in}\textmd{\textbf{ \Title}}\\\normalsize\vspace{0.1in}\small{Due\ on\ \DueDate}\\\vspace{0.1in}\large{\textit{\ClassInstructor\ \ClassTime}}\vspace{3in}}
\date{}
\author{\textbf{\AuthorName}}

\pagestyle{fancy}
\lhead{\AuthorName}
\chead{\Class}
\rhead{\Title}

\lfoot{\lastxmark}
\cfoot{}
\rfoot{Page\ \thepage\ of\ \pageref{lastromanpage}}

\begin{document}\begin{spacing}{1.1}

\maketitle\thispagestyle{empty}\newpage
\pagenumbering{roman}\tableofcontents \label{lastromanpage}
\newpage\pagenumbering{arabic}\clearpage
share|improve this question
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Heiko Oberdiek Apr 12 '13 at 8:09
    
Issue \rfoot{Page \thepage\ of \pageref{LastPage}} after \pagenumbering{arabic} and load the lastpage package (or \zpageref{LastPage} loading zref-lastpage). –  egreg Apr 12 '13 at 8:16

1 Answer 1

You can also change the footer inside the document with \rfoot. The label for the last page number is more complicate, because \label after the last page would not write anything in the .aux file. For example, package lastpage provides a label LastPage that can be used with \pageref.

Full example:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lastpage}

\newcommand*{\Title}{Title}
\newcommand*{\AuthorName}{John Doe}
\title{\Title}
\date{}
\author{\AuthorName}

\pagestyle{fancy}
\lhead{\AuthorName}
\chead{Class}
\rhead{\Title}

\lfoot{}
\cfoot{}
\rfoot{Page\ \thepage\ of\ \pageref{lastromanpage}}

\begin{document}

\maketitle\thispagestyle{empty}
\newpage

\pagenumbering{roman}
\tableofcontents
\label{lastromanpage}
\clearpage

\pagenumbering{arabic}
\rfoot{Page\ \thepage\ of \pageref{LastPage}}
\section{First section}
\newpage
\section{Last section}

\end{document}
share|improve this answer
    
Thank you for your help, this seems to work just fine ^^ –  Young-il Kim Apr 12 '13 at 10:45

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.