[Tex/LaTex] What causes the “\@next does not match its definition” error


I have the following (minimal) document class:

\ProvidesClass{minimal-article}[2013/01/11 Test class, extends article]

% Load parent class with preset options


  \begin{tikzpicture}[remember picture, overlay]%
  \typeout{Drawing a rectangle?} %
   \fill [fill=red] at (current page.south west) rectangle (current page.south east);%
  \typeout{Background rectangle built.}%


When using this from the minimal document file:



I get a strange error message:

Drawing a rectangle?
! Use of \@next doesn't match its definition.
\maketitle ...ng a rectangle?} \fill [fill=red] at
                                               (current page.south west)...
l.3 \begin{document}

As far as I can guess, it has to be some local environment problem,
since yesterday the non-minimal version of that same class worked just fine,
and now everything fails with that cryptic message.

Any ideas what would case this?

Best Answer

Jake has already shown the Tikz syntax error that caused the problem but to answer the question about what the error message means (as opposed to how to avoid getting it:-) This is a primitive TeX error caused when you use a "delimited argument". Consider


\def\aaa * #1 *{\typeout{argument is #1}}

\aaa * hello *

\aaa !* goodbye *


The macro \aaa instead of taking arguments in the usual way \aaa 1 or \aaa{123} takes its argument delimited by two token sequences *_ and _* (using _ as a visible space) note any sequence of tokens may be used between the parameter markers #1, #2, ...

So in the first case

argument is hello

is echoed to the terminal, but in the second case \aaa requires a * as the following token and it is not there, so you get the error message in the subject line:

! Use of \aaa doesn't match its definition.
l.8 \aaa !
          * goodbye *
? x
No pages of output.

While the\def form and delimited arguments are not supported at the top level in LaTeX, it is quite common to use them internally for all sorts of parsing tasks clearly TikZ but also standard latex optional and picture mode arguments using [ ] and ( ) use this kind of definition internally.