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 wanted to make a command that outputs a number in math mode. This is how my file looks like:

\documentclass{scrartcl}

%\usepackage{epsdice}
%\newcommand{dice}[1]{\epsdice{#1}}

\newcommand{dice}[1]{\ensuremath{#1}}

\begin{document}
Lorem ipsum...
\end{document}

But when I compile this with XeTeX, I always get this error:

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.13 \newcommand{dice}[1]{\ensuremath{#1}}

I have not that much experience with TeX, I think the solution is quite easy.

share|improve this question
2  
+1 for the minimal working example. –  lockstep Sep 25 '11 at 11:22
    
I edited your title so other people with the same problem can find this question more easily, hope you don't mind. –  doncherry Sep 25 '11 at 12:09
1  
@doncherry Nevermind. Having the right of constructive edits on people's questions and answers is IMHO one of the fundamental principles of the whole Stackexchange / -overflow family. –  FUZxxl Sep 25 '11 at 15:53

1 Answer 1

up vote 16 down vote accepted

You're just missing a backslash in the command definition, it should be

\newcommand{\dice}[1]{\ensuremath{#1}}
share|improve this answer
1  
The point being that Latex emits the "Missing \begin{document}." if it has something that looks like it should be output, but it has not yet met the "\begin{document}" command. Latex will run tokens after the first in its first argument: try passing {d\ice}, {\d\ice}, or {\d i}. –  Charles Stewart Sep 26 '11 at 9:08
    
The helpful news is that LaTeX tells you the first line it objects to (line 1.13 in this example). –  Ethan Bolker Apr 30 '12 at 0:18

Your Answer

 
discard

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.