summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2010-04-10 18:59:57 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2010-04-10 18:59:57 +0000
commitc36d67ae71480d2371a49d4c02b1597db736c6ac (patch)
tree6c8b12b7ea607907f611d5db31af0ff4a82695d4
parent* improve boundingbox calculation: include strokecaps. (diff)
downloadinkscape-c36d67ae71480d2371a49d4c02b1597db736c6ac.tar.gz
inkscape-c36d67ae71480d2371a49d4c02b1597db736c6ac.zip
commit patch for LaTeX equation render extension by Christoph Schmidt-Hieber
Fixed bugs: - https://launchpad.net/bugs/555128 (bzr r9308)
-rw-r--r--po/inkscape.pot8
-rw-r--r--share/extensions/eqtexsvg.inx1
-rw-r--r--share/extensions/eqtexsvg.py27
3 files changed, 31 insertions, 5 deletions
diff --git a/po/inkscape.pot b/po/inkscape.pot
index c88c30501..5b5857d7a 100644
--- a/po/inkscape.pot
+++ b/po/inkscape.pot
@@ -705,6 +705,14 @@ msgstr ""
msgid "LaTeX formula: "
msgstr ""
+#: ../share/extensions/eqtexsvg.inx.h:3
+msgid "Additional packages"
+msgstr ""
+
+#: ../share/extensions/eqtexsvg.inx.h:4
+msgid "Additional packages (comma-separated): "
+msgstr ""
+
#: ../share/extensions/export_gimp_palette.inx.h:1
msgid "Export as GIMP Palette"
msgstr ""
diff --git a/share/extensions/eqtexsvg.inx b/share/extensions/eqtexsvg.inx
index e99dfeb1d..70516b33f 100644
--- a/share/extensions/eqtexsvg.inx
+++ b/share/extensions/eqtexsvg.inx
@@ -8,6 +8,7 @@
<dependency type="executable" location="path">dvips</dependency>
<dependency type="executable" location="path">pstoedit</dependency>
<param name="formule" type="string" _gui-text="LaTeX formula: ">\(\displaystyle\frac{\pi^2}{6}=\lim_{n \to \infty}\sum_{k=1}^n \frac{1}{k^2}\)</param>
+ <param name="packages" type="string" _gui-text="Additional packages (comma-separated): "></param>
<effect>
<object-type>all</object-type>
<effects-menu>
diff --git a/share/extensions/eqtexsvg.py b/share/extensions/eqtexsvg.py
index 563bf2c4c..8e2e70a10 100644
--- a/share/extensions/eqtexsvg.py
+++ b/share/extensions/eqtexsvg.py
@@ -9,6 +9,9 @@ This extension need, to work properly:
Copyright (C) 2006 Julien Vitard <julienvitard@gmail.com>
+2010-04-04: Added support for custom packages
+ Christoph Schmidt-Hieber <christsc@gmx.de>
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -27,15 +30,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import inkex, os, tempfile, sys, xml.dom.minidom
-def create_equation_tex(filename, equation):
+def parse_pkgs(pkgstring):
+ pkglist = pkgstring.replace(" ","").split(",")
+ header = ""
+ for pkg in pkglist:
+ header += "\\usepackage{%s}\n" % pkg
+
+ return header
+
+def create_equation_tex(filename, equation, add_header=""):
tex = open(filename, 'w')
tex.write("""%% processed with eqtexsvg.py
\\documentclass{article}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{amsfonts}
-
-\\thispagestyle{empty}
+""")
+ tex.write(add_header)
+ tex.write("""\\thispagestyle{empty}
\\begin{document}
""")
tex.write(equation)
@@ -76,8 +88,12 @@ class EQTEXSVG(inkex.Effect):
inkex.Effect.__init__(self)
self.OptionParser.add_option("-f", "--formule",
action="store", type="string",
- dest="formula", default=10.0,
+ dest="formula", default="",
help="LaTeX formula")
+ self.OptionParser.add_option("-p", "--packages",
+ action="store", type="string",
+ dest="packages", default="",
+ help="Additional packages")
def effect(self):
base_dir = tempfile.mkdtemp("", "inkscape-");
@@ -102,7 +118,8 @@ class EQTEXSVG(inkex.Effect):
os.remove(err_file)
os.rmdir(base_dir)
- create_equation_tex(latex_file, self.options.formula)
+ add_header = parse_pkgs(self.options.packages)
+ create_equation_tex(latex_file, self.options.formula, add_header)
os.system('latex "-output-directory=%s" -halt-on-error "%s" > "%s"' \
% (base_dir, latex_file, out_file))
try: