I want to generate an image from a Tex file. I use a template and then programmatically insert LaTeX inside it. For example, if I want to create an image for x^2 + \phi, this would be the resulting template file:
\documentclass[12pt]{minimal}
\usepackage[english]{babel}
\usepackage[intlimits]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{wasysym}
\pagestyle{empty}
\parindent=0pt
\setbox0=\hbox{
x^2 + \phi
}
\textheight=\ht0
\textwidth=\wd0
\oddsidemargin=-1cm
\topmargin=-1.5cm
\advance\textheight by 1cm
\advance\textwidth by 1cm
\begin{document}
\vbox{\vss\hbox{\hss\copy0\hss}\vss}
\end{document}
I don't really know LaTeX, because I've only used it on Math.SE for equations. I've taken this template somewhere and if it can be made better I'm open for suggestions.
However, the problem is that this does not compile! Running latex source.tex produces
Missing character: There is no x in font nullfont!
! Missing $ inserted.
<inserted text>
$
l.10 x^
2 + \phi
My understanding is that some packages are setting the nullfont mode, so I cannot input the equation correctly.
minimalclass and never set boxes before\begin{document}. The reason for the error message is that^is legal only in math mode. – egreg Dec 08 '14 at 09:42minimalclass was not designed to be used for anything: it's there as it does the minimum necessary to allow LaTeX to process a\begin{document}line. Various core/expected definitions are not made byminimalas a result. It was set up for testing in the early 1990s in a very different computing situation. – Joseph Wright Dec 08 '14 at 10:26