]> git.donarmstrong.com Git - lilypond.git/commitdiff
Roman numerals may be used for page numbers
authorValentin Villenave <valentin@villenave.net>
Wed, 15 Oct 2014 20:13:03 +0000 (22:13 +0200)
committerValentin Villenave <valentin@villenave.net>
Wed, 15 Oct 2014 21:42:11 +0000 (23:42 +0200)
This patch builds on the number-format function used for
string numbers and enables it for page numbers, through
a new 'page-number-type paper property. Previously,
a custom markup function had to be used as demonstrated
in the bookparts.ly regtest, which has now been rewritten
to make use of the new property.

Documentation/changes.tely
Documentation/notation/spacing.itely
input/regression/bookparts.ly
ly/paper-defaults-init.ly
scm/define-markup-commands.scm
scm/titling.scm

index 1dd439dfb0b601b2d7f85e9830d3a8abd4885023..467f5a30ca34d73d10bc00552ad973e805247add 100644 (file)
@@ -61,6 +61,10 @@ which scares away people.
 
 @end ignore
 
+@item
+Page numbers may now be printed in roman numerals, by setting the
+@code{page-number-type} paper variable.
+
 @item
 It is now possible to use @code{\time} and @code{\partial}
 together to change the time signature in mid measure.
index e90d71a45f9b52460f8b6f7c875ca5bb4b70783f..1cded7566af4e6d379f2c0ba73656300e7029b97 100644 (file)
@@ -991,6 +991,14 @@ If set to true, a page number is printed on the first page.
 
 If set to false, page numbers are not printed.
 
+@cindex page numbers in roman numerals
+@item page-number-type
+@funindex page-number-type
+
+The type of numerals used for page numbers.  Choices include
+@code{roman-lower}, @code{roman-upper} and @code{arabic}.
+Default: @code{'arabic}.
+
 @end table
 
 @seealso
index 52660c9312e8c1e57302c426308344b1e4173528..7ee4cf168398d38d3e1f5823ac670c9bc7d626a6 100644 (file)
@@ -10,10 +10,6 @@ Page labels are also collected into the top-level paper."
 
 #(set-default-paper-size "a6")
 
-#(define-markup-command (roman-page-number layout props) ()
-  (let ((page-number (chain-assoc-get 'page:page-number props)))
-    (interpret-markup layout props (format #f "~@r" page-number))))
-
 \book {
   \tocItem \markup "First part"
   \header { title = "Book with several parts" }
@@ -25,8 +21,17 @@ Page labels are also collected into the top-level paper."
       left-margin = 20\mm
       right-margin = 20\mm
       line-width = 65\mm
-      evenHeaderMarkup = \markup \fill-line { \roman-page-number "SECOND PART" \null }
-      oddHeaderMarkup = \markup \fill-line { \null "SECOND PART" \roman-page-number }
+      page-number-type = #'roman-upper
+      evenHeaderMarkup = \markup \fill-line {
+        \fromproperty #'page:page-number-string
+        "SECOND PART"
+        \null
+      }
+      oddHeaderMarkup = \markup \fill-line {
+        \null
+        "SECOND PART"
+        \fromproperty #'page:page-number-string
+      }
     }
     \tocItem \markup "Second part"
     \markup \justify { Second part, with different margins and page header. }
index ef7419312271c1de3f975c10be5d375c6889ab56..398b5ac941eea8811f09e47219846191cb20e8f1 100644 (file)
   first-page-number = #1
   print-first-page-number = ##f
   print-page-number = ##t
+  page-number-type = #'arabic
 
   %%
   %% Headers, footers, and titles
index 467ccba7e13ed19399a98c58530b638bf070742b..20990a73857726918a575ff3a6e9f22f64e19a42 100644 (file)
@@ -1374,8 +1374,8 @@ equivalent to @code{\"fi\"}.
   "Perform simple wordwrap, return stencil of each line."
   (define space (if justify
                     ;; justify only stretches lines.
-                   (* 0.7 base-space)
-                   base-space))
+                    (* 0.7 base-space)
+                    base-space))
   (define (stencil-len s)
     (interval-end (ly:stencil-extent s X)))
   (define (maybe-shift line)
@@ -4231,7 +4231,11 @@ a column containing several lines of text.
 Reference to a page number.  @var{label} is the label set on the referenced
 page (using the @code{\\label} command), @var{gauge} a markup used to estimate
 the maximum width of the page number, and @var{default} the value to display
-when @var{label} is not found."
+when @var{label} is not found.
+
+(If the current book or bookpart is set to use roman numerals for page numbers,
+the reference will be formatted accordingly -- in which case the @var{gauge}'s
+width may require additional tweaking.)"
   (let* ((gauge-stencil (interpret-markup layout props gauge))
          (x-ext (ly:stencil-extent gauge-stencil X))
          (y-ext (ly:stencil-extent gauge-stencil Y)))
@@ -4244,7 +4248,10 @@ when @var{label} is not found."
                        (page-number (if (list? table)
                                         (assoc-get label table)
                                         #f))
-                       (page-markup (if page-number (format #f "~a" page-number) default))
+                       (number-type (ly:output-def-lookup layout 'page-number-type))
+                       (page-markup (if page-number
+                                        (number-format number-type page-number)
+                                        default))
                        (page-stencil (interpret-markup layout props page-markup))
                        (gap (- (interval-length x-ext)
                                (interval-length (ly:stencil-extent page-stencil X)))))
index 41a32dd4672b19c0658119de1b4c3b7ee42b1637..a29bdd25b607817b5a8885743f51cc5898bb153e 100644 (file)
@@ -48,6 +48,7 @@ variables set in @var{scopes} and @code{page:is-bookpart-last-page},
                                (cdr entry)))
                             alist))
                      alists))
+               (number-type (get 'page-number-type))
                (pgnum-alist
                 (list
                  (cons 'header:tagline
@@ -56,7 +57,7 @@ variables set in @var{scopes} and @code{page:is-bookpart-last-page},
                  (cons 'page:is-last-bookpart is-last-bookpart)
                  (cons 'page:is-bookpart-last-page is-bookpart-last-page)
                  (cons 'page:page-number-string
-                       (number->string page-number))
+                       (number-format number-type page-number))
                  (cons 'page:page-number page-number)))
                (props (append
                        (list pgnum-alist)