From a3b6b0e1f38454d90d36aeb6b31363b5e49dc23e Mon Sep 17 00:00:00 2001 From: hanwen Date: Wed, 17 Jul 2002 13:18:59 +0000 Subject: [PATCH] TCA pats --- Documentation/user/lilypond-book.itely | 16 ++++++++++----- VERSION | 2 +- input/test/ancient-font.ly | 2 +- scripts/lilypond-book.py | 28 ++++++++++++++++++++++---- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely index 6e732b9f41..4b01fb20ad 100644 --- a/Documentation/user/lilypond-book.itely +++ b/Documentation/user/lilypond-book.itely @@ -111,11 +111,17 @@ or \lilypond@{ YOUR LILYPOND CODE @} @end example -You can use whatever commands you like in the document preamble. -Lilypond-book will send it to La@TeX{} to find out how wide the text is -and adjust the linewidth variable in the paper definition of you music -according to that. Lilypond-book also know about the @code{\onecolumn} -and @code{\twocolumn} commands. +You can use whatever commands you like in the document preamble, +that is the part of the document before @code{\begin@{document@}}. +@command{lilypond-book} will send it to La@TeX{} to find out how wide +the text is and adjust the linewidth variable in the paper definition of +you music according to that. + +After @code{\begin@{document@}} you must be a little more careful +when you use commands that change the width of the text and how +many columns there are. @command{lilypond-book} know about the +@code{\onecolumn} and @code{\twocolumn} commands and the @code{multicols} +environment from the multicol package. The music will be surrounded by @code{\preLilypondExample} and @code{\postLilypondExample}. The variables are diff --git a/VERSION b/VERSION index 60212ec9f0..2e13323a11 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=68 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=tca2 # Use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/ancient-font.ly b/input/test/ancient-font.ly index 1ca2f408cb..74ed5af99f 100644 --- a/input/test/ancient-font.ly +++ b/input/test/ancient-font.ly @@ -133,7 +133,7 @@ lowerVoice = \context Staff = lowerNotes < \property Staff.KeySignature \set #'font-family = #'ancient \property Staff.KeySignature \override #'style = #'mensural \property Staff.Accidental \set #'font-family = #'ancient - \property Staff.Accidental \override #'style = #'mensural + \property Staff.Accidentalg \override #'style = #'mensural \property Staff.Custos \set #'font-family = #'ancient \property Staff.Custos \override #'style = #'mensural \property Staff.Custos \override #'neutral-position = #3 diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index eebf3ff3f4..a922177558 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -163,6 +163,7 @@ class LatexPaper: def __init__(self): self.m_document_preamble = [] self.m_num_cols = 1 + self.m_multicols = 1 def find_latex_dims(self): if g_outdir: fname = os.path.join(g_outdir, "lily-tmp.tex") @@ -200,10 +201,14 @@ class LatexPaper: except: pass def get_linewidth(self): - if self.m_num_cols == 2: - return (self.m_textwidth-self.m_columnsep)/2 + if self.m_num_cols == 1: + w = self.m_textwidth else: - return self.m_textwidth + w = (self.m_textwidth - self.m_columnsep)/2 + if self.m_multicols > 1: + return (w - self.m_columnsep*(self.m_multicols-1)) \ + / self.m_multicols + return w class HtmlPaper: @@ -444,6 +449,7 @@ re_dict = { 'multiline-comment': r"(?sm)\s*(?!@c\s+)(?P)\s", 'singleline-comment': no_match, 'numcols': no_match, + 'multicols': no_match, }, 'latex': {'input': r'(?m)^[^%\n]*?(?P\\mbinput{?([^}\t \n}]*))', @@ -463,6 +469,7 @@ re_dict = { 'multiline-comment': no_match, 'singleline-comment': r"(?m)^.*?(?P(?P^%.*$\n+))", 'numcols': r"(?P\\(?Pone|two)column)", + 'multicols': r"(?P\\(?Pbegin|end){multicols}({(?P\d+)?})?)", }, @@ -485,6 +492,7 @@ re_dict = { 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P@ignore\s.*?@end ignore)\s", 'singleline-comment': r"(?m)^.*?(?P(?P@c.*$\n+))", 'numcols': no_match, + 'multicols': no_match, } } @@ -807,7 +815,16 @@ def do_columns(m): return [('numcols', m.group('code'), 1)] if m.group('num') == 'two': return [('numcols', m.group('code'), 2)] - + +def do_multicols(m): + if __main__.format != 'latex': + return [] + if m.group('be') == 'begin': + return [('multicols', m.group('code'), int(m.group('num')))] + else: + return [('multicols', m.group('code'), 1)] + return [] + def chop_chunks(chunks, re_name, func, use_match=0): newchunks = [] for c in chunks: @@ -975,6 +992,8 @@ def process_lilypond_blocks(chunks):#ugh rename c = schedule_lilypond_block (c) elif c[0] == 'numcols': paperguru.m_num_cols = c[2] + elif c[0] == 'multicols': + paperguru.m_multicols = c[2] newchunks.append (c) return newchunks @@ -1284,6 +1303,7 @@ def do_file(input_filename): chunks = chop_chunks(chunks, 'singleline-comment', do_ignore, 1) chunks = chop_chunks(chunks, 'preamble-end', do_preamble_end) chunks = chop_chunks(chunks, 'numcols', do_columns) + chunks = chop_chunks(chunks, 'multicols', do_multicols) #print "-" * 50 #for c in chunks: print "c:", c; #sys.exit() -- 2.39.5