From: "Peña, Botp" Date: 2007-03-09T15:21:58+09:00 Subject: Re: rjust alignment On Behalf Of Ross: # I think I'm going crazy. I tried to write a fairly simple program to relax. # toc.pages[x].rjust(lineWidth + offset + (10 - toc.pages[x].length)) toc.pages[x].rjust(offset+10) #<-try this first suggest to take a second look to #just... it rjusts the whole string. subtraction not needed :) sample output should then be, C:\family\ruby>cat -n test.rb 1 class TableOfContents 2 attr_accessor :chapters, :topics, :pages 3 end 4 5 toc = TableOfContents.new 6 toc.chapters = ["Chapter 1", "Chapter 2", "Chapter 3"] 7 toc.topics = ["Numbers", "Letters", "Variables"] 8 toc.pages = ["Page 1", "Page 57", "Page 117"] 9 10 lineWidth = 20 11 3.times do |x| 12 offset = toc.chapters[x] + ": " + toc.topics[x] 13 offset = 40 - offset.length 14 puts toc.chapters[x] + ": " + toc.topics[x] + 15 toc.pages[x].rjust(offset) 16 #toc.pages[x].rjust(offset+10,"x") 17 end C:\family\ruby>ruby test.rb Chapter 1: Numbers Page 1 Chapter 2: Letters Page 57 Chapter 3: Variables Page 117 C:\family\ruby> btw, i'd suggest you put "Chapter", and "Page" as headers, like so, Chapter Page 1: Numbers 1 2: Letters 57 3: Variables 117 kind regards -botp