\documentclass[11pt]{article}
\usepackage{a4wide}
\usepackage{hyperref}
\usepackage[
  style=numeric,
  datamodel=software,
  abbreviate=false,
  natbib=true,
  sorting=ydnt,
  backend=biber,
  bibencoding=utf8,
  giveninits=true,
  url=false,
  doi=false,
  maxcitenames=10,
  maxbibnames=100]{biblatex}

% Load the software biblatex style
\makeatletter
\def\input@path{{.}}
\makeatother
\usepackage{software-biblatex}

% Set software specific bibliography options
\ExecuteBibliographyOptions{
  halid=true,
  swhid=true,
  shortswhid=true,
  swlabels=true,
  vcs=true,
  license=false,
  addendum=false,
  crossrefexpansion=conditional}

\addbibresource{showcase-crossref.bib}

\title{Crossref Functionality Showcase}
\author{Software Bibliography Style}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This document demonstrates all features of the crossref implementation for software bibliography entries. It shows how inheritance chains work, how fields are compared, and how concise crossref formatting is applied. Each section includes examples with citations and the resulting bibliography entries.
\end{abstract}

\tableofcontents
\newpage

\section{Introduction}

The crossref functionality allows software bibliography entries to reference parent entries, creating inheritance chains where child entries inherit fields from their parents. This enables concise bibliography formatting by showing only the differences between child and parent entries.

\subsection{Key Concepts}

\begin{itemize}
\item \textbf{Inheritance}: Child entries automatically inherit fields from parent entries via the \texttt{crossref} field
\item \textbf{Field Comparison}: The system compares child fields with parent fields to determine what to display
\item \textbf{Concise Format}: Only differing fields are shown, with a citation reference to the parent
\item \textbf{Version/SWHID Requirement}: For Software → Version relationships to make sense, each \texttt{@softwareversion} entry MUST have either:
  \begin{itemize}
  \item An explicit \texttt{version} field, OR
  \item A \texttt{swhid} id
  \end{itemize}
  Entries without either will not use the ``version X of [parent]'' format.
\item \textbf{Relationship Types}: Different entry types use different relationship text:
  \begin{itemize}
  \item Versions: ``version X of [citation]''
  \item Modules: ``part of [citation]''
  \item Fragments: ``from [citation]''
  \end{itemize}
\item \textbf{Duplicate Detection}: When all key fields are equal, a warning is issued and the full entry is shown
\end{itemize}

\subsection{Inheritance Chains}

The following inheritance chains are supported:
\begin{itemize}
\item \textbf{2-level}: Software → Version
\item \textbf{3-level}: Software → Version → Module
\item \textbf{3-level}: Software → Version → Fragment
\item \textbf{4-level}: Software → Version → Module → Fragment
\end{itemize}

\newpage

\section{Basic Software → Version Examples}

This section demonstrates basic crossref scenarios between software and softwareversion entries, using the real-world Scilab example.

\subsection{Base Software Entry}

Scilab is a software for numerical computation. Here is the base software entry \cite{delebecque:hal-02090402}.

\subsection{Version with Different Date}

When only the date differs (but the version field is present), the output shows the version, date, and citation. The version field is required for proper Software → Version inheritance.

Example: \cite{delebecque:hal-02090402v1}

The output format is: \textit{Version 1.1, Jan. 1994 of [parent citation]}. The version entry shows the version number and date difference (1994 vs 1994-01) while inheriting author, title, and institution. It also includes SWHID and file information.

\subsection{Version with Different Version Number}

When only the version number differs, the output shows the version and date with a reference to the parent. Note that the \texttt{@softwareversion} entry must have an explicit \texttt{version} field or \texttt{swhid} id for this format to be used.

Example: \cite{delebecque:hal-02090402v2}

The output format is: \textit{Version 2.0, 1995 of [parent citation]}.

\subsection{Version with Different Title}

When the title differs, it is shown along with the citation.

Example: \cite{delebecque:hal-02090402v3}

The output shows the overridden title ``Scilab Extended'' along with the version and citation reference.

\subsection{Version with All Fields Equal (Warning Case)}

When a version entry has all fields identical to its parent, the system emits a warning and shows the full entry. This indicates a potential duplicate that should be reviewed.

Example: \cite{showcase-version-duplicate}

\textbf{Note}: Check the compilation log for a warning message about duplicate entries. This synthetic example is kept for pedagogical demonstration of duplicate detection.

\newpage

\section{Module Inheritance Examples}

Modules are components of software that can have their own versions or inherit versions from their parent. This section uses the real-world CGAL (Computational Geometry Algorithms Library) example throughout.

\subsection{Base Setup}

We start with the CGAL base software entry \cite{cgal} and its version \cite{cgal:5-0-2}.

\subsection{Module Inheriting Version}

When a module does not have an explicit version field, it inherits the version from its parent but does not display it. Only the author, subtitle, and ``part of'' relationship are shown.

Example: \cite{cgal:lp-gi-20a}

The output format is: \textit{M. Karavelas, ``2D Voronoi Diagram Adaptor'', part of [parent citation]} (no version shown, inherits from parent). The module also shows its license and URL, properly referencing the parent version.

\subsection{Module with Own Version}

When a module has its own explicit version that differs from the parent, both the version and the ``part of'' relationship are shown, along with the author.

