LaTeX

LaTeX Hyperlinks with hyperref: \href, \url, Link Colors and Internal Links

Everything you need from the hyperref package for papers and theses, with tested examples.

MZ
Dr. Meng Zhao|Physician-Scientist · Founder, LabCat AI
Published: October 2026•7 min read•LaTeX

Links in a LaTeX PDF come from one package, hyperref. Loading it turns citations, cross-references and the table of contents into links, and adds \href and \url for links to the web.

Short answer

Load \usepackage{hyperref} near the end of the preamble. Use \href{https://...}{link text} for a named link and \url{https://...} to print the address itself. Add \hypersetup{colorlinks=true} to replace the boxes with colored text.

Links to web pages and email

\documentclass{article}
\usepackage{hyperref}
\begin{document}
Use the \href{https://www.journalmetrics.org/journal-rankings}{journal
rankings} or go to \url{https://www.journalmetrics.org}.
Questions: \href{mailto:editor@example.org}{email the editor}.
\end{document}

\href shows your text, \url shows the address in a typewriter font. Both accept %, # and _ in the address as typed, as long as the command is not inside the argument of another command such as a footnote or caption. Inside those, escape them as \% and \#.

Links to sections, figures and pages

Once hyperref is loaded, every \ref, \pageref and \cite is already a link. A few extra commands give you more control:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{Methods}\label{sec:methods}
See \autoref{sec:methods}, or read
\hyperref[sec:methods]{the methods section}, or
\nameref{sec:methods} by name.
\end{document}
  • \autoref{label} adds the type for you ("section 1", "Figure 2"). Change the word with, for example, \renewcommand{\sectionautorefname}{Section}.
  • \hyperref[label]{text} links any text to a label.
  • \nameref{label} prints the title of the section.
  • \hypertarget{name}{text} and \hyperlink{name}{text} link to any point, labelled or not.

Change link colors or remove the boxes

By default hyperref draws colored boxes around links. They show on screen but not in print. Most journals and thesis offices prefer colored text or no marking at all:

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=blue,
  citecolor=blue,
  urlcolor=blue
}
\begin{document}
Links are now blue text.
\end{document}

linkcolor covers internal links (sections, figures, footnotes), citecolor covers citations and urlcolor covers \href and \url. For links that work but look like plain text, use \hypersetup{hidelinks} instead. That is the safest choice for a printed thesis.

Break long URLs

A long address can run into the margin because \url only breaks at a few characters. The xurl package allows a break after any character:

\documentclass{article}
\usepackage{xurl}
\usepackage{hyperref}
\begin{document}
\url{https://www.journalmetrics.org/journal-rankings/political-science/a/very/long/path/that/needs/to/break}
\end{document}

Set the PDF title and author

Readers see the PDF title in the browser tab and in reference managers. Set it with \hypersetup:

\hypersetup{pdftitle={My Thesis Title}, pdfauthor={A. Author}}

Where to load hyperref

hyperref redefines many commands, so load it after most other packages. Some packages must come after it, the best known being cleveref. If you see odd errors after adding a package, check the order first. A missing hyperref is the usual reason for "Undefined control sequence" on \href; see our undefined control sequence guide.

Frequently Asked Questions

How do I insert a hyperlink in LaTeX?

Load hyperref and write \href{https://example.org}{link text}. For the address itself, use \url{https://example.org}.

How do I remove the red boxes around links?

Add \hypersetup{colorlinks=true} for colored text, or \hypersetup{hidelinks} for links that look like normal text.

How do I link to a section in LaTeX?

Add \label{sec:name} after the section command and use \ref{sec:name}, \autoref{sec:name} or \hyperref[sec:name]{your text}.

More LaTeX Guides

MZ

Written by Dr. Meng Zhao

Physician-Scientist · Founder, LabCat AI

MD · Former Neurosurgeon · Medical AI Researcher

Dr. Meng Zhao is a former neurosurgeon turned medical-AI researcher. After years in the operating room, he moved into applied AI for clinical workflows and now leads LabCat AI, a medical-AI company working on decision support and research tooling for clinicians. He built Journal Metrics as a free resource for researchers who need reliable journal metrics without paid database subscriptions.

Related Articles