# page number to cover several numbers, i.e. page page 1, 2, 3/4, 5-8, and 9

I'm interested to have several page number's refer to one page?

Here's an example illustrating what I have

\documentclass{article}
\begin{document}
\tableofcontents
\setcounter{page}{3}
\subsection{Introduction}
\newpage
\setcounter{page}{5} % what I would like to be able to write {4/5}
\subsection{Something}
\newpage
\setcounter{page}{7}
\subsection{Conclusion}
\end{document}


this obliviously give this index,

what I would like to do is to, e.g., set \setcounter{page}{4/5} and get is something like,

possible also with the option to set \setcounter{page}{5-8}

I generated the above using this code (and then deleted some pages)

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{lipsum}
\renewcommand*{\thepage}{\Huge\arabic{page}}
% 1, 2, 3/4, 5-8, and 9
\begin{document}
{\Huge \tableofcontents}
\setcounter{page}{1}
\subsection{Introduction}
\lipsum[1]
\newpage
\setcounter{page}{2}
\subsection{Foo}
\lipsum[1-3]
\newpage
\setcounter{page}{3} % here I would like to be able to write \setcounter{page}{3/4}
\subsection{Something}
\lipsum[1-3]
\newpage
4
\newpage
\setcounter{page}{5} % here I would like to be able to write \setcounter{page}{5-8}
\subsection{Bar}
\lipsum[1-3]
\newpage
6
\newpage
7
\newpage
9
\newpage
\subsection{Conclusion}
\lipsum[1-3]
\end{document}

• @leandriis, Thank you for your comment. I did look at those answers, what they do is tweaking the index to summarize’ a range of page numbers in the index. That’s not exactly what I am looking to do. What I am looking for is some way to cram several (virtual?) pages onto one page. Which then would be reflected in the index (and look like th two answer you point to). I’ll update my question. – Eric Fail Oct 8 '17 at 10:30
• For page number ranges on the pages of a document I found the following solution: tex.stackexchange.com/a/68425/134144, which can be easily adapted to your task. However, using this approach, the page numbers in the toc are not shown as page ranges and I have not been able to figure out how to overcome this. – leandriis Oct 8 '17 at 12:41
• Even if it is interesting to find a technical solution to your question, I like to remind that the reader has to interpret it. Often the value of the table of contents is overrated. – Harald Lichtenstein Oct 10 '17 at 9:24
• @HaraldLichtenstein, that's exactly the issue I am currently struggling with. I am definitely interested to have the reader interpret the pages as 3/4, 5-8, etc. To me most readers seem to be quite flexible. I have PDF documents where the first pages are roman, i.e i, ii, ... and the following pages are arabic, i.e. 1, 2, ... I can also generate PDFs that the reader reads with non-continues pages, but maybe 3/4, 5-8, etc. is impossible. – Eric Fail Oct 10 '17 at 12:18

With the package everypage you can create a macro to specify a custom page number which is automatically reset after the page:

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{lipsum}

%% Specify the default page format:
\newcommand*{\thepageformat}{\arabic{page}}
\renewcommand*{\thepage}{\Huge\thepageformat}

%% Automatically reset the page format to default on every page:
\usepackage{everypage}
\global\def\thepageformat{\arabic{page}}
}

%% A macro to set the page "number" manually for the current page:
\newcommand*{\custompage}[2][1]{
%% use the optional argument to specify the number of pages in your range
}

\begin{document}
{\Huge \tableofcontents}
\subsection{Introduction}
\lipsum[1]
\newpage

\subsection{Foo}
\lipsum[1-3]
\newpage

\custompage[2]{3/4} %% range 3-4 (2 pages)
\subsection{Something}
\lipsum[1-3]
\newpage

\custompage[4]{5--8} %% range 5-8 (4 pages)
\subsection{Bar}
\lipsum[1-3]
\newpage

\subsection{Conclusion}
\lipsum[1-3]
\end{document}


Edit: With the macro

