4

I would like to use the page number of a label as the input for \setcounter{page}{label's page}. I tried using zref abspage, however, in my document there are a few uncounted pages before I start with the actual page numbering, therefore abspage is offset by 2 pages. I also tried it with newcommand and variables, but I could not get it to work properly. An additional hurdle seems to be the roman style of page numbering making it hard to convert (got -1 using etoolbox's \rmntonum).

How can I resume the roman page numbering using a label placed at the end of the first part, before arabic numbering is used? The solution should be as generic as possible, i.e. not subtracting a hard coded offset.

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}
    this is my title
    \thispagestyle{empty}
    \newpage

    some declarations
    \thispagestyle{empty}
    \newpage

    \setcounter{page}{1}
    \pagenumbering{Roman}
    \tableofcontents
    \newpage

    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures
    \label{end of intro}
    \newpage

    \pagenumbering{arabic}
    \chapter{chapter one}
    \lipsum[2-5]
    \cite{kastenholz}

    \chapter{chapter two}
    \lipsum[2-4]

    \clearpage
    \pagenumbering{roman}
    \setcounter{page}{3}    % <-- set this value based on label 'end of intro', zref abspage gives 4

    \addcontentsline{toc}{chapter}{References} 
    \printbibliography

\end{document}
4

Do you have to use a \label? You might as well use a \newcount and use its value to set your counter:

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\newcount\pagebak

\begin{document}
    this is my title
    \thispagestyle{empty}
    \newpage

    some declarations
    \thispagestyle{empty}
    \newpage

    \setcounter{page}{1}
    \pagenumbering{Roman}
    \tableofcontents
    \newpage

    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures
    \pagebak=\arabic{page}
    \label{end of intro}
    \newpage

    \pagenumbering{arabic}
    \chapter{chapter one}
    \lipsum[2-5]
    \cite{kastenholz}

    \chapter{chapter two}
    \lipsum[2-4]

    \clearpage
    \pagenumbering{roman}
    %\setcounter{page}{3}    % <-- set this value based on label 'end of intro', zref abspage gives 4
    \setcounter{page}{\numexpr\pagebak+1}    % <-- set this value based on label 'end of intro', zref abspage gives 4

    \addcontentsline{toc}{chapter}{References} 
    \printbibliography

\end{document}
2

Here's a way with zref:

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}

\usepackage[nottoc]{tocbibind} % no need for \addcontentsline
\usepackage[user,abspage]{zref}

\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage{lipsum}

\makeatletter
\newcommand{\startfront}{\clearpage\pagenumbering{Roman}\zlabel{startfront}}
\newcommand{\startmain}{\clearpage\pagenumbering{arabic}\zlabel{startmain}}
\newcommand\startback{%
  \clearpage
  \pagenumbering{Roman}%
  \setcounter{page}{%
    \numexpr
      \zref@extractdefault{startmain}{abspage}{0}-
      \zref@extractdefault{startfront}{abspage}{0}+1
    \relax
  }%
}
\makeatother

\begin{document}

\thispagestyle{empty}
this is my title
\clearpage

\thispagestyle{empty}
some declarations
\clearpage

\startfront
\tableofcontents
\listoffigures

\startmain

\chapter{chapter one}
\lipsum[2-5]
\cite{kastenholz}

\chapter{chapter two}
\lipsum[2-4]

\startback

\printbibliography[heading=bibintoc]

\end{document}

The details are hidden in \startfront, \startmain and \startback.

Note that you need no \addcontentsline instructions.

enter image description here

  • thank you for your answer, I knew that it had to be possible with zref, but could not figure it out. However, the answer by skillmon is easier for me because (for now) I don't use the zref package. The tocbibind package is quite handy, thanks for the hint. – derptank Jun 9 '17 at 12:22

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.