diff --git a/HSRTReport/Config/Bibliography.tex b/HSRTReport/Config/Bibliography.tex new file mode 100644 index 0000000..a1c3e91 --- /dev/null +++ b/HSRTReport/Config/Bibliography.tex @@ -0,0 +1,106 @@ +% !TEX root = ../HSRTReport.cls +% ============================================================================== +% Bibliography Configuration Module +% ============================================================================== +% Description: Configure BibLaTeX citation formatting and hyperlink behavior +% Author: Frederik Beimgraben +% License: Creative Commons CC BY 4.0 +% ============================================================================== + +% ============================================================================== +% BibLaTeX Hyperlink Configuration +% ============================================================================== +% Make entire citation content clickable, not just parts of it + +% Load hyperref support for biblatex +\ExecuteBibliographyOptions{ + hyperref=true, + backref=false, + url=true, + doi=true, + isbn=false +} + +% ------------------------------------------------------------------------------ +% Make entire citation clickable (not just author or year) +% ------------------------------------------------------------------------------ +% This works with APA style to make the complete "Author, Year" clickable + +% Redefine how hyperlinks are created in citations +\DeclareFieldFormat{citehyperref}{% + \bibhyperref{#1}% +} + +% Make cite command create single hyperlink +\DeclareCiteCommand{\cite} +{\usebibmacro{prenote}} +{\bibhyperref{\usebibmacro{citeindex}\usebibmacro{cite}}} +{\multicitedelim} +{\usebibmacro{postnote}} + +% Make parencite create single hyperlink for entire content +\DeclareCiteCommand{\parencite}[\mkbibparens] +{\usebibmacro{prenote}} +{\bibhyperref{\usebibmacro{citeindex}\usebibmacro{cite}}} +{\multicitedelim} +{\usebibmacro{postnote}} + +% Make textcite create unified hyperlink +\DeclareCiteCommand{\textcite} +{\usebibmacro{prenote}} +{\bibhyperref{% + \usebibmacro{citeindex}% + \printnames{labelname}% + \setunit{\nameyeardelim}% + \printfield{year}% + }} +{\multicitedelim} +{\usebibmacro{postnote}} + +% Alternative simple command for fully linked citations +\newcommand{\fcite}[1]{% + \hyperlink{cite.#1}{\citeauthor{#1}, \citeyear{#1}}% +} + +% Make footcite also use single hyperlink +\DeclareCiteCommand{\footcite}[\mkbibfootnote] +{\usebibmacro{prenote}} +{\bibhyperref{\usebibmacro{citeindex}\usebibmacro{cite}}} +{\multicitedelim} +{\usebibmacro{postnote}} + +% ============================================================================== +% Additional Citation Formatting +% ============================================================================== + +% ------------------------------------------------------------------------------ +% Citation punctuation +% ------------------------------------------------------------------------------ +\renewcommand{\nameyeardelim}{\addcomma\space} % Comma between author and year +\renewcommand{\multicitedelim}{\addsemicolon\space} % Semicolon between multiple citations + +% ------------------------------------------------------------------------------ +% Author name formatting in citations +% ------------------------------------------------------------------------------ +\DeclareNameAlias{sortname}{family-given} % Last name first in bibliography +\DeclareNameAlias{default}{given-family} % Normal order in citations + +% ------------------------------------------------------------------------------ +% URL and DOI formatting +% ------------------------------------------------------------------------------ +\DeclareFieldFormat{url}{\url{#1}} +\DeclareFieldFormat{doi}{% + \ifhyperref + {\href{https://doi.org/#1}{\nolinkurl{doi:#1}}} + {\nolinkurl{doi:#1}}% +} + +% ------------------------------------------------------------------------------ +% Bibliography spacing +% ------------------------------------------------------------------------------ +\setlength{\bibitemsep}{0.5\baselineskip} % Space between bibliography entries +\setlength{\bibhang}{2em} % Hanging indent for bibliography + +% ============================================================================== +% End of Bibliography Configuration Module +% ============================================================================== diff --git a/HSRTReport/HSRTReport.cls b/HSRTReport/HSRTReport.cls index 35257ca..5c1274c 100644 --- a/HSRTReport/HSRTReport.cls +++ b/HSRTReport/HSRTReport.cls @@ -73,6 +73,7 @@ % Configuration Modules % ------------------------------------------------------------------------------ \input{\classPath/Config/Hyperref} +\input{\classPath/Config/Bibliography} \input{\classPath/Config/Fonts} \input{\classPath/Config/PageSetup} \input{\classPath/Config/Sections} diff --git a/Preamble.tex b/Preamble.tex index 2ef9384..2a302ff 100644 --- a/Preamble.tex +++ b/Preamble.tex @@ -18,6 +18,57 @@ % ------------------------------------------------------------------------------ \addbibresource{Main.bib} +% ------------------------------------------------------------------------------ +% Citation Hyperlink Configuration +% ------------------------------------------------------------------------------ +% Make entire citation content clickable (Author, Year) instead of just parts +% This uses BibLaTeX's internal commands for better compatibility with APA style +% ------------------------------------------------------------------------------ + +% Use AtBeginDocument to ensure our settings override the APA style +\AtBeginDocument{% + % Store original definitions + \let\origparencite\parencite + \let\origtextcite\textcite + \let\origcite\cite + + % Redefine parencite to make entire content clickable + \DeclareCiteCommand{\parencite}[\mkbibparens] + {\usebibmacro{prenote}} + {\bibhyperref{% + \usebibmacro{citeindex}% + \usebibmacro{cite}% + }} + {\multicitedelim} + {\usebibmacro{postnote}} + + % Redefine textcite to make entire content clickable + \DeclareCiteCommand{\textcite} + {\boolfalse{cbx:parens}% + \usebibmacro{prenote}} + {\bibhyperref{% + \usebibmacro{citeindex}% + \printnames{labelname}% + \setunit{\addspace}% + \bibopenparen\usebibmacro{citeyear}\bibcloseparen% + }} + {\ifbool{cbx:parens} + {\bibcloseparen\global\boolfalse{cbx:parens}} + {}% + \multicitedelim} + {\usebibmacro{postnote}} + + % Redefine cite to make entire content clickable + \DeclareCiteCommand{\cite} + {\usebibmacro{prenote}} + {\bibhyperref{% + \usebibmacro{citeindex}% + \usebibmacro{cite}% + }} + {\multicitedelim} + {\usebibmacro{postnote}} +} + % ------------------------------------------------------------------------------ % Document Settings Import % ------------------------------------------------------------------------------