![\newcommand에 비머 슬라이드 지정자 사용](https://rvso.com/image/405351/%5Cnewcommand%EC%97%90%20%20%EB%B9%84%EB%A8%B8%20%EC%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C%20%EC%A7%80%EC%A0%95%EC%9E%90%20%EC%82%AC%EC%9A%A9.png)
<>
다음과 같이 슬라이드를 지정하는 데 사용하고 있습니다 .https://tex.stackexchange.com/a/518585/114719
\newcommand
다음 예제와 같이 via로 정의된 매크로에 이 지정자를 적용할 때 문제가 발생합니다 .
\documentclass{beamer}
\usepackage{tikz}
\newcommand{\drawline}[2]{
\draw (#1) -- (#2);
}
\begin{document}
\begin{frame}
\begin{overlayarea}{\linewidth}{0.7\paperheight}
\centering
\begin{tikzpicture}
\useasboundingbox(-5.5,-.5)rectangle(6,5.5);%
\coordinate (O) at (0, 0);
\coordinate (A) at (5, 5);
\coordinate (B) at (-5, 5);
\draw<1-> (O) -- (B); %OK
\drawline<2> {A}{B}; %trouble
\end{tikzpicture}
\end{overlayarea}
\end{frame}
\end{document}
컴파일 오류는 다음과 같습니다:
! Package pgf Error: No shape named < is known.
<>
를 통해 정의된 매크로에 슬라이드 지정자를 어떻게 적용할 수 있나요 \newcommand
?
답변1
를 사용하여 사용자 정의 매크로가 오버레이 사양을 인식하도록 해야 합니다 \newcommand<>
. 매크로 정의 내에는 오버레이 사양을 포함하고 다른 매크로에 전달될 수 있는 추가 인수를 사용할 수 있습니다.
귀하의 예에는 두 개의 인수 #1
와 가 있습니다 #2
. 이제 \newcommand<>
대신 을 사용하면 을 \newcommand
통해 오버레이 사양에 액세스할 수 있습니다 #3
. \draw
as 에 추가해야 합니다 \draw#3
. 전체 예:
\documentclass{beamer}
\usepackage{tikz}
\newcommand<>{\drawline}[2]{
\draw#3 (#1) -- (#2);
}
\begin{document}
\begin{frame}
\begin{overlayarea}{\linewidth}{0.7\paperheight}
\centering
\begin{tikzpicture}
\useasboundingbox(-5.5,-.5)rectangle(6,5.5);%
\coordinate (O) at (0, 0);
\coordinate (A) at (5, 5);
\coordinate (B) at (-5, 5);
\draw<1-> (O) -- (B);
\drawline<2> {A}{B};
\end{tikzpicture}
\end{overlayarea}
\end{frame}
\end{document}