항목을 발견한 후 목록에서 항목을 강조 표시합니다.

항목을 발견한 후 목록에서 항목을 강조 표시합니다.
\documentclass[xcolor=table ]{beamer}


\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}

\title[Your Short Title]{Your Presentation}
\author{You}
\institute{Where You're From}
\date{Date of Presentation}

\begin{document}


\begin{frame}{Introduction}

\begin{itemize}
  \item <1-> Your introduction goes here!
  \item <2> Use \texttt{itemize} to organize your main points.
\end{itemize}

\end{frame}
\begin{frame} 
\begin{itemize}
  \item Your introduction goes here!
  \item {\colorbox{yellow} {Use \texttt{itemize} to organize your main points.}}
\end{itemize}

\end{frame}

\end{document}

이 MWE는 항목별 목록을 보여줍니다. 두 개의 연속 항목이 표시된 후 두 번째 항목이 강조 표시될 것으로 예상됩니다.세 번째 단계에서. 프레임을 복제하여 이를 달성했습니다. 프레임을 수동으로 복제하지 않고 오버레이를 통해 이를 달성할 수 있습니까?

답변1

쉬운 해결책은 코드의 일부를 조건부 \only로 만드는 것입니다.\colorbox{yellow}

    \begin{frame}{Introduction}
        \begin{itemize}
            \item <1-> Your introduction goes here!
            \item <2-> \only<3>{\colorbox{yellow}}{Use \texttt{itemize} to organize your main points.}
        \end{itemize}
    \end{frame}

그러나 여기에는 문제가 있습니다. \colorbox텍스트 주위의 일부 영역을 채우기 때문에 간격이 변경되어 눈에 띄는 점프가 발생합니다(시도해 보세요).

항상 를 사용하여 이 문제를 해결할 수 있지만 \colorbox강조 표시되지 않아야 하는 경우 배경색으로 채웁니다. 이것은 약간 지저분하므로 이 목적을 위해 새 명령을 정의하겠습니다.

\documentclass[xcolor=table]{beamer}
\usepackage[english]{babel}

\title[Your Short Title]{Your Presentation}
\author{You}
\institute{Where You're From}
\date{Date of Presentation}

\newcommand<>{\mycolorbox}[3][white]{{%
    % #1 = default color when overlay specification is not fulfilled (default: white)
    % #2 = color when overlay specification is fulfilled
    % #3 = text to be displayed
    % #4 = the actual overlay specification
    \def\mycolor{#1}%
    \only#4{\def\mycolor{#2}}%
    \colorbox{\mycolor}{#3}%
}}

\begin{document}
    \begin{frame}{Introduction}
        \begin{itemize}
            \item <1-> Your introduction goes here!
            \item <2-> \mycolorbox<3>{yellow}{Use \texttt{itemize} to organize your main points.}
        \end{itemize}
    \end{frame}
\end{document}

구문은 다음 \newcommand<>에 설명되어 있습니다.beamer 의 사용자 가이드 섹션9.6.1 사양을 인식하는 명령 및 환경 오버레이 만들기. 첫 번째 인수는 정의할 매크로의 이름( \mycolorbox이 경우)이고, 그 다음에는 오버레이 사양을 제외한 인수 개수 뒤에 오고, 마지막으로 첫 번째 인수의 기본값이 옵니다. 명령 내에서 #문자와 숫자를 사용하여 인수를 참조할 수 있습니다( 등, 설명 참조) #1.#2

이중 중괄호 쌍은 TeX 그룹을 생성하기 위해 존재 {{합니다 }}. 이는 매크로 (재) 정의가 결국에는 잊혀진다는 것을 의미합니다. 외부 쌍은 명령의 내용을 구분하고 내부 쌍은 TeX 그룹입니다.

\def그런 다음 (을 사용할 수도 있음 )을 사용하여 초기에 기본 색상인 \newcommand새 매크로를 정의합니다 . \mycolor를 사용하여 \only조건에 따라 원하는 색상(이 예에서는 노란색)으로 재정의합니다. 마지막으로 명령을 내립니다 \colorbox.

그런데 그냥 쓰는 것도 가능합니다만 \colorbox<3>{yellow}{text}, 어째선지 검은색 배경을 사용하고 있네요...

관련 정보