Saturday, 25 May 2013

\def function with arithmetic macro

\def function with arithmetic macro

I have been writing multiple equations to use for exam writing. I have made some new macros that display a positive sign in front of an expression for positive numbers and display no sign for negative numbers.
Here is an example of a simple version of my definitions:
\def\dsignaddmulti#1#2#3#4{
\newcount\tmp
\newcount\ymp
\tmp=#1
\ymp=#3
\multiply\tmp by #2
\multiply\ymp by #4
\advance\tmp by \ymp
\FPifneg{\the\tmp}\else+\fi
}
I am trying to construct the same definition to multiply four numbers. The definition works, but is displaying the number after the "sign", which I do not want.
Here is the non-working code:
\def\dsignmulti#1#2#3#4{
\newcount\tmp
\newcount\ymp
\tmp=#1
\ymp=#3
\multiply\tmp by #2
\multiply\ymp by #4
\multiply \tmp by \ymp
\FPifneg{\the\tmp} \else+\fi
}
Is there something that I am missing?
These are defined in my esami.sty file if that helps.

No comments:

Post a Comment