Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Illegal parameter number in definition of

486 views
Skip to first unread message

Christopher Barrington-Leigh

unread,
Oct 18, 2008, 11:25:13 AM10/18/08
to
The following simple file fails with " Illegal parameter number in
definition of \AP@." Can anyone tell me what is wrong?!

\documentclass{article}
\usepackage{afterpage}
\newcommand{\showSEs}[2]{#1}
\begin{document}
\afterpage{\clearpage
\renewcommand{\showSEs}[2]{#2} % To not show SEs
\showSEs{this one}{or this one}
\renewcommand{\showSEs}[2]{#1} % To show SEs
}
\end{document}

Ulrich M. Schwarz

unread,
Oct 18, 2008, 11:37:46 AM10/18/08
to
On Sat, 18 Oct 2008 08:25:13 -0700, Christopher Barrington-Leigh wrote:

> The following simple file fails with " Illegal parameter number in
> definition of \AP@." Can anyone tell me what is wrong?!

Try doubling the #s until it works. If \afterpage ends up putting your
argument inside a macro definition (\AP@) itself, your #2 wants to look at
the second argument to \AP@, not \showSEs.

HTH
Ulrich

Harald Hanche-Olsen

unread,
Oct 19, 2008, 2:47:42 AM10/19/08
to
+ Christopher Barrington-Leigh <christ...@gmail.com>:

Ulrich M. Schwarz offers good advice, but I think even better advice is
to avoid the redifinition of macros (with arguments) inside moving
arguments.

\documentclass{article}
\usepackage{afterpage}
\newcommand{\showSEsone}[2]{#1}
\newcommand{\showSEstwo}[2]{#2}
\newcommand{\showSEs}{\showSEsone} % shorter: \let\showSEs=\showSEsone
\begin{document}
\afterpage{\clearpage
\renewcommand{\showSEs}{\showSEStwo} % or \let\showSEs=\showSEstwo


\showSEs{this one}{or this one}

\renewcommand{\showSEs}{\showSEstwo} % or \let\showSEs=\showSEsone
}
\end{document}

For bonus points, note that \showSEsone and \showSEstwo are already
internal LaTeX macros named \@firstoftwo and \@secondoftwo.

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell

Christopher Barrington-Leigh

unread,
Oct 20, 2008, 10:57:59 PM10/20/08
to
Ulrich M Schwartz and Bertrand Russell --
Thank you!! What great responses!
That has been very helpful.
Chris

Harald Hanche-Olsen

unread,
Oct 21, 2008, 1:10:47 AM10/21/08
to
+ Christopher Barrington-Leigh <christ...@gmail.com>:

> Ulrich M Schwartz and Bertrand Russell --
> Thank you!! What great responses!

I'm glad you found the Bertrand Russell quote helpful.
Never knew philosophy could be so useful in solving TeX problems.
8-)

0 new messages