[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|