Skip to main content
To add clickable links and URLs in a LaTeX PDF, load \usepackage{hyperref} near the end of your preamble, then use \href{url}{text} for custom link text and \url{url} to print the address itself. Once hyperref is loaded, standard cross-references (\ref, \pageref), table-of-contents entries, and citations become clickable automatically. Choose the command based on what the reader should see in the PDF: In normal body text, both \url and \href accept _, #, and ~ inside the URL without escaping (inside another command’s argument such as \footnote{...}, escape # as \#). A literal % in a URL still starts a LaTeX comment unless escaped as \% (for example 100\%20ok). Load \usepackage{xurl} before hyperref so long URLs can break across lines at letters and digits as well as punctuation instead of overflowing into the margin.
basic-links.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
By default, hyperref keeps link text black and draws colored border boxes in the PDF viewer (red for internal links, green for citations, cyan for URLs). Configure appearance either in \usepackage[...]{hyperref} or with \hypersetup{...} in the preamble:
  • colorlinks=true: removes the boxes and colors the link text instead. Set categories with linkcolor (internal links and table of contents), citecolor (citations), urlcolor (web links), filecolor (local file links), or allcolors (all categories at once).
  • Color names: hyperref loads basic color names (black, white, red, green, blue, cyan, magenta, yellow). Extended names such as teal or purple require \usepackage{xcolor} before hyperref; otherwise compilation fails with ! LaTeX Error: Undefined color `teal'..
  • hidelinks: disables both link colors and border boxes while keeping every link clickable—useful for documents intended for printing.
link-colors.tex
When hyperref is loaded, ordinary \label and \ref commands create clickable links to sections, figures, tables, and equations. For the full labeling workflow, \eqref, and cleveref, see Cross-referencing. hyperref adds three internal-linking tools of its own:
  • \autoref{label} inserts the element name before its number. In English, hyperref defaults to lowercase chapter, section, subsection, and subsubsection, and capitalized Figure, Table, and Equation.
  • \hyperref[label]{custom text} links any phrase directly to an existing \label (note the square brackets around the label name).
  • \hypertarget{name}{text} and \hyperlink{name}{text} jump to destinations that have no LaTeX counter. For unnumbered headings such as \section*, place \phantomsection immediately before \addcontentsline or \label so the PDF anchor lands on the heading rather than the preceding numbered section.
internal-links.tex

PDF metadata and bookmark strings

Pass document properties to \hypersetup so PDF viewers display a title, author, subject, and keywords in the file properties panel (pdftitle, pdfauthor, pdfsubject, pdfkeywords). hyperref also generates PDF outline bookmarks from section titles. Math and formatting macros inside a heading trigger warnings such as Package hyperref Warning: Token not allowed in a PDF string (Unicode): followed by removing `math shift'. Wrap those parts in \texorpdfstring{LaTeX version}{plain PDF text} to supply clean bookmark text while keeping full math typesetting on the page.
hidelinks-metadata.tex

Where to load hyperref in the preamble

hyperref redefines internal macros from LaTeX and other packages so references, citations, and footnotes become links. Load it after most packages (including amsmath, graphicx, booktabs, xcolor, xurl, footmisc, natbib, and biblatex). A small set of packages explicitly expect hyperref to be loaded first so they can patch it in turn—most commonly cleveref and glossaries. Loading cleveref before hyperref stops compilation with ! Package cleveref Error: cleveref must be loaded after hyperref!..

Common hyperref issues

Try it in the editor

Because LaTeX Cloud Studio runs TeX Live 2026 (full distribution), hyperref, xcolor, and xurl work without extra setup. To test clickable links and PDF metadata directly, open the Basic Article template in LaTeX Cloud Studio and replace main.tex with the complete example.