From f4cbb15b0bcd2b876872983238a1656fbd990700 Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Mon, 17 Mar 2014 13:04:30 +0100 Subject: [PATCH 1/1] 2 runs in creating pdf --- librarian/pdf.py | 15 ++++++++------- librarian/pdf/fnprep.cls | 6 +++--- scripts/book2pdf | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/librarian/pdf.py b/librarian/pdf.py index b619f1d..5df8dad 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -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) diff --git a/librarian/pdf/fnprep.cls b/librarian/pdf/fnprep.cls index dbd11c4..c413272 100644 --- a/librarian/pdf/fnprep.cls +++ b/librarian/pdf/fnprep.cls @@ -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 } diff --git a/scripts/book2pdf b/scripts/book2pdf index cda7381..d4597fc 100755 --- a/scripts/book2pdf +++ b/scripts/book2pdf @@ -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'), ] -- 2.20.1