Documentation/Errors & Debugging/Fix: Hyperlinks Not Working in PDF (LaTeX hyperref)
Errors & Debugging

Fix: Hyperlinks Not Working in PDF (LaTeX hyperref)

You've added hyperlinks to your LaTeX document using the hyperref package, but when you open the PDF, the links don't work — they're not clickable, they point to the wrong location, or they cause errors. Hyperlink issues in LaTeX PDFs usually stem from package loading order, incorrect URL formatting, or PDF viewer limitations. Bibby AI configures hyperref correctly by default and validates your links before compilation.

Setting Up hyperref Correctly

The hyperref package must be loaded last (with few exceptions) and configured properly:

% RULE: hyperref should be one of the LAST packages loaded
% (cleveref is an exception — it goes AFTER hyperref)

% BAD order:
\usepackage{hyperref}     % Too early!
\usepackage{graphicx}
\usepackage{amsmath}

% GOOD order:
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{hyperref}     % Near last
\usepackage{cleveref}     % After hyperref

% Recommended hyperref configuration:
\usepackage{hyperref}
\hypersetup{
  colorlinks  = true,
  linkcolor   = blue,
  citecolor   = blue,
  urlcolor    = blue,
  pdfauthor   = {Your Name},
  pdftitle    = {Your Paper Title},
  pdfsubject  = {Research Paper},
  bookmarksnumbered = true,
  breaklinks  = true  % Allow links to break across lines
}

Fixing Common Hyperlink Problems

Diagnose and fix the most frequent hyperref issues:

% PROBLEM 1: URLs with special characters break
% BAD:
\url{https://example.com/path?a=1&b=2}
% & is special in LaTeX!

% GOOD (\url handles special chars automatically):
\usepackage{url}
\url{https://example.com/path?a=1&b=2}
% Or with hyperref:
\href{https://example.com/path?a=1&b=2}{Click here}

% PROBLEM 2: Links to figures/tables go to wrong page
% This happens when \label is in the wrong place.
% BAD:
\caption{A figure.}
\label{fig:example}  % Label after caption = might link wrong
% GOOD:
\caption{A figure.}
\label{fig:example}  % Actually this is correct;
% just make sure \label is inside the float environment

% PROBLEM 3: hyperref conflicts with other packages
% Add this before hyperref to fix common conflicts:
\usepackage{etoolbox}
\usepackage{hyperref}
% If using amsmath theorems:
\providecommand{\theoremautorefname}{Theorem}

Handling Long URLs That Break Across Lines

Long URLs often overflow margins or break at awkward points. Here's how to fix that:

% Method 1: Use breaklinks option in hyperref
\hypersetup{breaklinks=true}

% Method 2: Use the url package with break settings
\usepackage{url}
\def\UrlBreaks{\do\/\do-\do.\do=\do_\do?\do&\do\#}

% Method 3: Use xurl package (best option)
\usepackage{xurl}  % Extends url with better line breaking

% Method 4: Manual line breaks in URLs
\href{https://example.com/very/long/path/to/
  resource/that/breaks}{Short display text}

% Method 5: Use footnotes for long URLs
See the documentation\footnote{
  \url{https://example.com/very/long/path/
  to/documentation/page}}.

% For academic papers, consider DOI links instead:
Available at \href{https://doi.org/10.1234/example}
  {doi:10.1234/example}.

💡 Tips

  • Always load hyperref as one of the last packages — loading it too early causes subtle and hard-to-debug conflicts.
  • If links work in one PDF viewer but not another, it's usually a viewer issue — test in Adobe Acrobat, Preview, and a browser.
  • Bibby AI loads hyperref in the correct order automatically and validates all URLs in your document.
  • Use \href{url}{text} for display links and \url{url} for showing the raw URL — don't type URLs as plain text.

Try This in Bibby AI

Write LaTeX faster with AI auto-complete and instant compilation.

Start Writing Free

Related Tutorials

Fix: Hyperlinks Not Working in PDF (LaTeX hyperref) | Bibby AI