Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add function read preamble as contents
Most preamble is short, just paste to the editbox is better.
  • Loading branch information
wanglongqi committed Jun 14, 2015
1 parent 63e7343 commit fadfedf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions writetex.inx
Expand Up @@ -6,6 +6,7 @@
<dependency type="executable" location="extensions">inkex.py</dependency>
<dependency type="executable" location="path">xelatex</dependency>
<param name="preamble" type="string" _gui-text="Preamble File: "></param>
<param name="read-as-line" type="boolean" _gui-text="Trade above as contents">false</param>
<param name="scale" type="float" precision="2" min="0.1" max="50" _gui-text="Scale Factor">1</param>
<param name="action" type="notebook">
<page name="new" _gui-text="New TeX String">
Expand Down
19 changes: 13 additions & 6 deletions writetex.py
Expand Up @@ -37,6 +37,10 @@ def __init__(self):
action="store",type="string",
dest="preamble",default="",
help="Preamble File")
self.OptionParser.add_option("--read-as-line",
action="store",type="string",
dest="preline",default="",
help="Read preamble as string")
self.OptionParser.add_option("-s","--scale",
action="store",type="string",
dest="scale",default="",
Expand Down Expand Up @@ -88,13 +92,16 @@ def effect(self):
out_file=os.path.join(tmp_dir,"writetex.out")
err_file=os.path.join(tmp_dir,"writetex.err")
aux_file=os.path.join(tmp_dir,"writetex.aux")
if self.options.preamble=="":
preamble=""

if self.options.preline == "true":
preamble = self.options.preamble
else:
f=open(self.options.preamble)
preamble=f.read()
f.close()
if self.options.preamble=="":
preamble=""
else:
f=open(self.options.preamble)
preamble=f.read()
f.close()

self.tex=r"""
\documentclass[landscape,a3paper]{article}
Expand Down

0 comments on commit fadfedf

Please sign in to comment.