[cl-typesetting-devel] How to make some text flush left and someflush right?

Peter Seibel peter at gigamonkeys.com
Thu Jul 20 16:02:39 UTC 2006


On Jul 19, 2006, at 10:35 PM, Dmitriy Ivanov wrote:

> Hello Peter,
>
> | Suppose I want to make a header that has a chapter name on the left
> | and a page number on the right like this:
> |
> |   +--------------------------------------------------------------+
> |>   Chapter One                                         p. 1   |
> |   |                                                              |
> |>   Normal text here blah blah blah. The quick brown fox       |
> |>   jumps over the lazy dog ...                                |
> |   |                                                              |
> |
> | In the past I've built a table but that requires knowing the  
> width of
> | the page and computing the width of various pieces of text. It seems
> | like there ought to be a simple way to say, make a box containing
> | "Chapter One" that is sized to it's natural size, another box
> | containing nothing that expands to fill available space, and a third
> | containing "p. 1", also sized to it's natural size and then lay  
> those
> | three boxes out in a horizontal line to get the effect I want. Is
> | there any easy way to do that?
>
> I would suggest using a function as the header argument of draw- 
> pages. Here
> is an excerpt specifying the footer in such a way.

So using a function is what allows the header to differ a bit each  
time (i.e. the different page number) but isn't necessary for the  
layout part--for that I just needed :hfill which I didn't know about.  
However now I have a new puzzle. Here's my call to draw-pages:

   (draw-pages content
	      :size :Letter
	      :margins '(72 72 72 72) ; left top  right bottom
	      :header-top 36
	      :footer-bottom 36
	      :header (compile-text (:font "Times-Italic" :font-size 10)
			(hbox (:align :center :adjustable-p t)
			  (put-string "Header")
			  :hfill
			  (put-string "Page number")))
	      :footer (compile-text ()
			(paragraph
			    (:h-align :left :font "Times-Italic" :font-size 10)
			  (put-string "Footer")))))

This works fine except there's a lot of spacing between the letters  
in "Header" and "Page number" but not between the characters of  
"Footer". I assume that's due to some difference between the hbox  
used in the header and the paragraph used in the footer, but how do I  
get rid of the weird spacing.

-Peter

-- 
Peter Seibel           * peter at gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/





More information about the cl-typesetting-devel mailing list