% !TeX program = lualatex
\documentclass{article}
\ProvidesFile{docref.tex}[2026/11/30 v0.3.1 docref manual]
\usepackage{iftex}
\ifLuaTeX\else
  \PackageError{docref manual}{LuaLaTeX is required}{Compile this manual with LuaLaTeX.}
\fi

\usepackage{pkgmeta}
\usepackage{datemultical}
\dmcset{docref}{\pkgmeta[year]{docref}}{\pkgmeta[month]{docref}}{\pkgmeta[day]{docref}}
\usepackage{docref}
\usepackage[manual]{amikhteh-logo}
\usepackage[colorlinks]{hyperref}
\DocRefSource{geometry}{geometry-labels.aux}[geometry.pdf]

\definecolor{bbCoverInk}{HTML}{283F46}
\definecolor{bbCoverCream}{HTML}{EBDDB9}
\definecolor{bbCoverRose}{HTML}{DDBBAA}
\AmikhtehLogoFooterSetup{size=9mm,footskip=14mm}
\pagestyle{amikhteh-logo}

\begin{document}
\AmikhtehLogoFooterTitle{}
\noindent
\begin{tikzpicture}
  \node[fill=bbCoverInk,inner sep=5mm,outer sep=0pt,
    text width=\dimexpr\linewidth-10mm\relax,align=left] (panel) {%
    {\sffamily\small\color{bbCoverRose}PACKAGE GUIDE}\par\medskip
    {\sffamily\fontsize{29}{33}\selectfont\color{bbCoverCream}docref}\par\smallskip
    {\sffamily\color{bbCoverCream}Cross-references to package documentation}%
  };
  \fill[bbCoverRose] ([xshift=-1.5mm]panel.south east) rectangle (panel.north east);
  \node[anchor=north east,inner sep=2mm] at (panel.north east)
    {\AmikhtehLogo[size=18mm,primary=bbCoverCream,accent=bbCoverRose]};
\end{tikzpicture}\par\smallskip
\noindent Version \pkgmeta[version]{docref}\quad---\quad
\dmc{docref}{long}\hfill Amer Amikhteh

\begin{abstract}
    \noindent\texttt{docref} retrieves reference numbers, titles, and page numbers
    from locally available package documentation. It requires LuaLaTeX.
    Keep \texttt{docref.sty} and \texttt{docref.lua} together beside your document
    or in a TeX-searchable directory.
\end{abstract}

\section{Usage}\label{sec:hyperlinks}
Each command takes a package name and a label.
\verb|\docref{pkg}{label}| gives the reference number,
\verb|\docnameref{pkg}{label}| the title or caption, and
\verb|\docpageref{pkg}{label}| the page number.

For example, refer to a section in the Babel manual:
\begin{verbatim}
\usepackage{docref}
\usepackage{hyperref} % optional

See Section~\docref{babel}{selectors},
``\docnameref{babel}{selectors}'',
on page~\docpageref{babel}{selectors}.
\end{verbatim}

This refers to Babel section~\docref{babel}{selectors},
``\docnameref{babel}{selectors}'', on page~\docpageref{babel}{selectors}.

The same commands work for figures. This example uses the supplied label
record from the \texttt{geometry}~6.0 manual:
\begin{verbatim}
\DocRefSource{geometry}{geometry-labels.aux}[geometry.pdf]

Figure~\docref{geometry}{fig:Labc},
``\docnameref{geometry}{fig:Labc}'',
on page~\docpageref{geometry}{fig:Labc}.
\end{verbatim}

This refers to Figure~\docref{geometry}{fig:Labc},
``\docnameref{geometry}{fig:Labc}'', on page~\docpageref{geometry}{fig:Labc}.

With \textsf{hyperref}, loaded before or after \texttt{docref}, references
link to the external PDF. All three commands accept a star to suppress the
link, for example \verb|\docref*{geometry}{fig:Labc}|.
Unresolved values produce \texttt{??} and a warning.
Dotted number components follow the surrounding text direction; digits
within each component remain left to right.

\section{Selecting a manual}
Common source names include \texttt{pkg.tex}, \texttt{pkg-doc.tex}, and
\texttt{pkg-manual.tex}; \texttt{.ltx} and \texttt{.dtx} sources are also
supported. Installed documentation takes precedence over similarly named
files in the working directory.

Register a source or auxiliary file explicitly in the preamble:
\begin{verbatim}
\DocRefSource{pkg}{path/manual.tex}[path/manual.pdf]
\end{verbatim}
The optional final argument selects a PDF file or URL. Otherwise the PDF
is sought beside the source and in TeX's documentation search path.
A fragment's \verb|% !TeX root = manual.tex| comment selects its main
document. An auxiliary file can be registered without the TeX source.

When the source label or auxiliary file is unavailable, a PDF
bookmark can be registered by its exact title:
\begin{verbatim}
\DocRefPDF{pkg}{manual.pdf}[https://example.org/manual.pdf]
\DocRefBookmark{pkg}{my-label}{Heading title}
See Section~\docref{pkg}{my-label}.
\end{verbatim}
Register the local PDF before its bookmarks. The title must identify exactly
one bookmark, including among nested bookmarks; a leading section number in
Latin, Persian, or Arabic digits may be omitted from the registered title.
The PDF supplies the title,
printed page label, and section number when the bookmark contains one.
Without a page label, the physical page number is used. An absent number
cannot be obtained with \verb|\docref|; use \verb|\docnameref| or
\verb|\docpageref| instead.

Named destinations produce exact local or online links. A direct destination
is linked only if an identical named destination exists; otherwise the value
is shown without a link. The optional URL may include a query string; any
existing fragment is replaced by the named destination. If the online PDF
differs from the local one, its destination may differ. Bookmarks using
external actions rather than destinations within that PDF are not resolved.

\section{Labels and lookup rules}
For complete references, make the built manual's \texttt{.aux} file
available. Its records supply numbers, titles, pages, and destinations for
all label types, including chapters, figures, tables, equations, list items,
and custom counters.

Titles require records produced with \textsf{nameref} or \textsf{hyperref};
exact link destinations require \textsf{hyperref} in the target manual.
Titles are plain text; recorded empty values remain empty. Auxiliary files,
including those for included chapters, are read as data.

Source scanning alone handles headings from \texttt{section} to
\texttt{subparagraph}, with labels following their headings.
It cannot calculate arbitrary counters or pagination. PDF bookmarks and
page labels provide fallback titles and pages; physical page numbers are
used when page labels are absent.

Without an auxiliary destination, a standard section destination is used
only if it exists in the PDF; otherwise the link opens the manual at its
beginning. If no PDF is found, the reference remains unlinked.

\section{License}

The \texttt{Docref} package is released under the
\LaTeX~Project Public License (LPPL),
version 1.3c or later.
The full text of the license is available in the \texttt{LICENSE} file.

\section{Author and Maintainer}

The \texttt{Docref} package is developed and maintained by
\textbf{Amer Amikhteh}.

The project's source code, development versions, and issue tracker are
available in the project repository:

\begin{center}
    \url{https://github.com/gambi-shah/docref}
\end{center}

\end{document}
