I have three counters counterBoat
, counterThink
and counterWork
.
I want to print the integer "round"(100*counterBoat/(counterBoat+ counterThink+ counterWork))
in my document.
I use the package totcount
.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI have three counters counterBoat
, counterThink
and counterWork
.
I want to print the integer "round"(100*counterBoat/(counterBoat+ counterThink+ counterWork))
in my document.
I use the package totcount
.
\numexpr(100*\value{counterBoat}) /
( \value{counterBoat} + \value{counterThink} + \value{counterWork})\relax
\the
– David Carlisle
Oct 2 '19 at 12:57
\the
in front of that line in a document and the number will be printed. There is no testable code in this answer as you did not supply a test document in the question.
– David Carlisle
Oct 2 '19 at 15:03
\numexpr
and counters so this is integer arithmetic. That appears to be a completely different question, perhaps you want to use the xfp package and floating point arithmetic, i really can't guess.
– David Carlisle
Oct 2 '19 at 16:03
xfp
package and use\inteval
, and use\value
to access the values of the counters. The result is rounded by default.\inteval{100*\value{counterBoat}/(\value{counterBoat}+\value{counterThink}+\value{counterWork})}
– Phelype Oleinik Oct 2 '19 at 12:54