一旦定义,我不希望\Stepx
重新定义宏:
\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]{%
\ifcsname Step#1\endcsname%
\else%
\expandafter\gdef\csname Step#1\endcsname{\arabic{slideinframe}}%
\fi%
}
\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
我建议使用 中的命令etoolbox
。特别是,这里有\ifcsdef
和 ,\csxdef
可用作。请注意,您需要xdef
在定义命令时扩展定义。版本gdef
只会将命令设置为\arabic{slideinframe}
随每个帧而变化的命令。
\usepackage{etoolbox}
\newcommand{\MyLabel}[1]{%
\ifcsdef{Step#1}{}{\csgdef{Step#1}{\arabic{slideinframe}}}}
您完成的文档是:
\documentclass[xcolor=dvipsnames,professionalfont,french]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier,tikz,ifthen}
\usetikzlibrary{calc}
\usepackage[french]{babel}
\usepackage{etoolbox}
\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]{%
\ifcsdef{Step#1}{}{\csxdef{Step#1}{\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}