Custom 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)

• I am currently using the memoir document class, and haven't tried anything anything for this particular problem, as i couldn't find any documentation on this aspect. – Jack Halford Jul 17 '15 at 16:10
• The problem is, a google search on this matter indicates how i can change page numbering from arabic to roman or alphabetical, but there is no documentation for deeper customization. – Jack Halford Jul 17 '15 at 16:18
• What about unnumbered chapters? please give us a minimal example of the whole structure of your document – touhami Jul 17 '15 at 16:39
• there is no problem with memoir, but at least for me there is a problem with unnumbered chapters, do you have \chapter*{....} like command in your document? index? bibliography? – touhami Jul 17 '15 at 17:39
• you can see this tex.stackexchange.com/questions/24657/…, this is duplicate, but since you are new user ? – touhami Jul 17 '15 at 17:45

Update

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

\begin{document}
\maketitle
\pagenumbering{gobble}
\tableofcontents
\newpage
\pagenumbering{arabic} % you don't need this
\makeatletter
\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}}
\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}


• that seems to be the solution, the problem is I don't understand the code, any documentation to get me going? – Jack Halford Jul 17 '15 at 18:29
• I will need to understand the code for starters because : your code compiles but when i copy paste in my preamble (or structure.tex) i get error messages : LaTeX Error: Missing \begin{document}. [\@addtoreset{page} and problem in patching \chapter . [...ge{problem in patching \noexpand\chapter}}] – Jack Halford Jul 17 '15 at 18:34
• we need a minimal example of your code – touhami Jul 17 '15 at 19:41
• here's my main.tex, the chapters I include are only chapters sections and paragraphs: pastebin.com/ZJREX1vK – Jack Halford Jul 17 '15 at 19:45
• also here's my structure.tex : pastebin.com/xdy65HnQ – Jack Halford Jul 17 '15 at 19:46