0

I am trying to have the both the current and last page of the frontmatter in the footer, without using any extra packages. onecolumn does this without problem , but twocolumn causes a pageref on the last ToC page to point to the page immediately following it, so the page numbers become for an odd page:

i, cleared, 1, 2, 3, ...:

i / ii
cleared
1 / 7
2 / 7
3 / 7
...

while with onecolumn it correcly yields

i / i
cleared
1 / 7
2 / 7
3 / 7
...

and in the case of an even page twocolumn prints the page of the following chapter:

i, ii, 1, 2, 3, ...:

i / 1
ii / 1
1 / 15
2 / 15
3 / 15
...

while with onecolumn it correcly yields

i / ii
ii / ii
1 / 15
2 / 15
3 / 15
...

What could be causing this?

\documentclass[ a5paper
                ,17pt
                ,twocolumn
                ]{memoir}

\makeoddfoot    {plain}{}{{\thepage} / {\thelastpage}}{}
\makeevenfoot   {plain}{}{{\thepage} / {\thelastpage}}{}

\makepagestyle  {toc}
\makeoddfoot    {toc}{}{{\thepage} / {\pageref{lasttocpage}}}{}
\makeevenfoot   {toc}{}{{\thepage} / {\pageref{lasttocpage}}}{}

\AtBeginDocument{
    \addtocontents{toc}{
        \protect\thispagestyle{toc}
        \protect\pagestyle{toc}
    }
}

\begin{document}

\frontmatter

\pagestyle{toc}
\tableofcontents
\label{lasttocpage}
\pagestyle{toc}

\mainmatter

\chapter{Example} \chapter{Example} \chapter{Example} \chapter{Example}
% uncomment for even page ToC ending
%\chapter{Example} \chapter{Example} \chapter{Example} \chapter{Example}

\end{document}
1
  • 1
    \renewcommand\cfttocafterlisthook{\label{lasttocpage}}? To get it away from the extra stuff added inside \tableofcontents
    – daleif
    Commented Oct 6, 2017 at 12:33

1 Answer 1

2

Try

\renewcommand\cfttocafterlisthook{\label{lasttocpage}}

memoir has hooks inside the \tableofcontens macro, suft that you can get stuff close to the reading of the toc file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .