<newsletter:port_old_newsletter_to_new_system> Merge Colombans changes to make better usage of LaTeX for creating PDF into master
Frank Lanitz
git-noreply at xxxxx
Fri Jun 10 23:36:16 UTC 2011
Updating branch refs/heads/port_old_newsletter_to_new_system
to ae08e90b31a1d94c233cae83b44c4e88211a5e3b (commit)
from 472b8be18364e6d1c2a9904285625b77010252da (commit)
commit ae08e90b31a1d94c233cae83b44c4e88211a5e3b
Merge: 472b8be f1901c8
Author: Frank Lanitz <frank at frank.uvena.de>
Date: Sat Jun 11 01:31:56 2011 +0200
Merge Colombans changes to make better usage of LaTeX for creating PDF into master
commit f1901c86ee14dc49063c3b68d7e8cb1e02df8a33
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Thu May 26 18:56:11 2011 +0200
Place images on a minipage
Because it looks better to be.
commit 45faa66a66cced087fc0b46ef45a78333b12cd5d
Author: Jonathan Michalon <jonathan at michalon.eu>
Date: Thu May 26 18:24:13 2011 +0200
Arrange images in rst2latex generated newsletters
Signed-off-by: Jonathan Michalon <jonathan at michalon.eu>
Signed-off-by: Colomban Wendling <ban at herbesfolles.org>
commit c5af486f6eca2c890c0961617d30f6f6d7726595
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Wed May 25 17:35:30 2011 +0200
Drop latex preamble
It is not supported by rst2latex < 0.7, and we try to remove it anyway.
commit 101c639085fdd78a3e7a9f16065bb1088ef5709a
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Wed May 25 17:26:35 2011 +0200
Correctly report rst2latex failures
commit da6935e81f8c1ade30d766918926e5e25ae85542
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Tue May 24 20:54:45 2011 +0200
Properly forward commands failure (oops)
commit 731e8034e5dc9d4a52ebf9a29950da4d5761df59
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Tue May 24 17:04:34 2011 +0200
Don't fail if one of the temporary files don't exist
commit bf1361a04b754afd2f2d9e4f7b9a33a1bf6cbde8
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Tue May 24 15:48:34 2011 +0200
Try an alternative way to generate PDF
This is a bit ugly since it post-processes rst2latex output with sed,
but the input template isn't totally flexible enough.
Makefile | 20 +++++++++++++++++---
rst2latex.sed | 15 +++++++++++++++
template.tex | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index f272f52..e391b35 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,10 @@ OUTPUTS = $(OUTPUT_HTML) \
$(OUTPUT_ODT) \
$(OUTPUT_TEX)
+PDFLATEX_FLAGS = -interaction batchmode
+RST2LATEX_FLAGS = --template=template.tex \
+ --no-section-numbering
+
.PHONY: all clean html pdf odt tex
.SUFFIXES: .rst .html .pdf .tex .odt
@@ -34,14 +38,24 @@ clean:
.rst.html:
rst2html --stylesheet=style.css --toc-top-backlinks $< > $@
-.rst.pdf:
- rst2pdf $< -o $@
+.tex.pdf:
+ maxpasses=5; \
+ file=`basename $< .tex`; \
+ cd `dirname $<` || exit 1; \
+ pdflatex $(PDFLATEX_FLAGS) "$$file.tex" >/dev/null || exit 1; \
+ while test $$maxpasses -gt 0 && grep -q -i 'rerun' $$file.log; do \
+ pdflatex $(PDFLATEX_FLAGS) "$$file.tex" >/dev/null || exit 1; \
+ maxpasses=`expr $$maxpasses - 1`; \
+ done; \
+ rm -f "$$file.log" "$$file.toc" "$$file.out" "$$file.aux"
.rst.tex:
- rst2latex $< > $@
+ rst2latex $(RST2LATEX_FLAGS) $< > $@ || rm -f $@
+ sed -r -f rst2latex.sed -i $@ || rm -f $@
.rst.odt:
rst2odt $< > $@
# extra dependencies we cannot add to suffix rules
$(OUTPUT_HTML): style.css
+$(OUTPUT_TEX): template.tex rst2latex.sed
diff --git a/rst2latex.sed b/rst2latex.sed
new file mode 100644
index 0000000..ebee787
--- /dev/null
+++ b/rst2latex.sed
@@ -0,0 +1,15 @@
+# sed script to modify rst2latex output
+# this is used to fix a few flaws rst2latex has
+
+# remove \setcounter...{0} to get proper section numbering
+/^\\setcounter.*$/d
+
+# put the TOC on its own page
+/^\\tableofcontents/{
+ n
+ i \\\newpage
+}
+
+# center images and reduce them to something moderated fitting the page
+# also force an empty line before: fixes placement after \paragraph and with previous text
+s/(.*\\includegraphics)(.*)/\\begin{center}\\begin{minipage}[c]{\\linewidth}\\begin{center}\1[width=\\textwidth,height=0.25\\textheight,keepaspectratio=true]\2\\end{center}\\end{minipage}\\end{center}/
diff --git a/template.tex b/template.tex
new file mode 100644
index 0000000..c70223b
--- /dev/null
+++ b/template.tex
@@ -0,0 +1,37 @@
+% generated by Docutils <http://docutils.sourceforge.net/>
+\documentclass[%
+paper=a4,%
+fontsize=12pt,%
+twoside=false,%
+DIV18,
+headsepline,
+plainheadsepline,
+footsepline,
+plainfootsepline,
+parskip=half,%
+openany,%
+english]{scrartcl}
+% $head_prefix
+\usepackage{fixltx2e} % LaTeX patches, \textsubscript
+\usepackage{cmap} % fix search and cut-and-paste in PDF
+\usepackage[pdfborder={0 0 0}]{hyperref}
+$requirements
+%%% Custom LaTeX preamble
+\hypersetup{%
+ colorlinks,
+ linkcolor=black,
+ urlcolor=blue,
+}
+%%% User specified packages and stylesheets
+$stylesheet
+%%% Fallback definitions for Docutils-specific commands
+$fallbacks
+$pdfsetup
+%%% Body
+\begin{document}
+$body_pre_docinfo
+$docinfo
+$dedication
+$abstract
+$body
+\end{document}
More information about the Newsletter-Commits
mailing list