At Thu, 8 Jun 2017 08:55:00 -0700 (PDT), Dupéron Georges wrote:
> Generally it is nice to get the actual section title printed when using
> @secref["mysection"]. However, in some cases it is a bit awkwards:
>
> Chapter State of the art presents related work. Chapter Implementation
> explains in detail how this library is implemented. etc.
>
> I'd rather have something as follows, with the whole "Chapter 2" and "Chapter
> 3" being hyperlinks:
>
> Chapter 2 presents related work. Chapter 3 explains in detail how this
> library
> is implemented. etc.
>
> I can do this easily with @seclink, but I need to hardcode the chapter and
> section numbers. Is there an easy way to access them and automatically inject
> the chapter/section number (e.g. in Scribble's resolution phase)?
There's not a documented way, but a section tag maps to a vector whose
second element is the section's number spec (roughly, a list of
numbers, one for each level of nesting). So, you can use
`delayed-element` like this:
#lang scribble/base
@(require scribble/core)
@title{The Document}
@section[#:tag "sub"]{The Section}
See @(delayed-element
(lambda (r p ri)
(let ([v (resolve-get p ri (make-section-tag "sub"))])
;; Turns '(1) into "(1)" for demo purposes:
(format "~s" (vector-ref v 2))))
(lambda () "x")
(lambda () "x")).
The representation of section information is renderer-specific, but
currently the renderers all use a vector of a least three elements, so
the number spec is always there. Probably that fact should just be
documented and guaranteed forever, although a vector wasn't a great
choice.
[Sorry for the long delay!]
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.