[Tex/LaTex] Page number on Index page

indexingpage-numbering

I define the style of page numbering using fancy package, however, on Index page number is set in the center of footer. How to get the number in right place or remove it at all from Index page (at least…)?

\documentclass[]{article}

\usepackage{lastpage}

\usepackage{fancyhdr}
\pagestyle{fancy}

\fancyhf{}
\rhead{\thepage/\pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}

\usepackage{makeidx}
\makeindex

\begin{document}

\section{A} \index{A}
\newpage
\section{B} \index{B}

\printindex

\end{document}

Best Answer

You have to redefine the plain pagestyle. If you want to keep it also, you might try something like this. @Ruedi was the first, but this didn't really fit in the comments...

\documentclass[]{article}

\usepackage{lastpage}

\usepackage{fancyhdr}
\pagestyle{fancy}

\fancyhf{}
\rhead{\thepage/\pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}

% BACKUP PLAIN STYLE
\makeatletter
\let\ps@plainorig\ps@plain
\makeatother

\usepackage{makeidx}
\makeindex

\begin{document}

\section{A} \index{A}
\newpage
\section{B} \index{B}

% CHANGE PLAIN STYLE
\makeatletter
\let\ps@plain\ps@fancy
\makeatother

\printindex

% REVERT PLAIN STYLE
\makeatletter
\let\ps@plain\ps@plainorig
\makeatother

\end{document}