\only를 사용하여 표시된 여러 tikz그림을 정렬하는 방법

\only를 사용하여 표시된 여러 tikz그림을 정렬하는 방법

나는 모두 비슷하지만 크기가 약간 다른 일련의 tikzpicture를 사용합니다(튀어나온 것이 있습니다. 그러나 나는 그것들이 모두 tikzpicture의 같은 지점에 정렬되기를 바랍니다.

나는 그들 모두에 대한 기준선을 설정하면 해당 좌표점을 정렬할 것이라고 생각했지만 여전히 "흔들립니다".

여기 MWE가 있습니다. (0,0)의 열린 원 노드가 각 오버레이의 페이지에서 동일한 위치에 있기를 원합니다. 그러나 각 tikzpicture의 경계 상자를 중앙에 두는 것 같습니다. 큰 녹색 노드로 인해 상자의 크기가 변경됩니다. 옵션이 이 작업을 수행했을 수도 있지만 baseline그렇지 않습니다.

\documentclass{beamer}

\usepackage{tikz}


\begin{document}

\newcommand\grf[1]{
  \begin{tikzpicture}%[baseline={(0,0)}]
    \node[circle,draw] (0) at (0,0) {} ;  % <-- this circle node should not move  
    \node[circle,fill] (1) at (+1,+1) {} ;
    \node[circle,fill] (2) at (+1,-1) {} ;
    \node[circle,fill] (3) at (-1,-1) {} ;
    \node[circle,fill] (4) at (-1,+1) {} ;
    \node[circle,fill,green,inner sep=1em] at (#1) {} ;
  \end{tikzpicture}
}

\begin{frame}
  \only<1>{\grf{1}}%
  \only<2>{\grf{2}}%
  \only<3>{\grf{3}}%
  \only<4>{\grf{4}}%
\end{frame}


\end{document}

답변1

경계 상자는 여전히 변경될 수 있으므로 기준선을 설정해도 일반적으로 점프가 방지되지는 않습니다. 매우 빠른 수정 중 하나는 키를 추가하여 경계 상자에서 추가 노드를 제외하는 것입니다 overlay.

\documentclass{beamer}

\usepackage{tikz}
\begin{document}

\newcommand\grf[1]{
  \begin{tikzpicture}%[baseline={(0,0)}]
    \node[circle,draw] (0) at (0,0) {} ;  % <-- this circle node should not move  
    \node[circle,fill] (1) at (+1,+1) {} ;
    \node[circle,fill] (2) at (+1,-1) {} ;
    \node[circle,fill] (3) at (-1,-1) {} ;
    \node[circle,fill] (4) at (-1,+1) {} ;
    \node[circle,fill,green,inner sep=1em,overlay] at (#1) {} ;
  \end{tikzpicture}
}

\begin{frame}
  \only<1>{\grf{1}}%
  \only<2>{\grf{2}}%
  \only<3>{\grf{3}}%
  \only<4>{\grf{4}}%
\end{frame}


\end{document}

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

일반적으로 티케이Z 라이브러리에는 overlay-beamer-styles점프를 방지할 수 있는 다양한 옵션이 있습니다. 여기에서 사용할 수 있습니다

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}

\begin{document}


\begin{frame}
  \begin{tikzpicture}%[baseline={(0,0)}]
    \node[circle,draw] (0) at (0,0) {} ;  % <-- this circle node should not move  
    \node[circle,fill] (1) at (+1,+1) {} ;
    \node[circle,fill] (2) at (+1,-1) {} ;
    \node[circle,fill] (3) at (-1,-1) {} ;
    \node[circle,fill] (4) at (-1,+1) {} ;
    \path foreach \X in {1,...,4}
     {node[circle,fill,green,inner sep=1em,visible on=<\X>] at (\X) {} };
  \end{tikzpicture}
\end{frame}


\end{document}

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

관련 정보