Переключение цветов с помощью 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}

Теперь я хочу иметь две (или более) кнопки, которые будут влиять друг на друга (т. е. если Button1 красная, а Button2 зеленая и нажата одна из кнопок, Button1 становится зеленой, а Button2 синей; и то же самое для любой другой комбинации). Я не вижу, как это можно сделать, поскольку Button1 не «знает», какой цвет у Button2, когда я нажимаю Button1.

EDIT: Кажется, я недостаточно хорошо описал свою проблему. Мне нужно (например) четыре кнопки, расположенные в 2 ряда и 2 столбца так, чтобы каждая кнопка влияла сама на себя и на две кнопки в том же ряду, соответственно, в том же столбце (т. е. одна кнопка не влияла на все остальные кнопки). Основная цель — сделать это для произвольного количества кнопок, расположенных в прямоугольнике.

решение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}

Связанный контент