\hyperlink 在影像周圍增加了不需要的空間。如何擺脫它?

\hyperlink 在影像周圍增加了不需要的空間。如何擺脫它?

使用 pdflatex 如下

\documentclass{beamer}
\usepackage{hyperref}
\usepackage{tikz}
\begin{document}
  \begin{frame}
    \begin{figure}
        \hyperlink{bar}{
          \begin{tikzpicture}
                \filldraw (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
          \end{tikzpicture}
        }
        \hyperlink{bar}{
          \begin{tikzpicture}
                \filldraw (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
          \end{tikzpicture}
        }\\
        \begin{tikzpicture}
              \filldraw (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
        \end{tikzpicture}
        \begin{tikzpicture}
              \filldraw (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
        \end{tikzpicture}
  \end{figure}
 \end{frame}
\end{document}

產生一張投影片,其中超連結tikzpicture環境(上行)之間的間距大於非超連結tikzpicture環境(下行)之間的間距。使用例如時也可以看到相同的效果\includegraphics。有沒有辦法擺脫這個間距?

答案1

環境tikzpicture基本上就像一個字母/字元框,因此%後面沒有 a\end{tikzpicture}會導致空格,\hyperlink{bar}{換行符也會增加虛假空格。

如果這些間距中的任何一個應該被“殺死”,那麼您必須將其放置%\hyperlink{bar}{鏈結之後和之後以及\end{tikzpicture}非鏈結環境之後,並說\offinterlineskip- 這四個圖像是連續的。

查看兩種方法之間的差異。

\documentclass{beamer}
\usepackage{hyperref}
\usepackage{tikz}
\begin{document}
\begin{frame}
  \begin{figure}
    \hyperlink{bar}{%
      \begin{tikzpicture}
        \filldraw[blue] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
      \end{tikzpicture}%
    }
    \hyperlink{bar}{%
      \begin{tikzpicture}
        \filldraw[red] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
      \end{tikzpicture}%
    } 

    \begin{tikzpicture}
      \filldraw[yellow] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
    \end{tikzpicture}
    \begin{tikzpicture}
      \filldraw[green] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
    \end{tikzpicture}%
  \end{figure}

  \begin{figure}
    \hyperlink{bar}{%
      \begin{tikzpicture}
        \filldraw[blue] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
      \end{tikzpicture}%
    }%
    \hyperlink{bar}{%
      \begin{tikzpicture}
        \filldraw[red] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
      \end{tikzpicture}%
    }%
    \offinterlineskip% Only within groups!!!

    \begin{tikzpicture}
      \filldraw[yellow] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
    \end{tikzpicture}%
    \begin{tikzpicture}
      \filldraw[green] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
    \end{tikzpicture}%
  \end{figure}

\end{frame}
\end{document}

在此輸入影像描述

相關內容