- Ten years ago, Heiko provided the following solution for storing
biblatexoutputs (\citefield) for later use in headings (hyperrefbookmarks).
\makeatletter \newcommand*{\StoreCiteField}[3]{% \begingroup \global\let\StoreCiteField@Result\relax \citefield{#2}[StoreCiteField]{#3}% \endgroup \let#1\StoreCiteField@Result } \DeclareFieldFormat{StoreCiteField}{% \gdef\StoreCiteField@Result{#1}% } \makeatother
- I tried to adapt the code so that it works with
\citeauthorand failed. - Any ideas?
This is my (failing) attempt to use the same approach for \citeauthior:
\newcommand*{\StoreAuthor}[2]{%
\begingroup
\global\let\StoreAuthor@Result\relax
\citeauthor{#2}%
\endgroup
\let#1\StoreAuthor@Result
}
\DeclareFieldFormat{StoreAuthor}{%
\gdef\StoreAuthor@Result{#1}%
}
I punch way above my weight class here and just tried to find analogies in Heiko's code and adapted it accordingly. I do not understand the code. Yesterday, the previous regular user cfr commented on a related question (How can I make \citetitle work in a hyperref section bookmark?) because he/she has the same problem. This motivated me to try again.
\documentclass{article}
\usepackage{xcolor}
\usepackage{biblatex}
\begin{filecontents}{\jobname.bib}
@book{key,
title = {Book Title},
year = {2000},
author = {Givenname FamilyName},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\usepackage{hyperref}
\usepackage{bookmark}
% https://tex.stackexchange.com/questions/73678
\makeatletter
\newcommand{\StoreCiteField}[3]{%
\begingroup
\global\let\StoreCiteField@Result\relax
\citefield{#2}[StoreCiteField]{#3}%
\endgroup
\let#1\StoreCiteField@Result
}
\DeclareFieldFormat{StoreCiteField}{%
\gdef\StoreCiteField@Result{#1}%
}
%
\newcommand{\StoreAuthor}[2]{%
\begingroup
\global\let\StoreAuthor@Result\relax
\citeauthor{#2}%
\endgroup
\let#1\StoreAuthor@Result
}
\DeclareFieldFormat{StoreAuthor}{%
\gdef\StoreAuthor@Result{#1}%
}
\makeatother
\begin{document}
%% StoreCiteField (Working)
% Store Results
\StoreCiteField\myTitle{key}{title}
% Use Results In Headings
\section{Title (Working): \textcolor{red}{\myTitle}}
\myTitle
\noindent\rule{\textwidth}{1pt}
% Store Results
\StoreCiteField\myYear{key}{year}
% Use Results In Headings
\section{Year (Working): \textcolor{red}{\myYear}}
\myTitle
\noindent\rule{\textwidth}{1pt}
%% StoreAuthor (Nor Working)
% Store Results
\StoreAuthor\myAuthor{key}
% Use Results In Headings
\section{Author (Not Working): \textcolor{red}{\myAuthor}}
\myAuthor
\end{document}


biblatex, "author" ("editor" and some others) is a "name" rather than a simple "field". Take a look at\citenameinstead of\citefield. – gusbrs Mar 22 '22 at 01:38\citeauthoruses the\DeclareFieldFormat{StoreAuthor}? But ultimately the problem really is the one mentioned by Ulrike. I've tried with\citenameand\DeclareNameWrapperFormat, but it does not expand... – gusbrs Mar 22 '22 at 09:08