Example: \cite{cgal:module-with-version}

The output format is: \textit{S. Pion, ``3D Convex Hull'', version 4.0 part of [parent citation]}.

\subsection{Module with Different Author}

Modules can have different authors while still referencing the parent.

Example: \cite{cgal:module-diff-author}

The output shows the different author (A. Fabri) along with the subtitle and ``part of'' relationship.

\newpage

\section{Fragment Inheritance Examples}

Code fragments represent specific code sections extracted from larger software components. This section uses the real-world Parmap library example throughout.

\subsection{Base Setup}

We start with the Parmap base software entry \cite{parmap} and its version \cite{parmap-1.1.1}.

\subsection{Fragment from Version}

A fragment can reference a version directly. The output shows the subtitle, date, and a reference to the parent version.

Example: \cite{simplemapper}

The output format is: \textit{``Core mapping routine'', 2020 from [parent citation]} (includes SWHID information with path and line numbers).

\subsection{Fragment from Module}

Fragments can also reference modules, creating a 4-level chain: Software → Version → Module → Fragment.

Example: \cite{parmap-fragment-from-module}

This demonstrates a complete 4-level inheritance chain where the fragment references a module, which in turn references a version, which references the base software entry.

\newpage

\section{Multi-level Inheritance}

This section demonstrates deep inheritance chains with multiple levels, using real-world examples.

\subsection{3-Level Chain: Software → Version → Module}

A complete 3-level chain showing how modules inherit from versions. This example uses the real-world CGAL library.

\begin{itemize}
\item Base software: \cite{cgal}
\item Version: \cite{cgal:5-0-2}
\item Module: \cite{cgal:lp-gi-20a}
\end{itemize}

The module properly references its parent version in the bibliography, showing only the fields that differ from the parent (author, subtitle, license, URL).

\subsection{4-Level Chain: Software → Version → Module → Fragment}

The deepest supported chain demonstrates complete inheritance. This example uses the real-world Parmap library.

\begin{itemize}
\item Base software: \cite{parmap}
\item Version: \cite{parmap-1.1.1}
\item Module: \cite{parmap-module-core}
\item Fragment: \cite{parmap-fragment-from-module}
\end{itemize}

Each level correctly references its parent, showing the complete inheritance chain. The fragment shows its subtitle and SWHID information, referencing the module which references the version which references the base software.

\subsection{Deep Chain with Module Version}

A module can have its own version in a deep chain. This example uses CGAL with a module variant that has an explicit version.

\begin{itemize}
\item Base: \cite{cgal}
\item Version: \cite{cgal:5-0-2}
\item Module with version: \cite{cgal:module-with-version}
\item Fragment: (fragment from module with version can be created if needed)
\end{itemize}

The module with its own version (4.0) is shown along with the ``part of'' relationship to the parent version.

\subsection{4-Level Chain: CGAL Voronoi Module → Fragment}

A complete 4-level chain using the CGAL Voronoi Diagram Adaptor module, showing a fragment extracted from the module.

\begin{itemize}
\item Base software: \cite{cgal}
\item Version: \cite{cgal:5-0-2}
\item Module: \cite{cgal:lp-gi-20a}
\item Fragment: \cite{cgal:voronoi-fragment}
\end{itemize}

This demonstrates a fragment (``Print Endpoint'') extracted from the CGAL Voronoi Diagram Adaptor module, creating a complete 4-level inheritance chain. The fragment shows its subtitle and SWHID information with path and line numbers, referencing the module.


\newpage

\section{Edge Cases and Special Scenarios}

This section demonstrates how the system handles special cases. These examples use synthetic entries specifically designed to test boundary conditions that may not exist in real-world data.

\subsection{Editor Field Comparison}

Entries with editor fields are compared correctly.

\begin{itemize}
\item Base with editor: \cite{showcase-with-editor}
\item Version with same editor: \cite{showcase-editor-same}
\item Version with different editor: \cite{showcase-editor-diff}
\end{itemize}

\subsection{Date Precision Differences}

The system handles different date precisions (year, year-month, full date).

\begin{itemize}
\item Base (year only): \cite{showcase-date-base}
\item Version (year-month): \cite{showcase-date-year-month}
\item Version (full date): \cite{showcase-date-full}
\end{itemize}

\subsection{Multiple Authors}

Entries with multiple authors are handled correctly.

\begin{itemize}
\item Base with 3 authors: \cite{showcase-multi-author}
\item Version with 4 authors: \cite{showcase-multi-author-version}
\end{itemize}

\newpage

\section{Complete Bibliography}

The following bibliography shows all entries with their crossref relationships and concise formatting.

\printbibliography[title={Complete Showcase Bibliography}]

\section{Summary}

This showcase demonstrates:

\begin{itemize}
\item Basic crossref functionality between software and versions (using Scilab)
\item Module inheritance with and without explicit versions (using CGAL)
\item Fragment inheritance from versions and modules (using Parmap)
\item Multi-level inheritance chains (3 and 4 levels) using real-world examples
\item Edge cases including editor fields, date precision, and multiple authors
\item Duplicate entry detection and warnings
\end{itemize}

All examples show how the crossref system creates concise bibliography entries by showing only the differences between child and parent entries, making bibliographies more readable and avoiding redundant information.

\end{document}

