[Tex/LaTex] Custom page numbering

page-numbering

So after looking around on the web and finding nothing, i'm asking it here:

How can I convert pagination to a "Chapter-section" (see image below) style rather than numerically advancing page numbers.

PS: I've also been looking for a tutorial to edit all the features of the ToC (and page design in general)

ToC from "Feynman's lectures on physics"

Best Answer

Update

\documentclass{memoir}
\usepackage{lipsum} % just for example

\begin{document}
\maketitle
\pagenumbering{gobble}
\tableofcontents
\newpage
\pagenumbering{arabic} % you don't need this
\makeatletter
\@addtoreset{page}{chapter}
\renewcommand\thepage{\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@page}
\let\oldafterchaptertitle\afterchaptertitle
\renewcommand{\afterchaptertitle}{\oldafterchaptertitle\refstepcounter{page}}
\makeatother

\chapter{First}
\section{Foo}
\lipsum[1-20]

\chapter{Last}
\section{Bar}
\lipsum[1-20]

\end{document}

Here is a solution (a similar solution How to do custom page numbering)

\documentclass{memoir}
\usepackage{lipsum} % just for example

\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@chapter}{\refstepcounter{chapter}}{\refstepcounter{chapter}\refstepcounter{page}}%
{}{\errmessage{problem in patching \noexpand\chapter}}
\@addtoreset{page}{chapter}
\renewcommand\thepage{\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@page}
\makeatother

\begin{document}
\tableofcontents


\chapter{First}
\section{Foo}
\lipsum[1-20]

\chapter{Last}
\section{Bar}
\lipsum[1-20]

% here you can see the problem, one can try \setcounter{chapter}{0} if all unnumbered chapter are at the end

\chapter*{Last}
\section{Bar}
\lipsum[1-20]

\end{document}

enter image description here