This question already has an answer here:

I'm trying to calculate the sum of some numbers in my document. I want to allow non-integer values, so I'm using lengths, which works just fine.

In my document it's often necessary to specify the values for adding to the sum from inside an environment. I learned that the \global command does the trick.

However, I encountered the problem that the \global command seems to not work properly when the xifthen package is loaded, either directly or by another package.

Here's an example:



The output is:

0 0.5 0 0.5 0

Removing the xifthen package produces the expected output:

0 0.5 0 0.5 0.5

Is there any workaround to produce the second output, without having to ensure that no package which uses xifthen is loaded?

marked as duplicate by David Carlisle, Red, Mensch, Werner, karlkoeller Sep 24 '13 at 16:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    \global\addtolength is wrong anyway. The problem is that xifthen loads calc that redefines \addtolength so that \global has no effect (but it has effect without calc just by chance). See tex.stackexchange.com/a/119738/4427 – egreg Sep 24 '13 at 14:59