Re: Cross-referencing
From: "William D. Lindsey" <[email protected]>
Date: Sun, 30 Mar 1997 15:47:30 -0700
Matthias Clasen writes:
>
[ ...stuff ...]
>
> I.e. I want the `of ' part in proof to be omitted, if it is immediately
> following the theorem. So the task is to determine if the node
> immediately
> before the `proof' element is the one the `of' attribute is referring
> to.
[ ... more stuff ...]
>
>
> 1) Is my idea correct ?
>
> 2) Is there a way to do it within the current limitations of Jade ?
>
> 3) All these questions about cross-referencing made me remember a
> Latex-style called varioref which allows `intelligent pagereferences'
> which print out
> text like `on this page', `on the next page', `on the previous page'.
> It
> might even be aware if the reference and the referent are on one
> spread
> or not.
Here's a workaround for jade which I used for a problem similar
to yours. I'm sure there are better ways ...
This doesn't address your third question about "intelligent
pagereferences" which would involve indirect sosofos (see 12.5.1
in the standard).
Your code, with one small change:
(element PROOF
(make paragraph
(make sequence
(if (equal? (attribute-string "OF")
(attribute-string "ID"
(my-preced (current-node))))
;; was (attribute-string "ID" (ipreced)))
; proof directly following theorem, omit number
(literal "Proof:" )
; proof not directly following theorem
(with-mode theorem
(process-element-with-id
(attribute-string "OF"))))
(process-children))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; my-preced : substitute for ipreced in jade-0.5
;; different from ipreced in that it works on a singleton node list.
;;
;; returns the preceding sibling element or empty node list if
;; this is the first child.
;;
(define (my-preced snl)
(let loop ((scanned (empty-node-list))
(rest (siblings snl)))
(cond ((node-list-empty? rest)
(empty-node-list))
((node-list=? (node-list-first rest) snl)
scanned)
(else
(loop (node-list-first rest)
(node-list-rest rest))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; a couple of necessary utilities
;;
;; 1) get the list of sibling elements (assumes origin == parent,
;; in other words we're content)
;;
(define (siblings snl)
(children (parent snl)))
;;
;; 2) (empty-node-list)
;;
;; this doesn't seem to have been supplied with jade, so we go find
;; an empty node list at the tail of the current-node node-list.
;;
(define (empty-node-list)
(let loop ((enl (current-node)))
(if (node-list-empty? enl)
enl
(loop (node-list-rest enl)))))
Hope this helps,
-Bill
--
William D. Lindsey
[email protected]
+1 (303) 672-8954
|