[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Need Math Help: How to Convert Proportional Column

Subject: Re: Need Math Help: How to Convert Proportional Column Widths to Real Values?
From: Graydon <graydon@xxxxxxxxx>
Date: Fri, 7 Mar 2014 19:08:36 -0500
Re:  Need Math Help: How to Convert Proportional Column
On Fri, Mar 07, 2014 at 05:51:10PM -0600, Eliot Kimber scripsit:
> I'm converting CALS tables into InDesign tables where I need to specify
> actual measurements. I know the width available to all the proportional
> columns and I know the CALS proportional values, e.g. "1*", "1.38*", etc.
> 
> My puzzle is, how do I go from 1.38 to the correct fraction of the
> available width?
> 
> For example, say that I have two proportional columns of width "1*" and
> "1.39*" and the available width is 240pt.
> 
> How do I determine fraction of 240 each of these proportions get?

Proportional works by "shares", so "2*" is twice as large as "1*".

You need to total the proportional widths (carefully expunging the *
before asking XSLT to do math on the values!) to get the total number of
shares, divide that into the available width in points to get a single
share in points, and then start multiplying the proportional width
values by that single-share size to get the final sizes.

This sort of thing often gets fraught because of rounding, you're not
necessarily going to get the full 240 pts of available width.

In this specific case, it's

shareSize = 240/(1 + 1.39) ~= 100.42

So    1* = 1 x $shareSize = 100.42

   1.39* = 1.39 x $shareSize ~= 139.58

So with rounding you would get 240pts this time.

-- Graydon

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.