ocgx で色を切り替える - 複数のボタン

ocgx で色を切り替える - 複数のボタン

編集: 問題の最初の説明が十分ではありませんでした。最後の編集に注意してください。

ここocgx で色を切り替える方法について質問しました。解決策は次のとおりです。

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{ocgx2}

\begin{document}
\begin{frame}
  \makebox[0pt][l]{%
    \begin{ocg}{Bul01r}{ocg01r}{1}\actionsocg{ocg01r ocg01g}{}{}{\textcolor{red}{\textbullet}}\end{ocg}%
  }%
  \makebox[0pt][l]{%
    \begin{ocg}{Bul01g}{ocg01g}{0}\actionsocg{ocg01g ocg01b}{}{}{\textcolor{green}{\textbullet}}\end{ocg}%
  }%
  \makebox[0pt][l]{%
    \begin{ocg}{Bul01b}{ocg01b}{0}\actionsocg{ocg01b ocg01x}{}{}{\textcolor{blue}{\textbullet}}\end{ocg}%
  }%
  \begin{ocg}{Bul01x}{ocg01x}{0}\actionsocg{ocg01x ocg01r}{}{}{$\circ$}\end{ocg}%
\end{frame}
\end{document}

ここで、2 つ (またはそれ以上) のボタンが互いに影響し合うようにしたい (つまり、Button1 が赤で Button2 が緑で、ボタンの 1 つをクリックすると Button1 が緑に、Button2 が青に変わる、その他の組み合わせでも同様)。Button1 は、Button1 をクリックしたときに Button2 が何色になるかを「知らない」ので、これがどのように実現できるのかわかりません。

編集: 問題を十分に説明できなかったようです。私が求めているのは、(たとえば) 2 行 2 列に配置された 4 つのボタンで、各ボタンがそれ自体に影響を与え、同じ行と列にある 2 つのボタンにも影響を与える (つまり、1 つのボタンが他のすべてのボタンに影響を与えない) ことです。主な目標は、長方形に配置された任意の数のボタンに対してこれを実行することです。

答え1

すべてのボタンが 4 つの色 (赤、緑、青、無色) を循環しているように見えますが、各ボタンの色は左側の隣のボタンに対して 1 つずつシフトしています。

いずれかのボタンをクリックしてサイクルを進めることができます(シェアLaTeX):

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{ocgx2}
\usepackage{multido}

\begin{document}

\begin{frame}
  \multido{}{8}{
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % 1st button
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 1}{state1}{1}\showocg{state2}{\textcolor{red}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 2}{state2}{0}\showocg{state3}{\textcolor{green}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 3}{state3}{0}\showocg{state4}{\textcolor{blue}{\textbullet}}\end{ocg}%
    }%
    \begin{ocg}[radiobtngrp=myBullets]{state 4}{state4}{0}\showocg{state1}{$\circ$}\end{ocg}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % 2nd button
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 4}{state4}{0}\showocg{state1}{\textcolor{red}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 1}{state1}{1}\showocg{state2}{\textcolor{green}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 2}{state2}{0}\showocg{state3}{\textcolor{blue}{\textbullet}}\end{ocg}%
    }%
    \begin{ocg}[radiobtngrp=myBullets]{state 3}{state3}{0}\showocg{state4}{$\circ$}\end{ocg}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % 3rd button
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 3}{state3}{0}\showocg{state4}{\textcolor{red}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 4}{state4}{0}\showocg{state1}{\textcolor{green}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 1}{state1}{1}\showocg{state2}{\textcolor{blue}{\textbullet}}\end{ocg}%
    }%
    \begin{ocg}[radiobtngrp=myBullets]{state 2}{state2}{0}\showocg{state3}{$\circ$}\end{ocg}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % 4th button
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 2}{state2}{0}\showocg{state3}{\textcolor{red}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 3}{state3}{0}\showocg{state4}{\textcolor{green}{\textbullet}}\end{ocg}%
    }%
    \makebox[0pt][l]{%
      \begin{ocg}[radiobtngrp=myBullets]{state 4}{state4}{0}\showocg{state1}{\textcolor{blue}{\textbullet}}\end{ocg}%
    }%
    \begin{ocg}[radiobtngrp=myBullets]{state 1}{state1}{1}\showocg{state2}{$\circ$}\end{ocg}
  }
\end{frame}
\end{document}

関連情報