Re: Toc with counter

classic Classique list Liste threaded Arborescence
1 message Options
Répondre | Arborescence
Ouvrir ce message en vue arborescente
|

Re: Toc with counter

Schneidy
Mes excuses. Ne pas tenir compte du message (erreur de liste).
Cdt,
Pierre

2018-07-02 17:07 GMT+02:00 Pierre Perol-Schneider <[hidden email]>:
Hi All,

I'd like to add a counter (LSR 543) in a table of content.
However, when 'tocItemWithDotsMarkup is set, counter shows only pairs.
Any idea how to solve this ?

Snippet :

%%%%
\version "2.19.82" %% or 2.18

%%% Counter defs
% => http://lsr.di.unimi.it/LSR/Item?id=543

#(define counter-alist '())

#(define-markup-command (counter layout props name) (string?)
  "Increases and prints out the value of the given counter named @var{name}.
  If the counter does not yet exist, it is initialized with 1."
  (let* ((oldval (assoc-ref counter-alist name))
         (newval (if (number? oldval) (+ oldval 1) 1)))
  (set! counter-alist (assoc-set! counter-alist name newval))
  (interpret-markup layout props
    (markup (number->string newval)))))

#(define-markup-command (setcounter layout props name value) (string? number?)
  "Set the given counter named @var{name} to the given @var{value} and prints
  out the value. The counter does not yet have to exist."
  (set! counter-alist (assoc-set! counter-alist name (- value 1)))
  (interpret-markup layout props (make-counter-markup name)))

%% Test:

\book {
  \bookpart {
    \markuplist \table-of-contents
    \paper {
      %% comment the following line:
      tocItemMarkup = \tocItemWithDotsMarkup
    }
  }
  \bookpart {
    \tocItem \markup { "Étude" \counter #"counter" }
    { c' }
  }
  \bookpart {
    \tocItem \markup { "Étude" \counter #"counter" }
    { c' }
  }
  \bookpart {
    \tocItem \markup { "Étude" \counter #"counter" }
    { c' }
  }
}
%%%%

TIA, cheers,
Pierre


_______________________________________________
liste de diffusion lilypond-user-fr
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr