오버레이에서 그룹화된 서식 명령을 자동으로 트리거합니다.

오버레이에서 그룹화된 서식 명령을 자동으로 트리거합니다.

다음과 동일한 출력을 원합니다.

\documentclass{beamer}
\begin{document}

\begin{frame}[<+->]{Sampling}
\begin{itemize}
\item A random sample of ten people from the US will \alt<5>{{\color{blue}on average}}{on average} produce
five men and five women, but... \uncover<+->{ any given trial is likely to over-represent one sex and underrepresent
the other.}
\item Analogy: if you flip a fair coin 10 times, \alt<5>{{\color{blue}on average}}{on average} you'll get 5
heads and 5 tails, but... \uncover<+->{ sometimes we might get 7 heads and 3 tails, and other times 8 tails
and 2 heads.}
\item What does ``\alt<5>{{\color{blue}on average}}{on average}'' mean above?
\item It means that if we were to take a lot of samples.... blah blah.
\end{itemize}
\end{frame}

\end{document}

그러나 대신에 "평균적으로"의 처음 두 인스턴스에 대해 \alt<5>{{\color{blue}on average}}{on average}천천히 넣고 세 번째와 마지막 인스턴스에 다음과 같은 것을 넣고 싶습니다 . 즉, 다음 코드를 작성하지만 위와 동일한 출력을 얻고 싶습니다.\groupA{on average}\revealGroupA{on average}

\documentclass{beamer}
\begin{document}

\begin{frame}[<+->]{Sampling}
\begin{itemize}
\item A random sample of ten people from the US will \groupA{on average} produce
five men and five women, but... \uncover<+->{ any given trial is likely to over-represent one sex and underrepresent
the other.}
\item Analogy: if you flip a fair coin 10 times, \groupA{on average} you'll get 5
heads and 5 tails, but... \uncover<+->{ sometimes we might get 7 heads and 3 tails, and other times 8 tails
and 2 heads.}
\item What does ``\revealGroupA{on average}'' mean above?
\item It means that if we were to take a lot of samples.... blah blah.
\end{itemize}
\end{frame}

\end{document}

몇 가지 참고사항:

  • 예에서 인수("평균")는 항상 동일하지만 다른 사용 사례에서는 그렇지 않습니다.

  • 저는 수학에서도 이 작업을 많이 하기 때문에 명령이 수학 안팎에서 작동하는 것이 좋을 것입니다.

  • 나는 아마도 동일한 파일의 여러 다른 프레임에서 이 메커니즘을 사용할 것입니다.

  • \groupB관련성이 있는지는 확실하지 않지만 기본적으로 동일한 작업을 수행하지만 다른 색상을 사용하는 명령을 생성하기 위해 답변을 확장할 계획입니다 . 그 이유는 동일한 프레임에서 \groupA및 를 모두 사용하고 싶을 수도 있기 때문입니다.\groupB

답변1

totcount패키지를 사용하여 그룹이 컴파일 사이에 표시될 오버레이 번호를 저장할 수 있습니다 (다른 프레임에서 동일한 그룹을 재사용하지 마십시오).

\documentclass{beamer}


\makeatletter
\newcommand*{\slideinframe}{\beamer@slideinframe}
\makeatother

\usepackage{totcount}


\setbeamercolor{alerted text}{fg=blue}

\newcounter{overlaygroupA}
\setcounter{overlaygroupA}{0}

\newcommand{\revealGroupA}[1]{%
  \only<.>{\setcounter{overlaygroupA}{\slideinframe}}%
  \alert<.>{#1}%
}

\newcommand{\groupA}[1]{%
  \alert<\totvalue{overlaygroupA}>{#1}%
}

\regtotcounter{overlaygroupA}

\begin{document}

\begin{frame}[<+->]{Sampling}
\begin{itemize}
\item A random sample of ten people from the US will \groupA{on average} produce
five men and five women, but... \uncover<+->{ any given trial is likely to over-represent one sex and underrepresent
the other.}
\item Analogy: if you flip a fair coin 10 times, \groupA{on average} you'll get 5
heads and 5 tails, but... \uncover<+->{ sometimes we might get 7 heads and 3 tails, and other times 8 tails
and 2 heads.}
\item What does ``\revealGroupA{on average}'' mean above?
\item It means that if we were to take a lot of samples.... blah blah.
\end{itemize}

\end{frame}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보