TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to pass in a ratio of 4/15 (instead of its approximated decimal form of 0.266) to table definition.

Final solution can be seen here.

I need one more vote to close this topic.

share|improve this question
But, if you have another solution, welcome! – xport Dec 26 '10 at 18:52
Unfortunately, the \ratio above cannot accept dimensionless values such as \ratio{4}{15}. :-( – xport Dec 26 '10 at 19:30
If you want some overkill, you could use pgfmathparse. – Caramdir Dec 26 '10 at 19:33
@Caramdir, I will revisit this tomorrow. Thank you for commenting. – xport Dec 26 '10 at 19:44
@xport: Only the first comment in your \ratio macro is necessary. – TH. Dec 28 '10 at 9:11

If you want more accurate calculations use the fp package.

For example using the fp package as shown below you get 0.999999999999999998 rather than 0.998.



No need for any manual calculations!

You can use it in a tabular as follows (remember it creates variable names on the fly)




\begin{tabular}{|p{\columni cm}|p{\columnii cm}|}
a & b \\
c & d \\


share|improve this answer
@Yiannis, thanks for answering. It is useful. – xport Dec 27 '10 at 1:41
@Yiannis, how to define a newcommand with 2 inputs and produces the ratio between the inputs? Internally the newcommand use \FPdiv of course. I don't understand the manual of fp.sty. It is very short and difficult to understand. – xport Dec 27 '10 at 2:27
@xport \def\division#1#2{ \FPdiv\result{#1}{#2} \result } \division{2}{9999} – Yiannis Lazarides Dec 27 '10 at 3:51
@Yiannis, please kindly see again my last update above. – xport Dec 27 '10 at 5:05
@xport: I didn't check for sure, but the problem is that the \FP macros are not expandable. You're going to have to do the division before you need to use the result in an expandable manner. – TH. Dec 27 '10 at 12:02

I cannot see a gap with a zoom of 400% ...




share|improve this answer
because you took more accurate decimal numbers. You lost only 0.0001 in total. :-) – xport Dec 26 '10 at 19:00
even though there is no gap by taking more accurate decimal ratios, doing conversion manually is tedious. – xport Dec 26 '10 at 19:09
up vote 0 down vote accepted

See Joseph's solution.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.