skills/hyperref/SKILL.md
LaTeX hyperref package for hyperlinks, cross-references, bookmarks, and PDF metadata. Use when helping users add clickable links, configure PDF properties, or manage cross-references.
npx skillsauth add igbuend/grimbard hyperrefInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CTAN: https://ctan.org/pkg/hyperref
Manual: texdoc hyperref
% LOAD HYPERREF LAST (or near last) — it redefines many commands
\usepackage[
colorlinks=true,
linkcolor=blue,
citecolor=green!50!black,
urlcolor=blue!70!black,
pdftitle={My Document Title},
pdfauthor={Author Name},
]{hyperref}
% If using cleveref, load it AFTER hyperref:
\usepackage{cleveref}
| Option | Default | Description |
|--------|---------|-------------|
| colorlinks | false | Color link text (vs boxes) |
| linkcolor | red | Internal links (refs, TOC) |
| citecolor | green | Citation links |
| urlcolor | magenta | URL links |
| filecolor | cyan | File links |
| allcolors | — | Set all link colors at once |
| hidelinks | — | No color, no boxes (for print) |
| bookmarks | true | Generate PDF bookmarks |
| bookmarksnumbered | false | Include section numbers in bookmarks |
| bookmarksopen | false | Expand bookmarks by default |
| pdfborder | {0 0 1} | Link border (set {0 0 0} to remove) |
| breaklinks | true | Allow links to break across lines |
| unicode | true (modern) | Unicode in bookmarks |
| Option | Description |
|--------|-------------|
| pdftitle | Document title |
| pdfauthor | Author name(s) |
| pdfsubject | Subject |
| pdfkeywords | Keywords (comma-separated) |
| pdfcreator | Creating application |
| pdfproducer | PDF producer |
% Or set after loading:
\hypersetup{
pdftitle={My Paper},
pdfauthor={Jane Doe},
pdfsubject={LaTeX Tutorial},
pdfkeywords={LaTeX, hyperref, tutorial},
}
% External URL
\href{https://example.com}{Click here}
\href{mailto:[email protected]}{Email me}
\href{file:./report.pdf}{Local file}
% URL (typewriter, breakable)
\url{https://example.com/path?query=value}
% Internal reference with custom text
\hyperref[sec:intro]{see the introduction}
% Standard cross-references (auto-linked by hyperref)
\ref{fig:plot} % "3"
\pageref{tab:data} % "12"
\eqref{eq:main} % "(1)" — from amsmath
% Auto-named references
\autoref{fig:plot} % "Figure 3"
\autoref{tab:data} % "Table 2"
\autoref{sec:intro} % "section 1"
\autoref{eq:main} % "equation 1"
% Name reference (prints the title/caption)
\nameref{sec:intro} % "Introduction"
| Counter | Default name |
|---------|-------------|
| figure | Figure |
| table | Table |
| equation | equation |
| section | section |
| chapter | chapter |
| theorem | Theorem |
| page | page |
Customize: \renewcommand{\sectionautorefname}{Section}
\usepackage{hyperref}
\usepackage{cleveref} % MUST be after hyperref
% Automatic type detection + ranges
\cref{fig:a} % "fig. 1"
\Cref{fig:a} % "Figure 1" (capitalized)
\cref{fig:a,fig:b,fig:c} % "figs. 1 to 3"
\cref{eq:1,eq:2} % "eqs. (1) and (2)"
\crefrange{fig:a}{fig:d} % "figs. 1 to 4"
% Customize names
\crefname{equation}{eq.}{eqs.}
\Crefname{equation}{Equation}{Equations}
\crefname{figure}{fig.}{figs.}
% Manual bookmark entry
\pdfbookmark[level]{Text}{anchor}
\pdfbookmark[0]{Title Page}{title}
% Current bookmark (without section command)
\currentpdfbookmark{Appendix A}{appendixA}
% Bookmark with section:
\belowpdfbookmark{Subsection text}{anchor} % below current level
% Colored text links (preferred for screen)
\hypersetup{colorlinks=true, allcolors=blue}
% Boxed links (default)
\hypersetup{colorlinks=false, pdfborder={0 0 1}}
% Hidden links (for print)
\hypersetup{hidelinks}
% Custom: colored + no underline
\hypersetup{
colorlinks=true,
linkcolor={blue!80!black},
citecolor={green!60!black},
urlcolor={red!70!black},
}
\usepackage[
colorlinks=true,
linkcolor=black, % TOC/internal links in black
citecolor=blue!50!black,
urlcolor=blue!70!black,
bookmarks=true,
bookmarksnumbered=true,
]{hyperref}
\usepackage[
hidelinks, % clean for printing
bookmarks=true,
bookmarksnumbered=true,
bookmarksopen=true,
bookmarksopenlevel=2,
pdftitle={PhD Thesis},
pdfauthor={Name},
]{hyperref}
\usepackage{cleveref}
\usepackage[backref=page]{hyperref}
% Adds "Cited on page(s) X, Y" to bibliography entries
| Problem | Cause | Fix |
|---------|-------|-----|
| Broken cross-references | hyperref loaded too early | Load hyperref last (before cleveref) |
| \autoref says "section" lowercase | Default names | \renewcommand{\sectionautorefname}{Section} |
| Bookmark errors with math | Math in section titles | \texorpdfstring{$E=mc^2$}{E=mc2} |
| "Token not allowed" | Special chars in PDF strings | Use \texorpdfstring{LaTeX}{LaTeX} |
| Links in headers/footers | Fragile commands | Use \protect or \texorpdfstring |
| cleveref not working | Loaded before hyperref | Load order: hyperref → cleveref |
| Link boxes overlap text | Default border style | Use colorlinks=true or hidelinks |
| \url breaks wrong | Long URLs | hyperref handles this; check breaklinks=true |
| Conflicts with other packages | Package redefines same commands | Load hyperref after most packages |
% Safe order (most common packages):
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{...} % other packages
\usepackage[options]{hyperref} % near last
\usepackage{cleveref} % very last
colorlinks for screen PDFs; hidelinks for print\texorpdfstring{LaTeX version}{plain text} for anything fancy in section titles\phantomsection before \addcontentsline for correct hyperlinks in unnumbered sections\hypersetup{} can be called multiple times to change settings mid-document\nohyperpage in index entries to prevent hyperref page linkingdevelopment
Security anti-pattern for Cross-Site Scripting vulnerabilities (CWE-79). Use when generating or reviewing code that renders HTML, handles user input in web pages, uses innerHTML/document.write, or builds dynamic web content. Covers Reflected, Stored, and DOM-based XSS. AI code has 86% XSS failure rate.
development
Security anti-pattern for XPath injection vulnerabilities (CWE-643). Use when generating or reviewing code that queries XML documents, constructs XPath expressions, or handles user input in XML operations. Detects unescaped quotes and special characters in XPath queries.
development
Security anti-pattern for weak password hashing (CWE-327, CWE-759). Use when generating or reviewing code that stores or verifies user passwords. Detects use of MD5, SHA1, SHA256 without salt, or missing password hashing entirely. Recommends bcrypt, Argon2, or scrypt.
development
Security anti-pattern for weak encryption (CWE-326, CWE-327). Use when generating or reviewing code that encrypts data, handles encryption keys, or uses cryptographic modes. Detects DES, ECB mode, static IVs, and custom crypto implementations.