[Tex/LaTex] Checking if a number is a multiple of 4

calculationsconditionalsetoolbox

Using etoolbox, ifthen, or another form of conditional checking, how can I check if a value is a multiple of 4? E.g. if the number is 4, 8, 12, 16, etc., then it returns "true".

Best Answer

You can use pgfmath for this:

\documentclass{article}
\usepackage{pgf}

\begin{document}
\newcommand\ifismultiple[4]{%
    \pgfmathparse{mod(#1,#2)==0}
    \ifnum \pgfmathresult=1
    #3%
    \else
    #4%
    \fi
}
\ifismultiple{15}{4}{true}{false}
\end{document}