1

I remember there was a LaTeX macro used internally to define commands that can only be used in the preamble, but I cannot remember its name nor look it up.

Which is that command, and how is it used?

4

The command you're looking for is \@onlypreamble:

\documentclass{article}

\def\ACommand{\def\Example{}}

\makeatletter
\@onlypreamble\ACommand
\makeatother

\ACommand % ok

\begin{document}

\ACommand % error

\end{document}

output:

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.15 \ACommand
               % error
?

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.