LaTeX forum ⇒ GeneralCounters as Variables Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
nikolapoljak
Posts: 9
Joined: Sun Feb 26, 2012 3:03 pm

Counters as Variables

Postby nikolapoljak » Fri Apr 19, 2013 7:15 pm

Hi,

Let's say I have two counters set up in a file that do their counting correctly. Printing out a total value of a counter is simple, but how could I print out a ratio of two totals (something like \total{counta}/\total{countb}) to a specific number of decimal points? Also, how could I print the value of a counter divided by some pre-specified number?

I've looked around to find this, but didn't have any luck.

Thanks!
Last edited by nikolapoljak on Sat Apr 20, 2013 9:37 pm, edited 2 times in total.

Link:
BBcode:
HTML:
Hide post links
Show post links

nikolapoljak
Posts: 9
Joined: Sun Feb 26, 2012 3:03 pm

Postby nikolapoljak » Sat Apr 20, 2013 9:37 pm

Solved - more or less, by using packages totcount and fp and by using \csname. Couldn't find a simpler workaround.

After filling in counters countA and countB, defined whit \newtotcount I can do this.
  1. \FPdiv\intresult{\csname thecountA\endcsname}{\csname thecountB\endcsname}
  2. \FPround\final{\intresult}{2}

I get the final solution rounded off to two decimals. Writing it out in text is simple, something like this.
  1. The result I got is \final.

Of course, if say countB gets filled after the calculation written here, run LaTeX twice so that the \totcount does it's thing.

Link:
BBcode: Topic is solved[/url]" title="Click to select post's link in BBcode format" onclick="this.focus();this.select();" />
HTML: Topic is solved</a>" title="Click to select post's link in HTML format" onclick="this.focus();this.select();" />
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Sun Apr 21, 2013 11:46 am

The fp package would also have been one of my suggestions. Other possibilities for calculating real numbers are

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests