The textext plugin of Inkscape generates a .tex file wrapper by means of the following piece of Python code (for v0.4.4):
def tex_to_pdf(self, info):
"""
Create a PDF file from latex text
"""
# Read preamble
preamble = ""
if os.path.isfile(info.preamble_file):
f = open(info.preamble_file, 'r')
preamble += f.read()
f.close()
# If latex_text is a file, use the file content instead
latex_text = self._get_text(info)
# Geometry and document class
width = info.page_width
height = "400cm" # probably large enough
geometry = ""
document_class = r"\documentclass[a0paper,landscape]{article}"
if width:
document_class = r"\documentclass{article}"
geometry = (("\usepackage[left=0cm, top=0cm, right=0cm, nohead, "
"nofoot, papersize={%s,%s} ]{geometry}")
% (width, height))
if r"\documentclass" in preamble:
document_class = ""
# Write the template to a file
texwrapper = r"""
%(document_class)s
%(preamble)s
%(geometry)s
\pagestyle{empty}
\begin{document}
\noindent
%(latex_text)s
\end{document}
""" % locals()
f_tex = open(self.tmp('tex'), 'w')
try:
f_tex.write(texwrapper)
finally:
f_tex.close()
# Options pass to LaTeX-related commands
latex_opts = ['-interaction=nonstopmode', '-halt-on-error']
# Exec pdflatex: tex -> pdf
out = exec_command(['pdflatex', self.tmp('tex')] + latex_opts)
if not os.path.exists(self.tmp('pdf')):
raise RuntimeError("pdflatex didn't produce output:\n\n" + out)
You'll notice that it creates a file template resembling
%(document_class)s
%(preamble)s
%(geometry)s
\pagestyle{empty}
\begin{document}
\noindent
%(latex_text)s
\end{document}
that already creates the (document_class) (as \documentclass{article}) and (preamble) (which may include a \documentclass of your choice), all the way up to the start of the document. The only text inserted in your textext dialog box should be what is inserted as (latex_text).
Since you included \documentclass[12pt]{article} as your first input line, it ended forming part of the main document
\documentclass{article}
...
\begin{document}
\noindent
\documentclass[12pt]{article}% This is what you entered...
\begin{document}
test
\end{document}% ...up to here.
\end{document}
which causes the error.
XMLSyntaxError: Document is empty, line 1, column 1– éclairevoyant Oct 20 '11 at 19:52testin the box and you receive the mentioned errors? – Werner Oct 20 '11 at 19:58\beginand\endit gives me those errors. – éclairevoyant Oct 20 '11 at 20:03latex, and the new one seems to be different, I'm not sure what could cause it. What version oftextextdo you have? The latest? What OS are you running it on? Did you look in thetextextcode and change anything? Why else would it push out anXMLSyntaxError? Have your tried re-installing the latest version? If you're running this on a Mac, perhaps you should report these errors to the package author, sincetextextseems native to Windows with only a port for Mac. Lots of questions... – Werner Oct 20 '11 at 20:47Inkscape 0.48.2withtextext 0.4.4on Windows 7. I did change some of the code according to this post to maketextextwork withv0.48(since the last release was only compatible/tested withv0.46), but the changed lines have to do with producing unique identifiers for thelatextext objects, and (I would assume, anyway) nothing to do with theXMLSyntaxError. – éclairevoyant Oct 21 '11 at 02:00textexthasn't updated it in three years, so I doubt (s)he is still working on it. – éclairevoyant Oct 21 '11 at 02:16