# The structure for mathstyle in even and odd pages

I want to have the following structure:

ifoddpage\everydisplay{\color{blue}
ifevenpage\everydisplay{\color{red}}


\newcommand{\ctt}{\checkoddpage
\ifoddpage\everydisplay{\color{blue}}
\else\everydisplay{\color{red}}
\fi}


This structure does not work correctly. I use xelatex compiler.
How can i do this?
This is my codes:

\documentclass[twoside]{book}
\usepackage{xcolor}
\usepackage{everysel}
\usepackage{mathtools}
\usepackage{changepage}
\newcommand{\ctt}{\checkoddpage
\ifoddpage\everydisplay{\color{blue}}
\else\everydisplay{\color{red}}
\fi}\ctt
\begin{document}
$a^2=b^2+c^2$
text\newpage%\ctt
$a^3=b^3+c^3$
\end{document}

• When I try your mwe (with \ctt uncommented) the command seems to work, i.e., the equation on the first page is blue and the equation on the second page is red. Do you get any error message? If not, what does the output look like? – Marijn Oct 26 '18 at 10:14
• Thanks @ Marijn. I don't want use \ctt for every page. – SH.Madadpour Oct 26 '18 at 11:36

I would move the check directly into \everydisplay

\documentclass[twoside]{book}

\usepackage{xcolor}
\usepackage{changepage}

\newcommand*{\ctt}{\checkoddpage\ifoddpage\color{blue}\else\color{red}\fi}

\everydisplay\expandafter{\the\everydisplay\ctt}

\begin{document}
Bla bla
$a^2=b^2+c^2$ % will be blue
text
\newpage
Bla bla
$a^2=b^2+c^2$ % will be red
text
\newpage
Bla bla
$a^2=b^2+c^2$ % will be blue
text
\newpage
\renewcommand*{\ctt}{\relax}% revert to do nothing
Bla bla
$a^2=b^2+c^2$ % will be black
text

\end{document}