[Tex/LaTex] macros that won’t accept other macros as arguments


I'm trying to pass a counter to a macro that uses macros from the fp package.

I can pass hard coded values and \results from the fp package BUT if I pass the counter it complains that it is not a valid floating point value.

Is there any way to make this is work? There should be no diference between \cmd{1} and \cmd{\count0} as logically and mathematically when \count0 is 1.

I'm not sure what is going on behind the scenes but there should be some way to get it to work. This will save me trouble of having to create a \result variable that follows the counter which adds unnecessary clutter.

Best Answer

At face value, or as the current question stands, it seems like you're merely interested in passing counter values to "some command", which may even be macros supplied by the fp package.

Here is a minimal example of passing counter values to the fp package macros:

enter image description here

\usepackage{fp}% http://ctan.org/pkg/fp
\newcounter{count0} \newcounter{test}
\setcounter{count0}{5} \setcounter{test}{6}
\csname thecount0\endcsname \par
\thetest \par
\FPeval\result{clip(2*3+5*6)}\result \par
\FPeval\result{clip(2*3+\csname thecount0\endcsname*6)}\result \par

Note that if you're using count0 as a counter name, value extraction is not as simple as saying \thecount0, since macro definitions with numerals need special care. Also, \value{count0} (internal representation of count0) may be different from \csname thecount0\endcsname (the typesetting of count0), which may be different from \arabic{count0} (a fixed \arabic representation of count0).

Counters without numerals in their name are handled much easier (like test) in the above example.

Related Question