lilypond-devel
[Top][All Lists]

Re: [Spam:SpamScore 16.1] Re: extending \lilypondfile was: Re: Extractin

 From: Michael Haynie Subject: Re: [Spam:SpamScore 16.1] Re: extending \lilypondfile was: Re: Extracting header fields for use by e.g. LaTeX? Date: Tue, 13 Dec 2005 23:32:28 -0500

Glad to hear you were only _distracted_ by the events at Hemel Hempstead.
```
Thanks for the script.

```
I've been trying to test it, but I'm stuck. The problem may be the result of a change between 2.6.x and 2.7.x or bad configuration on my part. The script complains about an undefined variable, print-score-with-defaults. That word is mentioned in the generated lilyK*.ly file, but I can't find a definition, though. Any ideas?
```

The execution trace follows:

% lilypond-macros -f latex -V --psfonts working.ltx
lilypond_binary is lilypond
lilypond-macros (GNU LilyPond) 2.7.21
```
Invoking `latex tmpVa0Kzy.tex'This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
```entering extended mode
(./tmpVa0Kzy.tex
LaTeX2e <2003/12/01>
```
Babel <v3.8d> and hyphenation patterns for american, french, german, ngerman, b ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto, e stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk, polis h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish, tur
```kish, ukrainian, nohyphenation, loaded.

(/sw/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/sw/share/texmf-dist/tex/latex/base/size12.clo))
(/sw/share/texmf-dist/tex/latex/graphics/graphics.sty
(/sw/share/texmf-dist/tex/latex/graphics/trig.sty)
(/sw/share/texmf-dist/tex/latex/graphics/graphics.cfg)
(/sw/share/texmf-dist/tex/latex/graphics/dvips.def))
No file tmpVa0Kzy.aux.
textwidth=390.0pt
columnsep=10.0pt
(./tmpVa0Kzy.aux) )
No pages of output.
Transcript written on tmpVa0Kzy.log.

Dissecting...
Writing snippets...
lilyKAGHGDCBAII-verb1.tex is up to date.
lilyKABBAFJDFFI-verb1.tex is up to date.

Processing...
```
Invoking `lilypond --formats=ps --backend eps -I '/Users/mbh/SheetMusic/booktest' snippet-map.ly lilyKAGHGDCBAII lilyKBBGEFADHC lilyKABBAFJDFFI lilyKAIGDDBADDD'GNU LilyPond 2.6.4
```Processing `snippet-map.ly'
Parsing...
Processing `working.ltx:11 (lilyKAGHGDCBAII.ly)'
```
Parsing...lilyKAGHGDCBAII.ly:1:1: In expression (set! toplevel-score-handler print-score-with-defaults):
```lilyKAGHGDCBAII.ly:1:1: Unbound variable: print-score-with-defaults
lilypond-macros: warning: `lilypond' failed (status 2) (ignored)

