\hyperlink adiciona espaço indesejado ao redor das imagens. Como se livrar disso?

\hyperlink adiciona espaço indesejado ao redor das imagens. Como se livrar disso?

Com pdflatex o seguinte

\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}

produz um slide onde o espaçamento entre os tikzpictureambientes com hiperlinks (linha superior) é maior do que o espaçamento entre os ambientes sem hiperlinks tikzpicture(linha inferior). O mesmo efeito também pode ser visto ao usar, por exemplo \includegraphics. Existe uma maneira de se livrar desse espaçamento?

Responder1

Um tikzpictureambiente é basicamente como uma caixa de letra/caractere, portanto, não ter %depois de a \end{tikzpicture}causará espaçamentos, assim como \hyperlink{bar}{a quebra de linha adicionará espaços espúrios.

Se algum desses espaçamentos for 'eliminado', você deverá colocar %depois \hyperlink{bar}{e depois dos links e depois \end{tikzpicture}dos ambientes não vinculados, além de dizer \offinterlineskip- as quatro imagens são contíguas então.

Veja as diferenças entre os dois métodos.

\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}

insira a descrição da imagem aqui

informação relacionada