From: Jan Szejko Date: Thu, 12 Jan 2017 14:01:55 +0000 (+0100) Subject: verse/paragraph numbers in PDF (like in HTML) X-Git-Tag: 1.7~65 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/c6d792e73002970964923c0105b1f0c366d744fc?hp=07f1b10113588774b5cc75df100e8487a54b45d2 verse/paragraph numbers in PDF (like in HTML) --- diff --git a/librarian/pdf.py b/librarian/pdf.py index 246fd0c..c8af03b 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -310,12 +310,14 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, cwd = None os.chdir(temp) - 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") + # some things work better when compiled twice + for run in xrange(2): + 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/wl.cls b/librarian/pdf/wl.cls index fcb3656..55d4897 100644 --- a/librarian/pdf/wl.cls +++ b/librarian/pdf/wl.cls @@ -442,14 +442,30 @@ Letters={Uppercase} \par{\emph{#1}}% } +\usepackage{intcalc} +\usepackage{color} +\definecolor{gray}{RGB}{200,200,200} +\newcounter{parnum} +\newlength{\parnumwidth} +\setlength{\parnumwidth}{3em} +\newcommand{\N}{% + \leavevmode\refstepcounter{parnum}\reversemarginpar% + \marginnote{\textcolor{gray}{\small{\theparnum}}}% + \reversemarginpar} +\newcommand{\Nw}{% + \leavevmode\refstepcounter{parnum}\reversemarginpar% + \ifnum\intcalcMod{\value{parnum}}{5}=0% + \marginnote{\textcolor{gray}{\small{\theparnum}}}% + \fi\reversemarginpar} + \newcommand{\akap}[1]{% -\par{#1}% +\par{\N#1}% } \newcommand{\akapdialog}[1]{% -\par{#1}% +\par{\N#1}% } \newcommand{\akapcd}[1]{% -\par{#1}% +\par{\N#1}% } \newcommand{\mottopodpis}[1]{% @@ -464,16 +480,16 @@ Letters={Uppercase} \par{\noindent{\ignorespaces#1\vspace{1em}}}% } -\newcommand{\wers}[1]{#1} +\newcommand{\wers}[1]{\Nw#1} \newcommand{\wersakap}[1]{% -\hspace*{1em}#1% +\Nw\hspace*{1em}#1% } \newcommand{\werscd}[1]{% -\hspace*{8em}#1% +\Nw\hspace*{8em}#1% } \newcommand{\werswciety}[2][1em]{% -\hspace*{#1}#2% +\Nw\hspace*{#1}#2% } \ifshowfootnotes