Graphics, Figures & TablesWhen I click on a hyperlink to a figure or table in my ow...

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

When I click on a hyperlink to a figure or table in my ow...

Post by LavaTyper »

When I click on a hyperlink to a figure or table in my own document, and the caption is at the bottom of the figure or table, why does clicking on the link place the caption at the top of the resulting page?

This causes me to have to then scroll up to see the figure or table after I've already clicked on it.


See example below and attached figure.

Code: Select all

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=black, plainpages=false, pdfpagelabels=true, urlcolor=blue]{hyperref}



\begin{document}

\section{My First Section}

\begin{figure}[!h]
\begin{center}
\includegraphics[width=0.5\textwidth]{MyPDFOfTangent}
\caption{\label{figure:mypdfoftangent}caption goes here}
\end{center}
\end{figure}


\newpage

\section{My Second Section}

See Figure \ref{figure:mypdfoftangent}.


\end{document}
Attachments
MyPDFOfTangent.pdf
(76.54 KiB) Downloaded 667 times
Last edited by cgnieder on Mon Aug 18, 2014 7:56 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

When I click on a hyperlink to a figure or table in my ow...

Post by Johannes_B »

You are looking for package hypcap.

Code: Select all

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{hyperref}
\hypersetup{colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=black, plainpages=false, pdfpagelabels=true, urlcolor=blue}
\usepackage[all]{hypcap}

\begin{document}

\section{My First Section}

\begin{figure}[!h]
	\centering
		\rule{5cm}{4cm}
		\caption{\label{figure:mypdfoftangent}caption goes here}
%	\end{center}%JB: Do not use the environment, unless you
%	want some extra extra space
\end{figure}


\newpage

\section{My Second Section}

See Figure \ref{figure:mypdfoftangent}.
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: When I click on a hyperlink to a figure or table in my o

Post by LavaTyper »

Yup, that's what I need, works for everything except sideways tables :)
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

When I click on a hyperlink to a figure or table in my ow...

Post by Johannes_B »

Code: Select all

\documentclass[12pt]{article}
\usepackage[hypcap]{caption}
\usepackage{lipsum}
\usepackage{rotating}
\usepackage{hyperref}
\hypersetup{colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=black, plainpages=false, pdfpagelabels=true, urlcolor=blue}
\begin{document}

\section{My First Section}

\begin{figure}[!h]
	\centering
		\rule{5cm}{4cm}
		\caption{\label{figure:mypdfoftangent}caption goes here}
\end{figure}

\begin{sidewaystable}
	\centering
	\caption{the caption}\label{tab:tab}
	\rule{5cm}{4cm}
\end{sidewaystable}

\newpage

\section{My Second Section}

See Figure \ref{figure:mypdfoftangent}.
and \ref{tab:tab}.


\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply