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.
\def\test{\+test\cr}
\test
\vfill
\eject

The above gives error:

...
Runaway definition?
->
! Forbidden control sequence found while scanning definition of \test.
...
share|improve this question
add comment

3 Answers

\+ is a outer macro, it cannot be used in the definition of another macro. In plain.tex, it is defined as

\outer\def\+{\tabalign}

You can use \tabalign instead. Say,

\def\test{\tabalign test\cr}
\test
\bye
share|improve this answer
add comment

A different approach is to neutralize momentarily the outer macro:

\begingroup\let\+\relax
\gdef\test{\+test\cr}
\endgroup

It can be used for the outer macros that have no "inner" version like \bye, \beginsection or \proclaim.

\begingroup\let\beginsection\relax
\gdef\section#1{\beginsection#1\par}
\endgroup

\section{Title}

Of course \csname beginsection\endcsname would have worked too, as Joseph points out.

share|improve this answer
add comment

Another option to put an outer control sequence inside a macro is \noexpand:

\edef\test{\noexpand\+...}

The \noexpand command prevents expansion in an \edef (expanding def), and also hide "outerness".

share|improve this answer
    
The usual way to include an \outer control sequence inside something else is to use \csname ... \endcsname, which does not also leave you worrying about expansion. –  Joseph Wright Jun 21 '11 at 7:20
1  
True. The advantage of using \noexpand is that it also allows the \outer control sequence to come in an argument, expandably: \def\foo{\expandafter\fooo\noexpand} \def\fooo#1{...} works even if #1 is normally \outer. (I saw this in a solution of one of M.Downes exercises.) –  Bruno Le Floch Jun 21 '11 at 15:21
add comment

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.