\newcommand*{\custompagetoc}[3][1]{ %% Usage: \custompagetoc[numpages]{page number}{toc page number}
\global\def\thepageformat{#3} %% for the toc
\def\thepageformat{#2} %% for the page
}
}


you can also have different page numbers in the toc than on the page itself:

\custompagetoc[4]{5--8}{5+} %% on the page: "5–8", in the toc: "5+", advance counter by 4 pages instead of 1


You can't set a counter to a range. But you can change the representation of the page number (I leave the \Huge as it was in your example)

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{lipsum}
\renewcommand*{\thepage}{\Huge\arabic{page}}
% 1, 2, 3/4, 5-8, and 9
\begin{document}
{\Huge \tableofcontents}
%\setcounter{page}{1}
\subsection{Introduction}
\lipsum[1]
\newpage
%\setcounter{page}{2}
\subsection{Foo}
\lipsum[1-3]
\newpage
\renewcommand\thepage{\Huge3/4}
\subsection{Something}
\lipsum[1-3]
\newpage
\renewcommand\thepage{\Huge\arabic{page}}
4
\newpage
\renewcommand\thepage{\Huge5-8}
\subsection{Bar}
\lipsum[1-3]
\newpage
\renewcommand\thepage{\Huge\arabic{page}}
6
\newpage
7
\newpage
9
\newpage
\subsection{Conclusion}
\lipsum[1-3]
\end{document}


I would propose a command \newVirtualPage (without parameters) which can be used like \newpage but which has no visual effect except for an influence on the page number. This would avoid the need to hardcode page numbers and avoid possible inconsistencies.

\documentclass{article}

\newcounter{NumberVirtualPages}

% use this to create a new virtual page
% use it several times if you want several virtual pages
% the page number is adjusted automatically
\newcommand{\newVirtualPage}{%
\stepcounter{NumberVirtualPages}%
\stepcounter{page}%
}

% format to be used for page numbers
\newcommand*{\thePageFormat}{\arabic{page}}

% initialize \theRealPage
\xdef\theRealPage{\thePageFormat}

% set \pagenumber at every page depending on NumberVirtualPages
\usepackage{everypage}
% define \pagenumber
\xdef\thepage{%
\ifnum 0=\theNumberVirtualPages\relax
\theRealPage
\else \ifnum 1=\theNumberVirtualPages\relax
\theRealPage/\thePageFormat%
\else
\theRealPage--\thePageFormat%
\fi \fi
}%
% set \theRealPage to next page number
\xdef\theRealPage{\thePageFormat}%
% reset NumberVirtualPages
\setcounter{NumberVirtualPages}{0}%
}

% ========== TEST ==========

\usepackage{lipsum}

\begin{document}
\tableofcontents
\section{Introduction}
\label{intro}%
\lipsum[1]
\newpage

\section{Foo}
\label{foo}%
\lipsum[1-3]
\newpage

\section{Bar}
\begin{minipage}{.45\linewidth}
\label{bar-1}%
\lipsum[1]
\end{minipage}%
\hfill
\newVirtualPage
\begin{minipage}{.45\linewidth}
\label{bar-2}%
\lipsum[1]
\end{minipage}%
\newpage

\section{Another Section}
\label{a-1}%
\lipsum[1]
\newVirtualPage
\bigskip
\noindent
\begin{minipage}{.45\linewidth}
\label{a-2}%
\lipsum[1-1]
\end{minipage}%
\hfill
\newVirtualPage
\begin{minipage}{.45\linewidth}
\label{a-3}%
\lipsum[1]
\end{minipage}%

\newpage

\section{Conclusion}
\label{end}
\newcommand{\testref}[1]{section~\ref{#1} on page~\pageref{#1}}
It started with \testref{intro}, followed by \testref{foo}.
It got interesting in \testref{bar-1} and \testref{bar-2}.
As shown in \testref{a-1}, \testref{a-2} and \testref{a-3} the page number looks different when having more virtual pages.
In the end it is even possible to reference \testref{end}.
\end{document}
`