2 runs in creating pdf reports
authorMarcin Koziej <marcin@koziej.info>
Mon, 17 Mar 2014 12:04:30 +0000 (13:04 +0100)
committerMarcin Koziej <marcin@koziej.info>
Mon, 17 Mar 2014 12:04:30 +0000 (13:04 +0100)
librarian/pdf.py
librarian/pdf/fnprep.cls
scripts/book2pdf

index b619f1d..5df8dad 100644 (file)
@@ -209,7 +209,7 @@ def package_available(package, args='', verbose=False):
 
 
 def transform(wldoc, verbose=False, save_tex=None, save_texml=None, morefloats=None,
-              cover=None, cover_file=None, flags=None, customizations=None, documentclass='wl', resources=None):
+              cover=None, cover_file=None, flags=None, customizations=None, documentclass='wl', resources=None, tworuns=False):
     """ produces a PDF file with XeLaTeX
 
     wldoc: a WLDocument
@@ -315,12 +315,13 @@ def transform(wldoc, verbose=False, save_tex=None, save_texml=None, morefloats=N
         if resources:
             os.putenv("TEXINPUTS", "::.:%s" % resources)
 
-        if verbose:
-            p = call(['xelatex', tex_path])
-        else:
-            p = call(['xelatex', '-interaction=batchmode', tex_path], stdout=PIPE, stderr=PIPE)
-        if p:
-            raise ParseError("Error parsing .tex file")
+        for run in range(1 + (tworuns and 1 or 0)):
+            if verbose:
+                p = call(['xelatex', tex_path])
+            else:
+                p = call(['xelatex', '-interaction=batchmode', tex_path], stdout=PIPE, stderr=PIPE)
+            if p:
+                raise ParseError("Error parsing .tex file")
 
         if cwd is not None:
             os.chdir(cwd)
index dbd11c4..c413272 100644 (file)
@@ -251,7 +251,7 @@ Mapping=tex-text
 \makeatother
 
 \nochapternumbers
-\startcontents[chapter]
+%\startcontents[chapter] % ??? XXX
 
 \newcommand{\chapterblock}[1]{%
 \clearpage%
@@ -263,7 +263,7 @@ Mapping=tex-text
 \begin{minipage}[t][\dimexpr\textheight-28pt\relax]{\dimexpr\szpaltawidth-5mm\relax}%
 \Huge{}\headfont\color{white}#1%
 \vspace{\dimexpr21mm-11mm\relax}%
-\par{\printcontents[chapter]{}{1}{}}
+\par{\color{white}\printcontents[chapter]{}{1}{}}
 \end{minipage}%(testing)%\rule{0.1pt}{\baselineskip}%
 \hspace{2.5mm}}%
 \vspace{\dimexpr-\parskip-11pt\relax}%
@@ -518,7 +518,7 @@ Mapping=tex-text
 \renewcommand*\contentsname{Spis treÅ›ci}
 \newcommand{\spistresci}{
 {
-  \setcounter{tocdepth}{0}
+%  \setcounter{tocdepth}{0}
   \tableofcontents
   \newpage
 }
index cda7381..d4597fc 100755 (executable)
@@ -29,6 +29,8 @@ class Book2Pdf(Book2Anything):
                help='LaTeX document class options'),
         Option('-e', '--cover-file', dest='cover_file', metavar='FILE',
                help='Cover image file'),
+        Option('-2', '--two-runs', dest='tworuns', action='store_true', default=False,
+               help='two runs of (Xe)Latex'),
     ]