我使用hyperref
和pgf
包装。
我需要pgf
包含并定位一个图像:
\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
但每次\pgfbox[left,base]{}
调用后\href
,锚点都会在链接标题下方越来越低。有什么办法可以修复锚点吗?
下面是一个演示\href
锚点断裂的最小示例:
\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}
结果如下:
答案1
这是一个非常温和的替代方案,可以提供您想要的输出:
\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}
答案2
moderncv
我来这里是因为当我想保持链接可点击并放置徽标时,我遇到了同样的问题。pgfbox
这显然与hyperref
不使用它不兼容,链接锚点又回到了正确的位置。但是,您无法摆脱它,因为您的图像将变得浮动(在我看来),从而导致不正确的对齐。
我从评论中 Werner 的链接找到了一个可行的解决方案,其中最初的作者是 Peter Grill :(https://tex.stackexchange.com/a/169836/125774)。令人惊叹的解决方案!您可以再次使用坐标来放置任何东西。
\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}