Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am having trouble with the textext plugin in inkscape; even the simplest bit of code, such as




gave an error as follows:

LaTeX Warning: Unused global option(s): [a0].
No file tmp.aux.
! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
l.7         \documentclass
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on tmp.log.

What am I doing wrong?

share|improve this question
add comment

1 Answer

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()

    # 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"""
    """ % locals()

    f_tex = open(self.tmp('tex'), 'w')

    # 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


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[12pt]{article}% This is what you entered...
  \end{document}% ...up to here.

which causes the error.

share|improve this answer
if i type only the LaTeX text into the box, i get several parser errors, followed by XMLSyntaxError: Document is empty, line 1, column 1 –  luolimao Oct 20 '11 at 19:52
Do you only type test in the box and you receive the mentioned errors? –  Werner Oct 20 '11 at 19:58
Yes; no matter how much i type, without the \begin and \end it gives me those errors. –  luolimao Oct 20 '11 at 20:03
Since the original error posted dealt with latex, and the new one seems to be different, I'm not sure what could cause it. What version of textext do you have? The latest? What OS are you running it on? Did you look in the textext code and change anything? Why else would it push out an XMLSyntaxError? 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, since textext seems native to Windows with only a port for Mac. Lots of questions... –  Werner Oct 20 '11 at 20:47
I'm running Inkscape 0.48.2 with textext 0.4.4 on Windows 7. I did change some of the code according to this post to make textext work with v0.48 (since the last release was only compatible/tested with v0.46), but the changed lines have to do with producing unique identifiers for the latex text objects, and (I would assume, anyway) nothing to do with the XMLSyntaxError. –  luolimao Oct 21 '11 at 2:00
show 1 more comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.