4

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
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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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