21

I'm defining a command that should behave differently in handouts vs presentation. Is there a simple way to check that?

Ideally, it should be something like this:

\newcommand{\mycom}{
\ifthenelse{[check if handout mode]}{[Behave accordingly]}{[Behave otherwise]}
}

How can I do this?

Malabarba
  • 6,972

2 Answers2

27

Without additional packages, you can use \mode to accordingly define the command:

\documentclass[handout]{beamer}

\mode<beamer|second|trans|article>{\newcommand\mycmd{No H mode}}
\mode<handout>{\newcommand\mycmd{H mode}}

\begin{document}

\begin{frame}
\mycmd
\end{frame}

\end{document}
Gonzalo Medina
  • 505,128
5

Related to Detect value of option given to documentclass:

\documentclass[handout]{beamer}
\usepackage{xstring}
\makeatletter
\IfSubStr{\@classoptionslist}{handout}
  {\newcommand{\printmode}{Handout mode.}}
  {\newcommand{\printmode}{Not-handout mode.}}
\makeatother
\begin{document}

\begin{frame}
\printmode
\end{frame}

\end{document}
Mike Renfro
  • 20,550