Numbering sections (was Scaling inline images)

Subject: Numbering sections (was Scaling inline images)
From: Richard Light <richard@xxxxxxxxxxxxxxxxx>
Date: Thu, 6 Nov 1997 21:51:23 +0000
In message <199711062020.PAA08113@xxxxxxxxxxxxxxxxxxxxxxxx>, Tony Graham
<tgraham@xxxxxxxxxxxxxxxx> writes
> > Because the images are inlined, I assume that there is nothing I can do
> > to make the line wider to accommodate the full-sized image?  (I could
> > make all paragraphs that contain images double-spaced, but that isn't
> > ideal.)
>To answer the second part of your message, set the min-leading
>characteristic to something other than its default of #f.  The line
>spacing will then expand as necessary to accommodate the images.
>(although the cookbook stuff will soon move to under the dsssldoc
>directory (and it could do with contributions)).

Excellent!  Works a treat - thanks.

As a possible cookbook contribution, I've just had to deal with the
situation where sections within a document have to be numbered according
to the familiar 'X.X.X' scheme, but only specified element types 'count'
as contributors to this numbering.  Also, there can be a glorious
mixture of said element types at each level.  Thus (child-number) is no
use, and even counting preceding siblings isn't good enough.

The code I have written uses (node-list-filter), which in turn uses
(node-list-reduce) - these are both printed in the DSSSL standard, but
you need to type them in.  This is the core routine:

; preced-count: gives the number of 'significant' (for numbering)
sibling elements prior to node.
; This routine relies on a specific list of element types, which must
include all elements that
; are numbered:
(define (preced-count node)
                (lambda (n1)
                        (case (gi n1)
                          ((countable-elements) #t)
                          (else #f)
                (preced node)

You need to declare your 'countable elements' as a list of strings:

(define (countable-elements)
 (list "XXX" "YYY" "ZZZ" ...)

Then you add one to the number returned by (preced-count) to get the
correct number for the current element in a (number-clause) routine:

(define (number-clause node top-level)
        (case (gi node)
              (("ROOT-ELEMENT") ; i.e. the gi of your root element
               (if top-level
                   (list (+ (preced-count node) 1))
                   (cons (+ (preced-count node) 1)
                         (number-clause (parent node) top-level)

... which in turn is called by a (number-heading) routine which returns
a formatted string ...

(define (number-heading node top-level)
   (format-number-list (reverse (number-clause node top-level))

... that you can stick in front of the relevant heading:

                (make sequence
                      (number-heading (parent (current-node)) #t)
                      (literal " ")

(This assumes that the heading is a child of the structural element
which is being counted - hence (number-heading) is applied to the
_parent_ of the heading element.)

Is this any help?

Richard Light.

Richard Light
SGML/XML and Museum Information Consultancy

 DSSSList info and archive:

Current Thread