Monday, April 28, 2008

Aligning columns of numbers

A reader wrote to me last week with the following question:

"I am working on a financial report. The client has requested to have all commas line up as well as $ signs and keeping numbers right justified. I can't seem to do all three. I can get the number data right justified, and the dollar signs to match on a column but not the commas. Any suggestions?"

Upon further investigation, what she was encountering was this:

The commas don't line up because the typeface (Cambria Regular) is an OpenType typeface that supports proportional numerals. In other words, each numeral is a different width (the numeral one is narrower than the numeral eight for example). Most typefaces contain only tabular (equal width) numerals, so this isn't usually a problem.

Luckily, some OpenType fonts contain both proportional and tabular numerals, and InDesign and Illustrator allow you to choose which numeral style you want. Use the proportional numeral style to improve the spacing of numbers wherever possible, and switch to tabular numeral style to make columns of numbers align, as shown below.

To switch between tabular and proportional figures in InDesign, select the text with the Type tool, and choose OpenType > Tabular Lining/Proportional Lining from the Control panel menu. In Illustrator, display the OpenType panel (Window > Type > OpenType), and choose either Tabular Lining or Proportional Lining for the "Position".

To align the dollar signs in the example above, I inserted a "Figure Space" (Type > Insert White Space > Figure Space) in InDesign after the dollar sign on the last line. A figure space is the same width as a numeral when you are using Tabular figure alignment.

11 comments:

Teresa said...

Hi,
I'm using open type fonts such as Minion Pro that offer tabular lining, yet I cannot get the results you show. What am I not doing correctly?
Thanks,
Teresa

Keith Gilbert said...

@Teresa: This works great with Minion Pro. Tell me more details about what you've done/not done, and maybe I can help you out.

Teresa said...

Hi, Keith. I have a basic directory with three columns (col1, condo #; col2, name; col3, phone number...some include area codes but most do not). Col1 is left aligned. Col2 is regular tab stop (I didn't set the tab). Col3 is flush right (shift+tab). I change the font to Myriad Pro. Go to OpenType and select Tabular Lining. Nothing changes. I change the font to Minion Pro. Nothing changes. I set Col2 with left tab and Col3 with right tab. Nothing changes. I set Col3 with left tab. Nothing changes. I try other fonts that include Tabular Lining. Nothing changes. If you can figure this out, I'll owe you a donut. :o)

Keith Gilbert said...

@Teresa: Tabular lining should work with both Myriad Pro and Minion Pro, regardless of the type of tab stop. I can't quite see what might be going on. When you choose Tabular Lining, it doesn't appear in the menu with square brackets around it, like [Tabular Lining] does it?

Teresa said...

Nope.

Keith Gilbert said...

@Teresa, I'm starting to wonder if your InDesign Preferences file is corrupt. Try following the steps at http://blog.gilbertconsulting.com/2007/07/deleting-preference-files.html and see if the problem persists.

Teresa said...

Thank you for your help. Over a year ago, I created a copy of the basic paragraph style and used it as my default for quite some time without problems. After creating the new preference file, my problem text still didn’t change when I selected tabular lining. I created a new file using the same font as the problem file and all worked fine. So I did some copying and pasting between documents and found the problem text remained unchanged in both the old and new documents and the newly created text was correct in both. Then I checked the styles used and found the basic paragraph style corrected the problem text and the basic paragraph copy style created the problem. I don’t know why I didn’t think about a corrupt preference file. Maybe because I’ve only had that problem once since I began using InDesign when it was first released. Thanks again. Headache solved...except for recreating my styles.

Anonymous said...

"@Teresa: Tabular lining should work with both Myriad Pro and Minion Pro, regardless of the type of tab stop. I can't quite see what might be going on. When you choose Tabular Lining, it doesn't appear in the menu with square brackets around it, like [Tabular Lining] does it?"

What do [these] mean when this does happen?

Keith Gilbert said...

@Anonymous: The square brackets [] around a type style or menu choice means that that type style or menu choice is not available. So if you select Zapf Dingbats, and then try to choose OpenType > Proportional Oldstyle, you'll see that option will have brackets around it, because Zapf Dingbats doesn't offer Proportional Oldstyle numerals.

Anonymous said...

Is there a way to modify a font's attributes? I.e the font Agenda doesn't offer tabular lining, yet I would like to add this attribute to the font manually. Is this possible to do by code perhaps?

/t

Keith Gilbert said...

@Anonymous, the only practical way to modify a fonts attributes is with font editing software such as Fontographer or Fontlab Studio. Not a simple proposition.