```
lilypond-macros: error: Process lilypond --formats=ps --backend eps -I '/Users/mbh/SheetMusic/booktest' snippet-map.ly lilyKAGHGDCBAII lilyKBBGEFADHC lilyKABBAFJDFFI lilyKAIGDDBADDD exited unsuccessfully.
```Removing `working.tex'
Traceback (most recent call last):
```
File "/Applications/LilyPond.app//Contents/Resources/bin/lilypond-macros", line 1670, in ?
```    main ()
```
File "/Applications/LilyPond.app//Contents/Resources/bin/lilypond-macros", line 1653, in main
```    ly.exit (1)
```
File "/Applications/LilyPond.app/Contents/Resources/share/lilypond/current/ python/lilylib.py", line 139, in exit
```    raise _ ('Exiting (%d)...') % i
Exiting (1)...

On Dec 13, 2005, at 5:15 AM, Bernard Hurley wrote:

```
```Sorry, forgot the attachment!

/Bernard

On Tue, 2005-12-13 at 08:55 +0000, Bernard Hurley wrote:
```
```Hi,

I was going to post this stuff on Sunday, however I live in Hemel
```
Hempstead and have been a bit pre-occupied with other things. Here is a
```first attempt at solving the problem.  I might not have much time to
work on this in the near future, but would appreciate any suggestions.

I attach a file called "lilypond-macros" (not a very good name -maybe
```
someone can think of another one). You will have to do a bit of editing to get it working on your system (I think I have documented it enough in the file - if you search for "invisible" you should find the lines that
```need changing).

If you compare the effect of running:

lilypond-book -V --psfonts <name>.lytex

and:

lilypond-macros -V --psfonts <name>.lytex

You will see that l-b substitutes inline code for the embedded LaTeX
code whereas l-m substitutes a call to "\lilyInputSystems". This macro
is contained in a file "<name>.mac" that is "\input" at the top of the
resulting .tex file.

```
From now on "<name>.mac" can be used in _any_ TeX file. You must write:
```
\usepackage{graphics}  %% or: \usepackage{graphicx}
\include <name>.mac

in your preamble. The macros available are:

1] \lilyInputSystems{<song name>}

```
This macro causes the music to be displayed so that it looks identical
```the corresponding inline code generated by l-b. It takes account of
parameters "quote" and "verbatim" if they have been used in the
original .lytex file. The macros below do _not_ do this.

2] \lilyInputSingle{<song name>}{<system number>}

A single system is displayed.

3] \lilyInputRange{<song name>}{<first system>}{<last system>}

a Range of systems is displayed

4] \lilyInputVerbatim{<song name>}

the verbatim lilypond code is displayed

```
At present l-m only finds the _first_ header block in the code. Also the
```macro is fragile so you should write:

not:

Some points:

```
A] The song names are at present generated by l-m etc. and have the form "SongA", "SongB" etc... And you will have to look in the generated .tex
```code to see what they are.

B] The systems are numbered starting from "1". You will obviously have
to turn the generated .tex into .ps or .pdf to find out how many there
are!

```
C] If you are happy with the generated macros you don't actually have to
```run l-m again. You can simply work with .tex

D] At present you cannot "\import" two .mac files into the same LaTeX
```
file. Eventually it should be possible to gnerate libraries of songs for
```use in LaTeX.

e] You don't need all the generated files to use the macros. The ones
you need in addition to the .mac file are:

lilyXXXXXXXXXX-n.eps
lilyXXXXXXXXXX-verb.tex
lilyXXXXXXXXXX-verb1.tex

```
And if you are using the --psfonts option, <name>.psfonts will be needed
```by dvips.

/Bernard

On Sat, 2005-12-10 at 21:37 -0500, Michael Haynie wrote:
```
```OK, I'm back from Alaska.  Sorry for the delay.

```
LaTeX macros with multiple parameters typically separate them with {},
```so it would look like this:

\lilypondfile[options]{filename}{reference}

```
I thought we'd have lilypond-book provide the reference number, so I'm
```not sure what the reference would be, but I suppose that it could be
provided by lilypond-book during the rewrite step.  The rewrite is
```
currently replacing the call with stuff surrounding an \input. I think
```I'd replace the \input with a call to yet another macro to be user
defined, maybe following the \ifx pattern used by pre and post
LilyPondExample.  Something like:

\includeLilypondSystems{reference number}{system count}

```
The user would define includeLilypondSystems to e.g. discard the title,
```print the first system, or whatever.  The main weakness that I see is
```
that users would have to redefine the macro if they need to use several
```definitions in the same book.  I'm not sure I know why one would want
```
to do that, but my need to do my own titles suggests that others might
```need to do similarly odd things.

On Dec 2, 2005, at 8:53 AM, Bernard Hurley wrote:

```
```On Thu, 2005-12-01 at 14:02 +0000, Bernard Hurley wrote:
```
```Hi,

```
This discussion, started on the "user" list. However it now seems more
```appropriate for the "developer". We started discussing how header
fields
might be used in lilypond-book and got on to discussing a possible
extension to \lilypondfile, with an optional extra parameter (As in
\lilypondfile[mysong{song.ly}). It should be possible for anyone
interested to pick it up from here.

```
```Sorry it wouldn't quite work like this. Perhaps something like
\lilypondfile[options]{filename,reference}
would be better
--

```
```
```
```--
```