ocgx로 색상 전환

ocgx로 색상 전환

ocgx패키지를 사용하여 빨간색에서 녹색, 보이지 않는 빨간색 등을 클릭하면 색상이 변경되는 버튼이 있는 PDF를 만들고 싶습니다 . 나는 다음을 시도했다:

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{ocgx}
\begin{document}
\begin{frame}
\begin{ocg}{Bul01r}{ocg01r}{1}\actionsocg{ocg01g ocg01r}{}{}{\textcolor{red}{\textbullet}}\end{ocg} \hspace{-0.32cm}
\begin{ocg}{Bul01g}{ocg01g}{0}\actionsocg{ocg01g}{}{}{\textcolor{green}{\textbullet}}\end{ocg}
\end{frame}
\end{document}

그러나 이는 빨간색에서 녹색으로, 그리고 다시 빨간색으로 변경되는 것뿐입니다. 세 가지 상태의 버튼을 어떻게 얻을 수 있나요?

답변1

이 작업은 다음을 사용하여 편리하게 수행됩니다.ocgx2제공하는 패키지라디오 버튼 그룹( ocg환경 옵션 radiobtngrp=<name>). 동일한 라디오 버튼 그룹에 속하는 모든 OCG(PDF 레이어) 중에서 한 번에 하나만 활성화할 수 있으며 이전에 활성화된 OCG는 자동으로 숨겨집니다. 이를 통해 임의 주기 길이의 순환 종속성을 갖는 클릭 가능한 버튼을 구축할 수 있습니다.

다음 예제에서는 빨간색, 녹색, 파란색, 무색 상태를 연결합니다.

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

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

( 이전에 패키지를 사용한 *.aux경우 첫 번째 패키지를 삭제해야 할 수도 있습니다 .)ocgx


원래 게시물에서와 같이 \actionsocg{}{}{}{}더 간단한 명령 대신 명령을 사용하면 라디오 버튼 그룹 없이도 동일한 효과를 얻을 수 있습니다 . \showocg{}{}그러나 이를 위해서는 ocgx2서로 다른 레이어에 있는 스위칭 링크가 연결된 OCG의 가시성에 따라 올바르게 활성화/비활성화되도록 보장하는 패키지가 필요합니다.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% version without radio button group, using \actionsocg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{beamer}
\usepackage{xcolor}
\usepackage{ocgx2}

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

관련 정보