0

I want to have my page numbers in orange and of size footnotesize. Why does the following not produce that result on the title page? I am willing to entertain two solutions: either suppress the page numbers on the title page, or start with correctly formatted page numbering at section A.

\documentclass{article}
\usepackage{fancyhdr,xcolor}
\usepackage[titles]{tocloft}
\makeatletter
\fancypagestyle{mypagestyle}{%
  \fancyhf{}% 
  \fancyfoot[C]{\footnotesize \textcolor{orange}{\thepage}}% P
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
}
\makeatother
\pagestyle{mypagestyle}
\title{Title goes here}
\author{Author goes here}
\begin{document}
    \maketitle
    \newpage
    \tableofcontents
    \newpage
    \section{A} Section A text.
    \newpage
    \section{B} Section B text.
    \newpage
    \section{C} Section C text.
\end{document}
  • Because \maketitle uses \thispagestyle{plain} internally – user31729 Aug 6 '15 at 19:45
  • if the first page is really just for a title you can type {\renewcommand{\thepage}{\huge \textcolor{orange}{\arabic{page}}} \maketitle \newpage} – touhami Aug 6 '15 at 20:02
4

\maketitle of the article.cls uses \thispagestyle{plain}. If this is not wanted either plain has to be redefined, \maketitle be redefined or one could use \xpatchcmd to replace the plain with mypagestyle here.

  \xpatchcmd{\maketitle}{\thispagestyle{plain}}{\thispagestyle{mypagestyle}}{}{}

Since the O.P. does set the pagestyle globally to mypagestyle at the beginning,

  \xpatchcmd{\maketitle}{\thispagestyle{plain}}{}{}{}

would do also, i.e. replacing it with nothing. The first method is 'safer', however.

\documentclass{article}
\usepackage{fancyhdr,xcolor}
\usepackage[titles]{tocloft}

\usepackage{xpatch}

\makeatletter


\fancypagestyle{mypagestyle}{%
  \fancyhf{}% 
  \fancyfoot[C]{\huge \textcolor{orange}{\thepage}}% P
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
}
\makeatother

% Patch the plain out of \maketitle
\xpatchcmd{\maketitle}{\thispagestyle{plain}}{\thispagestyle{mypagestyle}}{}{}


\pagestyle{mypagestyle}
\title{Title goes here}
\author{Author goes here}
\begin{document}
    \maketitle
    \newpage
    \tableofcontents
    \newpage
    \section{A} Section A text.
    \newpage
    \section{B} Section B text.
    \newpage
    \section{C} Section C text.
\end{document}

enter image description here

  • 1
    Why replace it? Why not just remove it (i.e. replace with nothing)? – Sean Allred Aug 6 '15 at 19:50
  • @SeanAllred: Just for the case that mypagestyle is not set from the beginning? – user31729 Aug 6 '15 at 19:51
  • Fair enough, I suppose, but OP is setting the pagestyle globally :) – Sean Allred Aug 6 '15 at 19:52
  • @SeanAllred: I include the case that the OP just forgot to do so :-P – user31729 Aug 6 '15 at 19:52
  • \footnotesize has been replaced to make the number more outstanding here, just for demonstration – user31729 Aug 6 '15 at 19:55

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.