비머의 하이퍼링크(자동 참조 포함) 색상

비머의 하이퍼링크(자동 참조 포함) 색상

다음 MWE를 고려하십시오.

\documentclass[leqno]{beamer}
\usepackage{lmodern}

\hypersetup{colorlinks=true,allcolors=blue}
\setbeamertemplate{theorems}[numbered]

\begin{document}
\begin{frame}
  \begin{theorem}
  \label{thm:a_theorem}
    \begin{equation}
      \label{eq:an_equation}
      2 + 2 = 4
    \end{equation}
  \end{theorem}

Equation \ref{eq:an_equation} belongs to \ref{thm:a_theorem}.\\
Equation \eqref{eq:an_equation} belongs to \ref{thm:a_theorem}.\\
Equation \autoref{eq:an_equation} belongs to \autoref{thm:a_theorem}.
\end{frame}
\end{document}

나는 i) 방정식 번호 주위의 괄호가 하이퍼링크의 일부가 되도록 하고(따라서 파란색으로 강조 표시됨) ii) \autoref작업을 시작합니다(따라서 in 도 파란색으로 강조 Equation (1) belongs to Theorem (1)표시됨 ).(1)Theorem (1)

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

편집하다:이 질문에 대한 고유한 답변에 제안된 솔루션을 통합한 다음 MWE를 고려하십시오.

\documentclass[leqno]{beamer}
\usepackage{lmodern}

\hypersetup{colorlinks=true,allcolors=blue}
\setbeamertemplate{theorems}[numbered]

\begin{document}
\begin{frame}
  Foo
\end{frame}
\begin{frame}
  \phantomsection
  \begin{theorem}
  \label{thm:a_theorem}
  Bar
  \end{theorem}
\end{frame}
\begin{frame}
  \phantomsection
  \begin{equation}
    \label{eq:an_equation}
    2 + 2 = 4
  \end{equation}
\end{frame}
\begin{frame}
  \hyperref[eq:an_equation]{Equation (\ref*{eq:an_equation})} belongs
  to \hyperref[thm:a_theorem]{Theorem \ref*{thm:a_theorem}}.
\end{frame}
\end{document}

하이퍼링크는 항상 첫 번째 프레임을 가리키며 해당 방정식이나 정리를 가리키지 않습니다.

답변1

옵션을 사용하여 클래스를 beamer로드합니다 . 이는 로딩이 더 일찍 중단되고 중요한 부품이 로딩되지 않음을 의미합니다. 따라서 방정식은 앵커를 생성하지도 않습니다. 앵커가 없으면 링크가 없습니다(적어도 가야 할 장소는 아님). 앵커 이름이 없으면 no .hyperrefimplicit=falsehyperref\autoref

해결 방법은 두 부분으로 구성됩니다.

  • 앵커는 으로 설정됩니다 \phantomsection. 앵커 이름은 설정에 \autoref대한 스텁일 뿐이므로 어쨌든 중요하지 않습니다 . 그러나 또한 빈 매크로인 더미이므로 예제에서는 를 사용하여 앵커를 설정하는 를 정의합니다 .\refbeamer\phantomsection\phantomtarget\hypertarget
  • \hyperrefwith 선택적 인수는 일반 참조 번호를 링크 내부의 이름과 번호가 포함된 더 긴 문구로 바꾸는 데 사용됩니다. \ref*별표를 사용하면 불필요한 중첩 링크를 방지할 수 있습니다.

전체 예:

\documentclass[leqno]{beamer}
\usepackage{lmodern}

\hypersetup{colorlinks=true,allcolors=blue}
\setbeamertemplate{theorems}[numbered]

\makeatletter
\newcounter{phantomtarget}
\renewcommand*{\thephantomtarget}{phantom.\the\value{phantomtarget}}
\newcommand*{\phantomtarget}{%
  \stepcounter{phantomtarget}%
  \hypertarget{\thephantomtarget}{}%
  \edef\@currentHref{\thephantomtarget}%
}
\makeatother

\begin{document}
\begin{frame}
  \phantomtarget
  \begin{theorem}
  \label{thm:a_theorem}
  \phantomtarget
    \begin{equation}
      \label{eq:an_equation}
      2 + 2 = 4
    \end{equation}
  \end{theorem}

\hyperref[eq:an_equation]{Equation (\ref*{eq:an_equation})} belongs
to \hyperref[thm:a_theorem]{Theorem \ref*{thm:a_theorem}}.
\end{frame}
\end{document}

결과

관련 정보