Hello,
I have hacked lilypond-book such that it supports pdflatex, too. It's
probable that I made some errors, because I don't know any python.
Nevertheless I can now produce a song book in PDF with hyperlinks, now.
I didn't care about the inline music, so this is almost surely broken
for PDF.
I've attached a diff with the lilypond-book that came with 1.4.10.
If it is of any use, feel free to include, extend, or modify it.
To use the pdf-part provide the option -fpdflatex. It should produce
a file *.pdflatex in this, which can be feed to pdflatex.
Best regards
Thomas
--
http://www.thomas.willhalm.de/
*** linux/bin/lilypond-book Mon Feb 18 15:25:42 2002
--- /usr/local/bin/lilypond-book Tue Jan 8 15:18:38 2002
***************
*** 365,371 ****
'letterpaper': {12: in2pt(6)}}
option_definitions = [
! ('EXT', 'f', 'format', 'set format. EXT is one of texi, latex and pdflatex.'),
('DIM', '', 'default-music-fontsize', 'default fontsize for music. DIM is
assumed to be in points'),
('DIM', '', 'default-lilypond-fontsize', 'deprecated, use
--default-music-fontsize'),
('DIM', '', 'force-music-fontsize', 'force fontsize for all inline lilypond. DIM
is assumed be to in points'),
--- 365,371 ----
'letterpaper': {12: in2pt(6)}}
option_definitions = [
! ('EXT', 'f', 'format', 'set format. EXT is one of texi and latex.'),
('DIM', '', 'default-music-fontsize', 'default fontsize for music. DIM is
assumed to be in points'),
('DIM', '', 'default-lilypond-fontsize', 'deprecated, use
--default-music-fontsize'),
('DIM', '', 'force-music-fontsize', 'force fontsize for all inline lilypond. DIM
is assumed be to in points'),
***************
*** 406,433 ****
'output-tex': '{\\preLilypondExample \\input %(fn)s.tex
\\postLilypondExample\n}',
'pagebreak': r'\pagebreak',
},
- 'pdflatex': {
- 'output-lilypond-fragment' : r"""\begin[pdf,singleline,%s]{lilypond}
- \context Staff <
- \context Voice{
- %s
- }
- >
- \end{lilypond}""",
- 'output-filename' : r'''
-
- \verb+%s+:''',
- 'output-lilypond': r"""\begin[%s]{lilypond}
- %s
- \end{lilypond}""",
- 'output-verbatim': "\\begin{verbatim}%s\\end{verbatim}",
- 'output-default-post': "\\def\postLilypondExample{}\n",
- 'output-default-pre': "\\def\preLilypondExample{}\n",
- 'usepackage-graphics': '\\usepackage{graphics}\n',
- 'output-eps':
'\\noindent\\parbox{\\lilypondepswidth{%(fn)s.eps}}{\includegraphics{%(fn)s.pdf}}',
- 'output-tex': '{\\preLilypondExample \\input %(fn)s.pdftex
\\postLilypondExample\n}',
- 'pagebreak': r'\pagebreak',
- },
'texi' : {'output-lilypond': """@lilypond[%s]
%s
@end lilypond
--- 406,411 ----
***************
*** 495,519 ****
'singleline-comment': r"(?m)^.*?(?P<match>(?P<code>^%.*$\n+))",
'numcols': r"(?P<code>\\(?P<num>one|two)column)",
},
- 'pdflatex': {'input': r'(?m)^[^%\n]*?(?P<match>\\mbinput{?([^}\t \n}]*))',
- 'include':
r'(?m)^[^%\n]*?(?P<match>\\mbinclude{(?P<filename>[^}]+)})',
- 'option-sep' : ',\s*',
- 'header': r"\\documentclass\s*(\[.*?\])?",
- 'geometry':
r"^(?m)[^%\n]*?\\usepackage\s*(\[(?P<options>.*)\])?\s*{geometry}",
- 'preamble-end': r'(?P<code>\\begin{document})',
- 'verbatim': r"(?s)(?P<code>\\begin{verbatim}.*?\\end{verbatim})",
- 'verb': r"(?P<code>\\verb(?P<del>.).*?(?P=del))",
- 'lilypond-file':
r'(?m)^[^%\n]*?(?P<match>\\lilypondfile\s*(\[(?P<options>.*?)\])?\s*\{(?P<filename>.+)})',
- 'lilypond' :
r'(?m)^[^%\n]*?(?P<match>\\lilypond\s*(\[(?P<options>.*?)\])?\s*{(?P<code>.*?)})',
- 'lilypond-block':
r"(?sm)^[^%\n]*?(?P<match>\\begin\s*(\[(?P<options>.*?)\])?\s*{lilypond}(?P<code>.*?)\\end{lilypond})",
- 'def-post-re': r"\\def\\postLilypondExample",
- 'def-pre-re': r"\\def\\preLilypondExample",
- 'usepackage-graphics': r"\usepackage{graphics}",
- 'intertext': r',?\s*intertext=\".*?\"',
- 'multiline-comment': no_match,
- 'singleline-comment': r"(?m)^.*?(?P<match>(?P<code>^%.*$\n+))",
- 'numcols': r"(?P<code>\\(?P<num>one|two)column)",
- },
# why do we have distinction between @mbinclude and @include?
--- 473,478 ----
***************
*** 730,736 ****
if __main__.format == 'texi':
scan_texi_preamble(chunks)
else:
! assert __main__.format == 'latex' or __main__.format == 'pdflatex'
scan_latex_preamble(chunks)
--- 689,695 ----
if __main__.format == 'texi':
scan_texi_preamble(chunks)
else:
! assert __main__.format == 'latex'
scan_latex_preamble(chunks)
***************
*** 843,849 ****
return [('lilypond', m.group('code'), options)]
def do_columns(m):
! if __main__.format != 'latex' and __main__.format != 'pdflatex':
return []
if m.group('num') == 'one':
return [('numcols', m.group('code'), 1)]
--- 802,808 ----
return [('lilypond', m.group('code'), options)]
def do_columns(m):
! if __main__.format != 'latex':
return []
if m.group('num') == 'one':
return [('numcols', m.group('code'), 1)]
***************
*** 946,955 ****
basename = basename + "-%i" % taken_file_names[basename]
if not g_read_lys:
update_file(file_body, os.path.join(g_outdir, basename) + '.ly')
! if format == 'pdflatex':
! needed_filetypes = ['pdftex']
! else:
! needed_filetypes = ['tex']
if format == 'texi':
needed_filetypes.append('eps')
--- 905,911 ----
basename = basename + "-%i" % taken_file_names[basename]
if not g_read_lys:
update_file(file_body, os.path.join(g_outdir, basename) + '.ly')
! needed_filetypes = ['tex']
if format == 'texi':
needed_filetypes.append('eps')
***************
*** 968,975 ****
todo = []
if 'tex' in needed_filetypes and f(pathbase, '.ly', '.tex'):
todo.append('tex')
- if 'pdftex' in needed_filetypes and f(pathbase, '.ly', '.pdftex'):
- todo.append('pdftex')
if 'eps' in needed_filetypes and f(pathbase, '.tex', '.eps'):
todo.append('eps')
if 'png' in needed_filetypes and f(pathbase, '.eps', '.png'):
--- 924,929 ----
***************
*** 994,1006 ****
if format == 'latex':
if 'eps' in opts:
s = 'output-eps'
! else:
s = 'output-tex'
! else:
! if format == 'pdflatex':
! s = 'output-tex'
! else: # format == 'texi'
! s = 'output-all'
newbody = newbody + get_output (s) % {'fn': basename }
return ('lilypond', newbody, opts, todo, basename)
--- 948,957 ----
if format == 'latex':
if 'eps' in opts:
s = 'output-eps'
! else:
s = 'output-tex'
! else: # format == 'texi'
! s = 'output-all'
newbody = newbody + get_output (s) % {'fn': basename }
return ('lilypond', newbody, opts, todo, basename)
***************
*** 1076,1085 ****
#ugh
if base + '.ly' not in tex:
tex.append (base + '.ly')
- elif e == 'pdftex':
- #ugh
- if base + '.ly' not in tex:
- tex.append (base + '.ly')
elif e == 'png' and g_do_pictures:
png.append (base)
d = os.getcwd()
--- 1027,1032 ----
***************
*** 1099,1108 ****
if g_outdir:
lilyopts = lilyopts + '--dep-prefix=' + g_outdir + '/'
texfiles = string.join (tex, ' ')
! if __main__.format != 'pdflatex':
! system ('lilypond --header=texidoc %s %s' % (lilyopts, texfiles))
! else :
! system ('lilypond --header=texidoc -fpdftex %s %s' % (lilyopts,
texfiles))
#
# Ugh, fixing up dependencies for .tex generation
--- 1046,1052 ----
if g_outdir:
lilyopts = lilyopts + '--dep-prefix=' + g_outdir + '/'
texfiles = string.join (tex, ' ')
! system ('lilypond --header=texidoc %s %s' % (lilyopts, texfiles))
#
# Ugh, fixing up dependencies for .tex generation