1

this could seem a little awkward, but apparently I need to do it this way.

I have a document (class book) that uses arabic page numbering starting from the introduction page. Before that I have the \tableofcontents where I would like to show the page numbers as Roman, even when the real ones are numbered as arabic.

Example of wanted ToC:

  1. First chapter --- I
  2. Second chapter ---- X

But the real page number of the first chapter must be 1, second chapter must be 10, etc. I only need to transform the numbers to Roman on the ToC.

I've tried with this:

% ...
    \pagenumbering{Roman}
    \tableofcontents
    \pagenumbering{arabic}
    \setcounter{page}{1}
    \chapter{First chapter} % Page: 1
    % ... 
    \chapter{Second chapter} % Page: 10
% ...

But that just changes the pages where the ToC is, not the ToC itself, and that's not what I want.

  • Could you post a minimal (non-)working example that we can play with? – Bernard Aug 21 '15 at 19:18
  • What is the rationale behind this awkwardness? Which page number style should be used by \pageref? – Heiko Oberdiek Aug 21 '15 at 19:49
  • \pagenumbering{arabic} should be preceded by \cleardoublepage. – egreg Aug 21 '15 at 19:49
0

Typically all sectioning commands write \thepage to the ToC using \addcontentsline. You can update \addcontentsline to

\renewcommand{\addcontentsline}[3]{%
  \addtocontents{#1}{\protect\contentsline{#2}{#3}{\Roman{page}}}}

which writes \Roman{page} to the ToC instead of the default formatting \thepage (which may be different from \Roman{page}). A better option might be to patch \addcontentsline using etoolbox:

\usepackage{etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\addcontentsline}{\thepage}{\Roman{page}}{}{}

enter image description here

\documentclass[openany]{book}

\usepackage{etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\addcontentsline}{\thepage}{\Roman{page}}{}{}

\begin{document}

\tableofcontents

\clearpage
\pagenumbering{arabic}
\chapter{A chapter} % Page: 1
\section{A section}
\subsection{A subsection}

\clearpage
\setcounter{page}{10}
\chapter{Another chapter} % Page: 10
\section{Another section}
\subsection{Another subsection}
\end{document}
  • I don't think this makes sense. – egreg Aug 21 '15 at 19:48
  • @egreg: The OP mentioned "this could seem a little awkward, but apparently I need to do it this way." – Werner Aug 21 '15 at 19:49
  • I see; it doesn't make sense nonetheless. ;-) – egreg Aug 21 '15 at 19:50
  • No, it doesn't make any sense, but it's what I needed, thank you!! I have faith that the person responsible for writing this nonsense rule at my university will be punished eventually... and very badly. – user3346114 Aug 21 '15 at 20:01
  • 4
    @Cataphractus: Are you sure that you get the rule right? Maybe the pages on which the TOC is printed should be numbered roman?! That makes lot more sense and is quite common … – Tobi Aug 21 '15 at 20:10

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.