TeX \newcommand and D.R.Y. (don't repeat yourself)
You could simply use the builtin \ifodd
and check the value of the item. A better solution is to define your own list type with
\newlist{altcolorslist}
and simply use
\begin{altcolorslist}
\item ...
\begin{altcolorslist}
similar to Andrew Swann's answer.
References:
ifnum x is even DO THIS \else DO THIS \fi
To redefine a macro that has optional parameters, you have to use
\LetLtxMacro
from theletltxmacro
package . A detailed description of\LetLtxMacro
can be found at this question at When to use \LetLtxMacro?.
Code:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage{enumitem}
\newcommand*{\Item}{\item\ifodd\value{enumi}\color{black}\else\color{blue}\fi}
\begin{document}
\begin{varwidth}[t]{\textwidth}
TRIGONOMETRIA
\begin{enumerate}[leftmargin=*,label={\textcolor{black}{\textbullet}}]
\Item $\sin^{2} \alpha + \cos^{2} \alpha = 1$
\Item {$\tan \alpha = \dfrac{\sin \alpha}{\cos \alpha}$}
\Item $\sin \alpha + \beta = \sin \alpha \cos \beta + \sin \beta \cos \alpha$
\Item {$\cos \alpha + \beta = \cos \alpha \cos \beta - \sin \alpha \sin \beta$}
\Item $\tan \alpha + \beta = \dfrac{\tan \alpha + \tan \beta}{1 - \tan \alpha \tan \beta}$
\Item {$\sin \alpha - \beta = \sin \alpha \cos \beta - \sin \beta \cos \alpha$}
\Item $\cos \alpha - \beta = \cos \alpha \cos \beta + \sin \alpha \sin \beta$
\Item {$\tan \alpha - \beta = \dfrac{\tan \alpha - \tan \beta}{1 + \tan \alpha \tan \beta}$}
\Item $\sec \alpha = \dfrac{1}{\cos \alpha}$
\Item {$\dfrac{\sin^{2} \alpha}{\cos^{2} \alpha} + 1 = \tan^{2} \alpha + 1 = \sec^{2} \alpha$}
\Item $\sin(\arctan z) = \cfrac{z}{\sqrt{z^{2} + 1}}$
\Item {$\cos(\arctan z) = \cfrac{1}{\sqrt{z^{2} + 1}}$}
\Item $\cos 2\alpha =\begin{cases}
\cos^{2} \alpha - \sin^{2} \alpha\\
2 \cos^{2} \alpha - 1\\
1 - \sin^{2} \alpha
\end{cases}
$
\Item $\cos 2\alpha =\begin{cases}
\cos^{2} \alpha - \sin^{2} \alpha\\
2 \cos^{2} \alpha - 1\\
1 - \sin^{2} \alpha
\end{cases}
$
\end{enumerate}
\end{varwidth}%
\end{document}
Code: Custom List Version
\documentclass{article}
\usepackage{letltxmacro}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage{enumitem}
\LetLtxMacro{\OldItem}{\item}
\newcommand*{\MyItem}{\OldItem\ifodd\value{altcolorslisti}\color{black}\else\color{blue}\fi}
\newlist{altcolorslist}{enumerate}{1}
\setlist[altcolorslist]{
leftmargin=*,label={\textcolor{black}{\textbullet}},
before={\let\item\MyItem},
after={\let\item\OldItem},
}
\begin{document}
\begin{varwidth}[t]{\textwidth}
TRIGONOMETRIA
\begin{altcolorslist}
\item $\sin^{2} \alpha + \cos^{2} \alpha = 1$
\item $\tan \alpha = \dfrac{\sin \alpha}{\cos \alpha}$
\item $\sin \alpha + \beta = \sin \alpha \cos \beta + \sin \beta \cos \alpha$
\item $\cos \alpha + \beta = \cos \alpha \cos \beta - \sin \alpha \sin \beta$
\end{altcolorslist}
\end{varwidth}%
\end{document}
Here is a version where the item command retains its name and its optional argument.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage{etoolbox}
\usepackage{enumitem}
\usepackage{hyperref}
\definecolor{lightgray}{HTML}{EFEFEF}
\newtoggle{odditem}
\def\myitem{\iftoggle{odditem}%
{\color{black}\togglefalse{odditem}}%
{\color{blue}\toggletrue{odditem}}%
\olditem}
\newenvironment{myitemize}[1]{%
\begin{varwidth}[t]{\textwidth}
#1
\begin{itemize}[leftmargin=*]%
\toggletrue{odditem}%
\let\olditem\item%
\let\item\myitem}{\end{itemize}\end{varwidth}}
\begin{document}
\begin{myitemize}{TRIGONOMETRIA}
\item $\sin^{2} \alpha + \cos^{2} \alpha = 1$
\item $\tan \alpha = \dfrac{\sin \alpha}{\cos \alpha}$
\item $\sin \alpha + \beta = \sin \alpha \cos \beta + \sin \beta \cos \alpha$
\item[$*$] $\cos \alpha + \beta = \cos \alpha \cos \beta - \sin \alpha
\sin \beta$
\item $\tan \alpha + \beta = \dfrac{\tan \alpha + \tan \beta}{1 -
\tan \alpha \tan \beta}$
\end{myitemize}
\end{document}
In my opinion, a tabular
is handier.
Please, note that \ifodd
is a TeX primitive: you're trying (quite successfully) to break LaTeX by doing \newif\ifodd
.
Linguistic note. The English “pair” means “coppia”; the English term for “pari” is “even”.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[
a4paper,
margin=15mm,
bindingoffset=2mm,
heightrounded,
]{geometry}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage[table]{xcolor}
\usepackage{enumitem}
\usepackage{array}
\usepackage{booktabs}
\usepackage{hyperref}
\newenvironment{formulas}
{\setcounter{formulas}{0}%
\begin{tabular}{@{}>{\changecolor\textbullet\ }l@{}}}
{\end{tabular}}
\newcounter{formulas}
\newcommand{\changecolor}{%
\stepcounter{formulas}%
\ifodd\value{formulas}\color{black}\else\color{blue!70!green}\fi
}
\begin{document}
\begin{formulas}
\toprule
\multicolumn{1}{@{}l@{}}{TRIGONOMETRIA} \\
\midrule
$\sin^{2} \alpha + \cos^{2} \alpha = 1$
\\ \addlinespace
$\tan \alpha = \dfrac{\sin \alpha}{\cos \alpha}$
\\ \addlinespace
$\sin \alpha + \beta = \sin \alpha \cos \beta + \sin \beta \cos \alpha$
\\ \addlinespace
$\cos \alpha + \beta = \cos \alpha \cos \beta - \sin \alpha \sin \beta$
\\ \addlinespace
$\tan \alpha + \beta = \dfrac{\tan \alpha + \tan \beta}{1 - \tan \alpha \tan \beta}$
\\ \addlinespace
$\sin \alpha - \beta = \sin \alpha \cos \beta - \sin \beta \cos \alpha$
\\ \addlinespace
$\cos \alpha - \beta = \cos \alpha \cos \beta + \sin \alpha \sin \beta$
\\ \addlinespace
$\tan \alpha - \beta = \dfrac{\tan \alpha - \tan \beta}{1 + \tan \alpha \tan \beta}$
\\ \addlinespace
$\sec \alpha = \dfrac{1}{\cos \alpha}$
\\ \addlinespace
$\dfrac{\sin^{2} \alpha}{\cos^{2} \alpha} + 1 = \tan^{2} \alpha + 1 = \sec^{2} \alpha$
\\ \addlinespace
$\sin(\arctan z) = \cfrac{z}{\sqrt{z^{2} + 1}}$
\\ \addlinespace
$\cos(\arctan z) = \cfrac{1}{\sqrt{z^{2} + 1}}$
\\ \addlinespace
$\cos 2\alpha =\begin{cases}
\cos^{2} \alpha - \sin^{2} \alpha\\
2 \cos^{2} \alpha - 1\\
1 - \sin^{2} \alpha
\end{cases}$
\\ \addlinespace
$\cos 2\alpha =\begin{cases}
\cos^{2} \alpha - \sin^{2} \alpha\\
2 \cos^{2} \alpha - 1\\
1 - \sin^{2} \alpha
\end{cases}$
\\
\bottomrule
\end{formulas}
\end{document}