我有一张图。图中描述了不同的组件,稍后将对其进行描述并用\label
标签进行标记。
我可以将一张图片的不同区域/部分引用链接到不同的\label
标签吗?还是我必须将不同图片的图表组合起来并引用它们?
hyperref
我目前正在使用这个包。
\documentclass[11pt, a4paper, oneside]{article}
\usepackage{graphicx}
\usepackage{hyperref}
\begin{document}
\includegraphics[scale=0.2]{diagrammPicture.pdf}
% something like \refInsidePicture{area1}{fromX}{toX}{fromY}{toY}
% \refInsidePicture{area2}{fromX}{toX}{fromY}{toY}
% \refInsidePicture{area3}{fromX}{toX}{fromY}{toY}
% \refInsidePicture{area4}{fromX}{toX}{fromY}{toY}
\section{area1 explained} \label{area1}
\section{area2 explained} \label{area2}
\section{area3 explained} \label{area3}
\section{area4 explained} \label{area4}
\end{document}
答案1
看来 \hypertarget 瞄准的是基线,所以我不得不移动基线以下的区域。
\documentclass[11pt, a4paper, oneside]{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{mwe}
\newsavebox{\tempbox}
\newlength{\tempheight}
\newlength{\tempwidth}
\newcommand{\area}{\rule[-0.49\tempheight]{0.49\tempwidth}{0.49\tempheight}}
% better too small than too big
\begin{document}
\savebox{\tempbox}{\includegraphics[scale=0.5]{example-image}}
\settoheight{\tempheight}{\usebox{\tempbox}}
\settowidth{\tempwidth}{\usebox{\tempbox}}
\hfil\parbox{\tempwidth}{%
\hypertarget{area1}{\area}\hfill%
\hypertarget{area2}{\area}%
\newline%
\hypertarget{area3}{\area}\hfill%
\hypertarget{area4}{\area}%
\newline%
\raisebox{0pt}[0pt]{\usebox{\tempbox}}% overlay
}
\begin{center}
\hyperlink{area1}{upper left}
\hyperlink{area2}{upper right}
\hyperlink{area3}{lower left}
\hyperlink{area4}{lower right}
\end{center}
\end{document}