为什么这个动态命名的宏不起作用?

为什么这个动态命名的宏不起作用?
\documentclass[xcolor=dvipsnames,professionalfont,french]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier,tikz,ifthen}
\usetikzlibrary{calc} 
\usepackage[french]{babel}

\usetheme{Madrid}               % thème
\setbeamertemplate{footline}{}

\setbeamercolor{palette primary}{fg=white, bg=MidnightBlue!90}
\setbeamercolor{background canvas}{bg=MidnightBlue!15}

\setbeamersize{text margin left=1 mm}
\setbeamersize{text margin right=1 mm}

\beamertemplatenavigationsymbolsempty

\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\def\beamerslideinframe{\beamer@slideinframe}
\makeatother

\newcommand{\MyLabel}[1]{%
\expandafter\newcommand\csname Step#1\endcsname{\arabic{slideinframe}}
}


\begin{document}
\begin{frame}[label=bob]{Title}
\begin{enumerate}[<+->]
\item \only<.>{\MyLabel{a}}\arabic{slideinframe}

    \Stepa

\item \begin{itemize}[<+->]
    \item
    \item 
    \end{itemize}

\end{enumerate}
\end{frame}
\end{document}

答案1

你只是在本地组内进行定义,因此它在框架结束时未定义,你还缺少一个%

\documentclass[xcolor=dvipsnames,professionalfont,french]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier,tikz,ifthen}
\usetikzlibrary{calc} 
\usepackage[french]{babel}

\usetheme{Madrid}               % thème
\setbeamertemplate{footline}{}

\setbeamercolor{palette primary}{fg=white, bg=MidnightBlue!90}
\setbeamercolor{background canvas}{bg=MidnightBlue!15}

\setbeamersize{text margin left=1 mm}
\setbeamersize{text margin right=1 mm}

\beamertemplatenavigationsymbolsempty

\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\def\beamerslideinframe{\beamer@slideinframe}
\makeatother

\newcommand{\MyLabel}[1]{%
\expandafter\gdef\csname Step#1\endcsname{\arabic{slideinframe}}%
}


\begin{document}
\begin{frame}[label=bob]{Title}
\begin{enumerate}[<+->]
\item \only<.>{\MyLabel{a}}\arabic{slideinframe}

    \Stepa

\item \begin{itemize}[<+->]
    \item
    \item 
    \end{itemize}

\end{enumerate}
\end{frame}
\end{document}

相关内容