# Latex newcommand with mode*

I want to use a string constant inside a command in beamer. Here's what I'm doing

\documentclass{beamer}

\begin{document}

\mode*

\newcommand{\test}{asdf}

\begin{frame}
\test
\end{frame}

\end{document}


If \test is outside of frame it works, or if I remove mode*. All I want to use is to define a string for reusage in other commands and as input (it will hold a path).

• What do you need \mode* for? – user36296 Apr 22 '18 at 14:19
• While you wait for an answer to this question, can you go back to your previous ones and look if the answers solve your problems and accept them, if they do? – user36296 Apr 22 '18 at 14:21
• @samcarter Do you really think spamming me with 20 comments on each single of those is the right way of achieving that? – FooBar Apr 22 '18 at 14:48
• As for this question, \mode* is clearly not required here, but essential in the actual tex file. As it is necessary for creating the error, I included it. – FooBar Apr 22 '18 at 14:49

Here's the description of \mode* in the Beamer documentation:

\mode*

The effect of this mode is to ignore all text outside frames in the presentation modes. In article mode it has no effect.

Define \test in the proper location, that is, before \begin{document}:

\documentclass{beamer}

\newcommand{\test}{asdf}

\begin{document}

\mode*

\begin{frame}
\test
\end{frame}

\end{document}