扩展 Beamer 论证

扩展 Beamer 论证

我创建了一个接受 beamer 参数 (<...>) 的新命令,但无法传递它们。我想这是 \expandafter 的问题。有人知道吗?

\documentclass{beamer}
\usepackage{tikz}

\pgfkeys{/mypgf/.cd, arg/.store in = \arg}

\newcommand<>\img[2][]{
    \pgfkeys{/mypgf/.cd, #1}

    {
        \def\options{} % set options to something useful based on #1

        % This works:
        \expandafter\includegraphics\expandafter[\options]{#2}

        % But not when I try to add the beamer argument:
        \expandafter\includegraphics#3\expandafter[\options]{#2}
    }
}

\begin{document}

\img<2-4>[arg=val]{example-image}

\end{document}

答案1

\expandafter\includegraphics#3\expandafter[\options]{#2}

第一个\expandafter将扩展第一个标记(仅),#3但这样<就不会扩展。我认为你的目的是

\def\foo{\includegraphics#3}%
\expandafter\foo\expandafter[\options]{#2}%

相关内容