5

This is what I'm doing:

\documentclass{article}
\usepackage{calc}
\newcommand{\foo}{0}
\setlength{\foo}{2in + 3in}
\usepackage[paperwidth=\foo,paperheight=\foo]{geometry}
\begin{document}
Hello, world!
\end{document}

I'm getting:

! LaTeX Error: Missing \begin{document}.

What's wrong?

0

1 Answer 1

6

You didn't show the full error message, which is:

 ! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.4 \setlength{\foo}{2in + 3in}

Because \foo is supposed to be a length parameter, you mustn't use \newcommand to define it. Instead, use \newlength. For sure, the following code compiles fine:

\documentclass{article}
\usepackage{calc}
\newlength{\foo}
\setlength{\foo}{2in + 3in}
\usepackage[paperwidth=\foo,paperheight=\foo]{geometry}
\begin{document}
Hello, world!
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .