From: Julien Rioux Date: Thu, 21 Feb 2013 20:35:25 +0000 (-0500) Subject: lilypond-book: Use 550.0 as textwidth when autodetection fails. X-Git-Tag: release/2.17.17-1~23 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e375bc55aea13a75a7ee56248703c30108c25d57;p=lilypond.git lilypond-book: Use 550.0 as textwidth when autodetection fails. --- diff --git a/python/book_latex.py b/python/book_latex.py index e1eda89983..8d2104b08d 100644 --- a/python/book_latex.py +++ b/python/book_latex.py @@ -166,12 +166,13 @@ LATEX_INSPECTION_DOCUMENT = r''' # Do we need anything else besides `textwidth'? def get_latex_textwidth (source, global_options): + # default value + textwidth = 550.0 + m = re.search (r'''(?P\\begin\s*{document})''', source) if m == None: warning (_ ("cannot find \\begin{document} in LaTeX document")) - - ## what's a sensible default? - return 550.0 + return textwidth preamble = source[:m.start (0)] latex_document = LATEX_INSPECTION_DOCUMENT % {'preamble': preamble} @@ -239,12 +240,22 @@ def get_latex_textwidth (source, global_options): if m: columnsep = float (m.group (1)) - textwidth = 0 m = re.search ('textwidth=([0-9.]+)pt', parameter_string) if m: textwidth = float (m.group (1)) - if columns: - textwidth = (textwidth - columnsep) / columns + else: + warning (_ ("cannot detect textwidth from LaTeX")) + return textwidth + + debug ('Detected values:') + debug (' columns = %s' % columns) + debug (' columnsep = %s' % columnsep) + debug (' textwidth = %s' % textwidth) + + if m and columns: + textwidth = (textwidth - columnsep) / columns + debug ('Adjusted value:') + debug (' textwidth = %s' % textwidth) return textwidth