# Page numbering resets at Index with imakeidx and JHEP template

I am typing a document using the template provided by JHEP

https://jhep.sissa.it/jhep/help/JHEP_TeXclass.jsp

I would like to include an Index with imakeidx. Everythings seems to be working fine, except that page numbering resets at the Index. I have stripped the code down to this:

\documentclass[a4paper,11pt]{article}

\usepackage{jheppub}

\usepackage{imakeidx}
\makeindex

\title{\boldmath some title}
\author{some author}

\begin{document}
\maketitle
\flushbottom
\section{title}\index{title}

\printindex

\end{document}


and the issue persists. I am looking for a solution/workaround.

My advice would be to set the pagestyle of the first page of the appendix to empty. The journal class does some really funny things.

\documentclass[a4paper,11pt]{article}

\usepackage{jheppub}
\usepackage{blindtext}

\usepackage{imakeidx}
\indexsetup{firstpagestyle=empty}
\makeindex

\title{Red bricks on a yellow bench}
\author{Carl Capybara}

\begin{document}
\maketitle
\section{Wombat}\index{Wombat}
\blindtext[10]

\printindex
\blindtext[10]

\end{document}


The index uses plain for the first page, the journal class does some definitions that start over pagenumbering every time the pagestyle is used. This is ,imho, a serious design error.

I see no reason whatsoever for the plain page style to be let equal to myplain (which resets the page numbering).

\documentclass[a4paper,11pt]{article}

\usepackage{imakeidx}
\usepackage{jheppub}

\usepackage{lipsum} % just for the example

\makeatletter
\renewcommand\ps@plain{%
%\pagenumbering{arabic}% no reset!
\renewcommand\@oddfoot{\hfill-- \thepage\ --\hfill}%
}
\makeatother

\makeindex

\title{some title}
\author{some author}

\begin{document}
\maketitle

\section{title}\index{title}

\lipsum

\printindex

\end{document}


Note that imakeidx should be loaded before jheppub, because otherwise index entries would not make links.

Alternatively,

\documentclass[a4paper,11pt]{article}

\usepackage{imakeidx}
\usepackage{jheppub}

\usepackage{lipsum} % just for the example

\makeatletter
\renewcommand\ps@myplainnoreset{%
%\pagenumbering{arabic}% no reset!
\renewcommand\@oddfoot{\hfill-- \thepage\ --\hfill}%
}
\makeatother

\makeindex
\indexsetup{firstpagestyle=myplainnoreset}

\title{some title}
\author{some author}

\begin{document}
\maketitle

\section{title}\index{title}

\lipsum

\printindex

\end{document}