平均能量损失

平均能量损失

我正在尝试根据哪些 PDF 图层处于活动状态来显示带有徽标的不同框。参见下图

在此处输入图片描述

在我的例子中,我只有 3 个,但对于我的实际问题,我猜我需要3 组。我想根据三个设置切换盒子:

  • Language = {English|Bokmål|Nynorsk|Samisk}
  • Color = {Black, Color}
  • Secret = {True | False}

每组中每次只能有一个设置处于活动状态。我的问题是我无法堆叠图层,并且它们按顺序显示。有没有办法确保每个图层都相互叠加,并以可管理的方式构建三个组。

平均能量损失

\documentclass[12pt]{article}

\usepackage[samin, norsk, nynorsk, british]{babel}
\usepackage[utf8]{inputenc} % usually not needed (loaded by default)
\usepackage[T1]{fontenc}

\usepackage[tikz]{ocgx2}

\newcommand{\UNItitlebox}[1]{%
  \begin{center}
    \setlength{\fboxsep}{0pt}
    \fbox{%
      \begin{minipage}{\dimexpr\textwidth-2\fboxrule}
        \vspace{1pt}
        \hrule height 1pt
        \vspace{1.2em}
        \noindent
        \mbox{}\quad\includegraphics[height=1.69cm,width=12.8cm]{#1}\\[5pt]
          \mbox{}\quad MAT-1001\quad Calculus\hfill English\quad\mbox{}%
          \\[5pt]
          \mbox{}\quad Exam\hfill 23/09/2019\quad\mbox{}%
          \vspace{1em}
          \hrule height1pt
          \vspace{1pt}
        \end{minipage}%
      }
    \end{center}%
}

% Hyperlenker og klikkbare lenker.
\RequirePackage{hyperref}

\hypersetup{
  colorlinks=true,        % false: boxed links; true: colored links
  linkcolor=black,        % color of internal links (change box color with linkbordercolor)
}

\begin{document}

\section{Introduction}

\begin{ocg}{OCG 1}{ocg1}{1}
  \noindent
  \actionsocg{}{ocg1}{ocg2 ocg3 ocg4}{\color{green!50!black}English}\hfill%
  \actionsocg{}{ocg2}{ocg1 ocg3 ocg4}{Bokmål}\hfill%
  \actionsocg{}{ocg3}{ocg1 ocg2 ocg4}{Nynorsk}\hfill%
  \actionsocg{}{ocg4}{ocg1 ocg2 ocg3}{Samisk}
\end{ocg}

  \vspace{-\baselineskip}
\begin{ocg}{OCG 2}{ocg2}{0}
  \noindent
  \actionsocg{}{ocg1}{ocg2 ocg3 ocg4}{English}\hfill%
  \actionsocg{}{ocg2}{ocg1 ocg3 ocg4}{\color{green!50!black}Bokmål}\hfill%
  \actionsocg{}{ocg3}{ocg1 ocg2 ocg4}{Nynorsk}\hfill%
  \actionsocg{}{ocg4}{ocg1 ocg2 ocg3}{Samisk}
\end{ocg}

  \vspace{-\baselineskip}
\begin{ocg}{OCG 3}{ocg3}{0}
  \noindent
  \actionsocg{}{ocg1}{ocg2 ocg3 ocg4}{English}\hfill%
  \actionsocg{}{ocg2}{ocg1 ocg3 ocg4}{Bokmål}\hfill%
  \actionsocg{}{ocg3}{ocg1 ocg2 ocg4}{\color{green!50!black}Nynorsk}\hfill%
  \actionsocg{}{ocg4}{ocg1 ocg2 ocg3}{Samisk}
\end{ocg}

  \vspace{-\baselineskip}
\begin{ocg}{OCG 4}{ocg4}{0}
  \noindent
  \actionsocg{}{ocg1}{ocg2 ocg3 ocg4}{English}\hfill%
  \actionsocg{}{ocg2}{ocg1 ocg3 ocg4}{Bokmål}\hfill%
  \actionsocg{}{ocg3}{ocg1 ocg2 ocg4}{Nynorsk}\hfill%
  \actionsocg{}{ocg4}{ocg1 ocg2 ocg3}{\color{green!50!black}Samisk}
\end{ocg}

\bigskip

\begin{ocg}{OCG 1}{ocg1}{1}
  \UNItitlebox{example-image-a}
\end{ocg}
  \vspace{-4.7cm}
\begin{ocg}{OCG 2}{ocg2}{0}
  \UNItitlebox{example-image-b}
\end{ocg}
  \vspace{-4.7cm}
\begin{ocg}{OCG 3}{ocg3}{0}
  \UNItitlebox{example-image-c}
\end{ocg}
  \vspace{-4.7cm}
\begin{ocg}{OCG 4}{ocg4}{0}
  \UNItitlebox{example-image}
\end{ocg}

\end{document}

答案1

ocgx2具有两个可简化当前任务的功能:单选按钮组OCMD

在此处输入图片描述

  1. 单选按钮组

    将所有 OCG 添加到一个公共单选按钮组(此处radiobtngrp=languages:)一次只能启用一个 OCG;当启用另一个 OCG 时,前一个 OCG 将被自动禁用。

  2. 眼科医学博士s(可选内容成员词典)

    OCMD 是除 OCG 之外的另一种 PDF 图层,其可见性取决于查看时文档中其他 OCG 的可见性。它们的可见性不是通过用户交互(例如鼠标点击)直接设置的,而是基于可见性表达式计算的。它们是随环境创建的ocmd。在这里,OCMD 用于制作顶行中绿色和黑色按钮标题的图层,表示“开”和“关”状态。

mbox通过使用零宽度-es 来准确覆盖排版材料,代码得到进一步简化。

\documentclass[12pt]{article}

\usepackage[samin, norsk, nynorsk, british]{babel}
\usepackage[utf8]{inputenc} % usually not needed (loaded by default)
\usepackage[T1]{fontenc}

\usepackage[tikz]{ocgx2}

\newcommand{\UNItitlebox}[2]{% #1: logo, #2: language
  \frame{%
    \begin{minipage}{\textwidth}\centering
      \vspace{1pt}
      \hrule height 1pt
      \vspace{1.2em}
      \includegraphics[height=1.69cm,width=12.8cm]{#1}\\[5pt]
      \makebox[12.8cm]{MAT-1001\quad Calculus\hfill #2}\\[5pt]
      \makebox[12.8cm]{Exam\hfill 23/09/2019}\\[5pt]
      \vspace{1em}
      \hrule height 1pt
      \vspace{1pt}
    \end{minipage}%
  }
}

% Hyperlenker og klikkbare lenker.
\usepackage{hyperref}

\begin{document}

\section{Introduction}

{%
  \noindent\hypersetup{pdfborder=0 0 0}% locally suppress link borders
  \begin{ocmd}{\AllOff{ocg1}}\makebox[0pt][l]{English}\end{ocmd}% black, "on" if ocg1 is "off"
  \showocg{ocg1}{%
    \begin{ocmd}{\AllOn{ocg1}} % green if ocg1 "on"
      \color{green!50!black}English
    \end{ocmd}}\hfill
  %  
  \begin{ocmd}{\AllOff{ocg2}}\makebox[0pt][l]{Bokmål}\end{ocmd}% black, "on" if ocg2 is "off"
  \showocg{ocg2}{%
    \begin{ocmd}{\AllOn{ocg2}} % green if ocg2 "on"
      \color{green!50!black}Bokmål
    \end{ocmd}}\hfill
  %  
  \begin{ocmd}{\AllOff{ocg3}}\makebox[0pt][l]{Nynorsk}\end{ocmd}% black, "on" if ocg3 is "off"
  \showocg{ocg3}{%
    \begin{ocmd}{\AllOn{ocg3}} % green if ocg3 "on"
      \color{green!50!black}Nynorsk
    \end{ocmd}}\hfill
  %  
  \begin{ocmd}{\AllOff{ocg4}}\makebox[0pt][l]{Samisk}\end{ocmd}% black, "on" if ocg4 is "off"
  \showocg{ocg4}{%
    \begin{ocmd}{\AllOn{ocg4}} % green if ocg4 "on"
      \color{green!50!black}Samisk
    \end{ocmd}}%
}  

\bigskip

\begin{center}
%
\begin{ocg}[radiobtngrp=languages]{OCG 1}{ocg1}{on}
  \makebox[0pt][l]{\UNItitlebox{example-image-a}{English}}
\end{ocg}%
%
\begin{ocg}[radiobtngrp=languages]{OCG 2}{ocg2}{off}
  \makebox[0pt][l]{\UNItitlebox{example-image-b}{Bokmål}}
\end{ocg}%
%
\begin{ocg}[radiobtngrp=languages]{OCG 3}{ocg3}{off}
  \makebox[0pt][l]{\UNItitlebox{example-image-c}{Nynorsk}}
\end{ocg}%
\begin{ocg}[radiobtngrp=languages]{OCG 4}{ocg4}{off}
  \UNItitlebox{example-image}{Samisk}
\end{ocg}
\end{center}

\end{document}

相关内容