5

I use hyperref and pgf packages.

I need pgf to include and position an image:

\pgfputat{\pgfxy(-0.2, -2.4)}{
    \pgfbox[left,base]{
        \includegraphics[width=0.19\textwidth]{\@universitylogo}
    }
}

\href{http://www.example.com}{www.example.com}   % Shows link with broken anchor

But after each \pgfbox[left,base]{} call the \href anchor moves lower and lower below the link title. Any ideas how to fix the anchor?

Here is minimal example to demonstrate the broken \href anchor:

\documentclass{article}
\usepackage{pgf}
\usepackage{hyperref}

\begin{document}

\begin{center}
  \pgfputat{\pgfxy(-1.3, -2.1)}{\pgfbox[left,base]{
      \includegraphics[width=0.19\textwidth]{img/sun}}}
  \pgfputat{\pgfxy(10.9, -2.0)}{\pgfbox[left,base]{
      \includegraphics[width=0.15\textwidth]{img/moon}}}

  \parbox[b]{0.5\textwidth}{
     \centering \large\bf
     My University \\
     Institute of Science and Technology \\
     C O U N T R Y
  } 

\vskip 1cm
\href{http://www.example.com}{www.example.com}
\end{center}
\end{document}

Here is the result: enter image description here

  • Are you using the raiselinks option? – John Kormylo Oct 9 '14 at 15:10
  • No. Just tried setting it to true|false, but no effect. – niekas Oct 9 '14 at 15:15
  • Never mind. I presume this whole thing is sitting inside an \href command. Perhaps you you put the \href inside the \pgfbox instead. – John Kormylo Oct 9 '14 at 15:21
  • Nope, the \href and \pgfputat are in the same block. – niekas Oct 9 '14 at 15:29
  • Do you need to use this lowlevel commands instead of regular TikZ syntax ? – percusse Oct 9 '14 at 17:12
3

Here is a very mild alternative that provides the output you're after:

enter image description here

\documentclass{article}
\usepackage[margin=0.5in]{geometry}% Just for this example
\usepackage{tabularx,graphicx,hyperref}

\begin{document}

\begin{center}
  \renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}
  \begin{tabularx}{\linewidth}{@{}m{.2\linewidth}Xm{.2\linewidth}@{}}
    \includegraphics[width=\linewidth]{example-image-a} &
    \large\bfseries
    My University \par
    Institute of Science and Technology \par
    C O U N T R Y &
    \includegraphics[width=\linewidth]{example-image-b} \\ \\[1cm]
    &
    \href{http://www.example.com}{www.example.com}
  \end{tabularx}
\end{center}

\end{document}

The m-column specification is similar to a p-column, but vertically centres its contents (supplied by the array package which is loaded by tabularx).

0

I came here because I have had the same issue with moderncv when I would want to keep link clickable and put a logo. pgfbox it's clearly incompatible with hyperref if you don't use it, the link anchor is again at the right place. However, you can't get rid of it, because your images will become float (in my opinion), yielding an incorrect alignment.

I found a working solution, from Werner's link in comments where the initial author was Peter Grill : (https://tex.stackexchange.com/a/169836/125774). Amazing solution! You can once again use coordinates to place anythings.

MWE

\documentclass{article}
\usepackage{hyperref}

\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*{\BottomLeftX}{1.0in+\hoffset+\oddsidemargin}%
\newcommand*{\BottomLeftY}{\paperheight-1.0in-\voffset-\topmargin-\headheight-\headsep-\textheight}%
\newcommand*{\AbsolutePosition}[4][]{%
    % #1 = tikz options
    % #2 = x (from south west corner of page
    % #3 = y
    % #4 = text
    \begin{tikzpicture}[remember picture,overlay, ultra thick]
        %\draw [shift={(#2,#3)},#1]  (current page.south west) circle (2pt) 
        \draw [#1]  ($(current page.south west) + (\BottomLeftX,\BottomLeftY) + (#2,#3)$)  
                node[above right] {#4};
    \end{tikzpicture}%
}

\begin{document}

\begin{center}
  \AbsolutePosition{8.9cm}{17.5cm}{\includegraphics[width=0.19\textwidth]{example-image-a}}
  \AbsolutePosition{0.9cm}{17.5cm}{\includegraphics[width=0.19\textwidth]{example-image-b}}
  \parbox[b]{0.5\textwidth}{
     \centering \large\bf
     My University \\
     Institute of Science and Technology \\
     C O U N T R Y
  } 
\vskip 1cm
\href{http://www.example.com}{www.example.com}
\end{center}


\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.