The main problem with your code is that you are not using the correct syntax. If you look section 89.3.5 of the current pgf manual (version 3.0.1a), then you will find that pgf provides a \pgfmathifthenelse{x}{y}{z} command that you use inside \pgfmathparse, or \pgfmathsetmacro, as the function ifthenelse(x,y,z). So, your code is using the syntax for the standalone macro \pgfmathifthenelse whereas you should be using the code for the internal ifthenelse pgfmath function. Further, the example given in the manual for ifthenelse is
\pgfmathparse{ifthenelse(5==4,"yes","no")} \pgfmathresult
so your use of \equal{...} is incorrect and unnecessary.
Secondly, to me it seems a bad idea to define a macro that you then give to \pgfmathsetmacro. Instead I would make your macro set \points directly:
\newcommand\bareme[1]{%
\pgfmathsetmacro{\points}{ifthenelse(#1==1,5,
ifthenelse(#1==2, 8,
ifthenelse(#1==3, 7,
ifthenelse(#1==4, 9,
ifthenelse(#1==5, 1,"")))))}%
}
This certainly works. On the other hand, there is a much simpler way to do what you want using the TeX \ifcase command:
\newcommand\Bareme[1]{%
\ifcase #1\or 5% have to skip 0
\or 8%
\or 7%
\or 9%
\or 1%
\else ?%
\fi%
}
For completeness, here is the full code:
\documentclass{article}
\usepackage{pgfmath}
\newcommand\bareme[1]{%
\pgfmathsetmacro{\points}{ifthenelse(#1==1,5,
ifthenelse(#1==2, 8,
ifthenelse(#1==3, 7,
ifthenelse(#1==4, 9,
ifthenelse(#1==5, 1,"")))))}%
}
\newcommand\Bareme[1]{%
\ifcase #1\or 5% have to skip 0
\or 8%
\or 7%
\or 9%
\or 1%
\else ?%
\fi%
}
\begin{document}
\bareme{1} \points
\Bareme{1}
\Bareme{2}
\Bareme{3}
\end{document}
\ifthenelseis probably overkill. – daleif Oct 12 '17 at 07:57