verse/paragraph numbers in PDF (like in HTML)
authorJan Szejko <janek37@gmail.com>
Thu, 12 Jan 2017 14:01:55 +0000 (15:01 +0100)
committerJan Szejko <janek37@gmail.com>
Thu, 12 Jan 2017 14:01:55 +0000 (15:01 +0100)
librarian/pdf.py
librarian/pdf/wl.cls

index 246fd0c..c8af03b 100644 (file)
@@ -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)
index fcb3656..55d4897 100644 (file)
@@ -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